diff --git a/Algomap/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py b/Algomap/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py index 519f416b..8a99b971 100644 --- a/Algomap/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py +++ b/Algomap/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py @@ -25,4 +25,4 @@ def findClosestNumber(self, nums): diff1, diff2 = min_pos, 0 - max_neg if diff1 < diff2: return min_pos - return max_neg \ No newline at end of file + return max_neg diff --git a/Algomap/Merge_Strings_Alternately/Merge_Strings_Alternately.py b/Algomap/Merge_Strings_Alternately/Merge_Strings_Alternately.py index 78a61128..c8433556 100644 --- a/Algomap/Merge_Strings_Alternately/Merge_Strings_Alternately.py +++ b/Algomap/Merge_Strings_Alternately/Merge_Strings_Alternately.py @@ -10,12 +10,12 @@ def mergeAlternately(self, word1, word2): if len(word1) < len(word2): for i in range(len(word1)): mergedword += word1[i] + word2[i] - mergedword += word2[len(word1):len(word2)] + mergedword += word2[len(word1) : len(word2)] return mergedword elif len(word1) > len(word2): for i in range(len(word2)): mergedword += word1[i] + word2[i] - mergedword += word1[len(word2):len(word1)] + mergedword += word1[len(word2) : len(word1)] return mergedword else: for i in range(len(word2)): @@ -31,4 +31,4 @@ def mergeAlternately(self, word1, word2): # if i < len(word2): # result.append(word2[i]) # i += 1 - # return ''.join(result) \ No newline at end of file + # return ''.join(result) diff --git a/Algomap/roman_to_integer/roman_to_integer.py b/Algomap/roman_to_integer/roman_to_integer.py index 4e3d86aa..247dc87d 100644 --- a/Algomap/roman_to_integer/roman_to_integer.py +++ b/Algomap/roman_to_integer/roman_to_integer.py @@ -4,15 +4,7 @@ def romanToInt(self, s): :type s: str :rtype: int """ - d = { - "I" : 1, - "V" : 5, - "X" : 10, - 'L' : 50, - "C" : 100, - 'D' : 500, - "M": 1000 - } + d = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} # print(d.keys(), "\n", d.values()) summ = 0 i = 0 @@ -24,4 +16,3 @@ def romanToInt(self, s): summ += d[s[i]] i += 1 return summ - \ No newline at end of file diff --git a/Codechef/ABSTRING/ABSTRING.py b/Codechef/ABSTRING/ABSTRING.py index 906293fd..dd052e98 100644 --- a/Codechef/ABSTRING/ABSTRING.py +++ b/Codechef/ABSTRING/ABSTRING.py @@ -1,5 +1,6 @@ import collections -T = int(input()) + +T = int(input()) while T: T -= 1 N = int(input()) @@ -12,4 +13,4 @@ if c > 0: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/AB_Diff/AB_Diff.py b/Codechef/AB_Diff/AB_Diff.py index fcaaba63..74b3a874 100644 --- a/Codechef/AB_Diff/AB_Diff.py +++ b/Codechef/AB_Diff/AB_Diff.py @@ -1,2 +1,2 @@ A, B = map(int, input().split()) -print(abs((A * B) - (A + B))) \ No newline at end of file +print(abs((A * B) - (A + B))) diff --git a/Codechef/AC_Temp/AC_Temp.py b/Codechef/AC_Temp/AC_Temp.py index 444bea74..2f3000cb 100644 --- a/Codechef/AC_Temp/AC_Temp.py +++ b/Codechef/AC_Temp/AC_Temp.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, C = map(int, input().split()) - if (A > B or C > B): + if A > B or C > B: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/ADJSUMPAR/ADJSUMPAR.py b/Codechef/ADJSUMPAR/ADJSUMPAR.py index be5575e7..d2cb424f 100644 --- a/Codechef/ADJSUMPAR/ADJSUMPAR.py +++ b/Codechef/ADJSUMPAR/ADJSUMPAR.py @@ -3,8 +3,8 @@ T -= 1 N = int(input()) B = input() - c = B.count('1') - if(c % 2 == 0): + c = B.count("1") + if c % 2 == 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/AIRM/AIRM.py b/Codechef/AIRM/AIRM.py index 66bd12a5..9e8bb4ab 100644 --- a/Codechef/AIRM/AIRM.py +++ b/Codechef/AIRM/AIRM.py @@ -11,9 +11,9 @@ d[i] = 1 else: d[i] += 1 - + c = 0 for i in d: if d[i] > c: c = d[i] - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/ALTSTR/ALTSTR.py b/Codechef/ALTSTR/ALTSTR.py index 61bb92e0..effcf40e 100644 --- a/Codechef/ALTSTR/ALTSTR.py +++ b/Codechef/ALTSTR/ALTSTR.py @@ -3,9 +3,9 @@ S = list(input()) z_c = S.count("0") o_c = S.count("1") - + if o_c == z_c: print(N) else: res = min(o_c, z_c) * 2 + 1 - print(res) \ No newline at end of file + print(res) diff --git a/Codechef/AMMEAT/AMMEAT.py b/Codechef/AMMEAT/AMMEAT.py index 0596307f..5d0b55ff 100644 --- a/Codechef/AMMEAT/AMMEAT.py +++ b/Codechef/AMMEAT/AMMEAT.py @@ -5,11 +5,11 @@ P = list(map(int, input().split())) P.sort() c = 0 - for i in range(-1 , -len(P) - 1 , -1): + for i in range(-1, -len(P) - 1, -1): M -= P[i] c = c + 1 if M <= 0: print(c) break else: - print(-1) \ No newline at end of file + print(-1) diff --git a/Codechef/ARRINT/ARRINT.py b/Codechef/ARRINT/ARRINT.py index a607a36c..4daefd34 100644 --- a/Codechef/ARRINT/ARRINT.py +++ b/Codechef/ARRINT/ARRINT.py @@ -7,4 +7,4 @@ C1 = set(map(int, input().split())) A1 = A1.intersection(B1) A1 = A1.intersection(C1) - print(len(A1)) \ No newline at end of file + print(len(A1)) diff --git a/Codechef/ASTHIT/ASTHIT.py b/Codechef/ASTHIT/ASTHIT.py index ac9f537f..185145e4 100644 --- a/Codechef/ASTHIT/ASTHIT.py +++ b/Codechef/ASTHIT/ASTHIT.py @@ -3,7 +3,7 @@ T -= 1 n = int(input()) dir = [] - pow = [] + pow = [] for i in range(n): ele1, ele2 = list(map(int, input().split())) dir.append(ele1) @@ -23,11 +23,11 @@ else: pow[stack[-1]] += pow[i] else: - a.append(i) + a.append(i) while stack: a.append(stack.pop()) a.sort() print(len(a)) if len(a) > 0: for i in a: - print(i + 1, end = " ") \ No newline at end of file + print(i + 1, end=" ") diff --git a/Codechef/ATM/ATM.py b/Codechef/ATM/ATM.py index 1a2cfb9b..691ea66f 100644 --- a/Codechef/ATM/ATM.py +++ b/Codechef/ATM/ATM.py @@ -14,5 +14,5 @@ else: l_2.append(0) for i in l_2: - print(i, end = "") + print(i, end="") print() diff --git a/Codechef/ATM2/ATM2.py b/Codechef/ATM2/ATM2.py index 1902401e..629790e3 100644 --- a/Codechef/ATM2/ATM2.py +++ b/Codechef/ATM2/ATM2.py @@ -10,4 +10,4 @@ tid.append(1) else: tid.append(0) - print(*tid, sep="") \ No newline at end of file + print(*tid, sep="") diff --git a/Codechef/Accuracy/Accuracy.py b/Codechef/Accuracy/Accuracy.py index d02a2789..07af2aa9 100644 --- a/Codechef/Accuracy/Accuracy.py +++ b/Codechef/Accuracy/Accuracy.py @@ -1,8 +1,9 @@ import math + T = int(input()) while T: T -= 1 X = int(input()) - temp = math.ceil(X/3) + temp = math.ceil(X / 3) temp *= 3 - print(temp - X) \ No newline at end of file + print(temp - X) diff --git a/Codechef/Acs/Acs.py b/Codechef/Acs/Acs.py index 200d53d1..f82ffcc1 100644 --- a/Codechef/Acs/Acs.py +++ b/Codechef/Acs/Acs.py @@ -5,4 +5,4 @@ if ((P % 100) + (P // 100)) <= 10: print((P % 100) + (P // 100)) else: - print(-1) \ No newline at end of file + print(-1) diff --git a/Codechef/Advance/Advance.py b/Codechef/Advance/Advance.py index 155c6fcf..0e1f66e8 100644 --- a/Codechef/Advance/Advance.py +++ b/Codechef/Advance/Advance.py @@ -1,8 +1,8 @@ T = int(input()) while T: - T -= 1 + T -= 1 X, Y = map(int, input().split()) if Y >= X and Y <= (X + 200): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Age_Limit/Age_Limit.py b/Codechef/Age_Limit/Age_Limit.py index 4d6258bb..d87409c0 100644 --- a/Codechef/Age_Limit/Age_Limit.py +++ b/Codechef/Age_Limit/Age_Limit.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y, A = map(int, input().split()) - if (A >= X and A < Y): + if A >= X and A < Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Ageing/Ageing.py b/Codechef/Ageing/Ageing.py index 1faabf4e..848e743c 100644 --- a/Codechef/Ageing/Ageing.py +++ b/Codechef/Ageing/Ageing.py @@ -2,4 +2,4 @@ while T: T -= 1 X = int(input()) - print(X - 10) \ No newline at end of file + print(X - 10) diff --git a/Codechef/Air_Hockey/Air_Hockey.py b/Codechef/Air_Hockey/Air_Hockey.py index 37c289f3..445980ed 100644 --- a/Codechef/Air_Hockey/Air_Hockey.py +++ b/Codechef/Air_Hockey/Air_Hockey.py @@ -4,4 +4,4 @@ A, B = map(int, input().split()) A = 7 - A B = 7 - B - print(min(A, B)) \ No newline at end of file + print(min(A, B)) diff --git a/Codechef/Airline/Airline.py b/Codechef/Airline/Airline.py index 287c2fa8..449be024 100644 --- a/Codechef/Airline/Airline.py +++ b/Codechef/Airline/Airline.py @@ -11,6 +11,6 @@ elif (B + C) <= D and A <= E: print("YES") - + else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Airlines/Airlines.py b/Codechef/Airlines/Airlines.py index 9329e823..11a6d1c6 100644 --- a/Codechef/Airlines/Airlines.py +++ b/Codechef/Airlines/Airlines.py @@ -3,7 +3,7 @@ T -= 1 X, Y, Z = map(int, input().split()) limit = 10 * X - if (limit < Y): + if limit < Y: print(limit * Z) else: - print(Y * Z) \ No newline at end of file + print(Y * Z) diff --git a/Codechef/Alta_Ray/Alta_Ray.py b/Codechef/Alta_Ray/Alta_Ray.py index 813fad49..44d54686 100644 --- a/Codechef/Alta_Ray/Alta_Ray.py +++ b/Codechef/Alta_Ray/Alta_Ray.py @@ -3,11 +3,11 @@ T -= 1 N = int(input()) A = list(map(int, input().split())) - + res = [1 for i in range(N)] - for i in range(N-2, -1, -1): + for i in range(N - 2, -1, -1): if A[i + 1] * A[i] < 0: - res[i] = res[i + 1] + 1 + res[i] = res[i + 1] + 1 for i in res[:-1]: - print(i, end = " ") - print(res[-1]) \ No newline at end of file + print(i, end=" ") + print(res[-1]) diff --git a/Codechef/Apple_Orange/Apple_Orange.py b/Codechef/Apple_Orange/Apple_Orange.py index 00ab0f0c..a44e26a5 100644 --- a/Codechef/Apple_Orange/Apple_Orange.py +++ b/Codechef/Apple_Orange/Apple_Orange.py @@ -1,12 +1,13 @@ def hcf(a, b): - if (b == 0): + if b == 0: return abs(a) else: return hcf(b, a % b) + T = int(input()) while T: T -= 1 N, M = map(int, input().split()) result = hcf(N, M) - print(result) \ No newline at end of file + print(result) diff --git a/Codechef/Attendu/Attendu.py b/Codechef/Attendu/Attendu.py index 2f7b43e4..f7c7306f 100644 --- a/Codechef/Attendu/Attendu.py +++ b/Codechef/Attendu/Attendu.py @@ -8,8 +8,8 @@ if i == "1": c1 += 1 remain = 120 - N + c1 - atten_perc = (remain/120) * 100 + atten_perc = (remain / 120) * 100 if atten_perc >= 75: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Auction/Auction.py b/Codechef/Auction/Auction.py index 13a62510..e430fdc9 100644 --- a/Codechef/Auction/Auction.py +++ b/Codechef/Auction/Auction.py @@ -2,9 +2,9 @@ while T: T -= 1 A, B, C = map(int, input().split()) - if (A > B and A > C): + if A > B and A > C: print("Alice") - elif (B > A and B > C): + elif B > A and B > C: print("Bob") else: - print("Charlie") \ No newline at end of file + print("Charlie") diff --git a/Codechef/Audible/Audible.py b/Codechef/Audible/Audible.py index 5e8289ed..0c8b256e 100644 --- a/Codechef/Audible/Audible.py +++ b/Codechef/Audible/Audible.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X >= 67 and X <= 45000): + if X >= 67 and X <= 45000: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Avg/Avg.py b/Codechef/Avg/Avg.py index a1d0842d..5f81b608 100644 --- a/Codechef/Avg/Avg.py +++ b/Codechef/Avg/Avg.py @@ -3,8 +3,8 @@ T -= 1 N, K, V = map(int, input().split()) A = list(map(int, input().split())) - result = ((V * (N + K)) - sum(A))/K + result = ((V * (N + K)) - sum(A)) / K if result.is_integer() and result > 0: print(int(result)) else: - print(-1) \ No newline at end of file + print(-1) diff --git a/Codechef/Avg_Problem/Avg_Problem.py b/Codechef/Avg_Problem/Avg_Problem.py index 7cc95320..d45431ea 100644 --- a/Codechef/Avg_Problem/Avg_Problem.py +++ b/Codechef/Avg_Problem/Avg_Problem.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, C = map(int, input().split()) - if (A + B)/2 > C: + if (A + B) / 2 > C: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/BLOBBYVOLLEY/BLOBBYVOLLEY.py b/Codechef/BLOBBYVOLLEY/BLOBBYVOLLEY.py index 358d6061..520cf48a 100644 --- a/Codechef/BLOBBYVOLLEY/BLOBBYVOLLEY.py +++ b/Codechef/BLOBBYVOLLEY/BLOBBYVOLLEY.py @@ -1,4 +1,4 @@ -T = int(input()) +T = int(input()) while T: T -= 1 N = int(input()) @@ -7,12 +7,12 @@ alice = 0 bob = 0 for j in range(N): - if((server == 0) and (S[j] == 'A')): + if (server == 0) and (S[j] == "A"): alice += 1 - elif((server == 0) and (S[j] == 'B')): + elif (server == 0) and (S[j] == "B"): server = 1 - elif((server == 1) and (S[j] == 'B')): + elif (server == 1) and (S[j] == "B"): bob += 1 else: server = 0 - print(alice, "", bob) \ No newline at end of file + print(alice, "", bob) diff --git a/Codechef/BMI/BMI.py b/Codechef/BMI/BMI.py index a9710c96..5e00bc7e 100644 --- a/Codechef/BMI/BMI.py +++ b/Codechef/BMI/BMI.py @@ -2,7 +2,7 @@ while T: T -= 1 M, H = map(int, input().split()) - result = M/H**2 + result = M / H**2 if result <= 18: print(1) elif result >= 19 and result <= 24: @@ -10,4 +10,4 @@ elif result >= 25 and result <= 29: print(3) else: - print(4) \ No newline at end of file + print(4) diff --git a/Codechef/BREAKSTICK/BREAKSTICK.py b/Codechef/BREAKSTICK/BREAKSTICK.py index d5f780f7..ec0b885a 100644 --- a/Codechef/BREAKSTICK/BREAKSTICK.py +++ b/Codechef/BREAKSTICK/BREAKSTICK.py @@ -2,7 +2,7 @@ while T: T -= 1 N, X = map(int, input().split()) - if(N % 2 == 0 or X % 2 != 0): - print('YES') + if N % 2 == 0 or X % 2 != 0: + print("YES") else: - print('NO') \ No newline at end of file + print("NO") diff --git a/Codechef/Badminton/Badminton.py b/Codechef/Badminton/Badminton.py index 0db6ff8a..e2d4be12 100644 --- a/Codechef/Badminton/Badminton.py +++ b/Codechef/Badminton/Badminton.py @@ -2,4 +2,4 @@ while T: T -= 1 P = int(input()) - print((P//2) + 1) \ No newline at end of file + print((P // 2) + 1) diff --git a/Codechef/Balloon/Balloon.py b/Codechef/Balloon/Balloon.py index a8f735b7..a7848a09 100644 --- a/Codechef/Balloon/Balloon.py +++ b/Codechef/Balloon/Balloon.py @@ -9,4 +9,4 @@ c += 1 if c == 7: print(i + 1) - break \ No newline at end of file + break diff --git a/Codechef/Bath/Bath.py b/Codechef/Bath/Bath.py index f0752178..b5d46d66 100644 --- a/Codechef/Bath/Bath.py +++ b/Codechef/Bath/Bath.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print(X//(2*Y)) \ No newline at end of file + print(X // (2 * Y)) diff --git a/Codechef/Battery_Low/Battery_Low.py b/Codechef/Battery_Low/Battery_Low.py index fda29286..d5b2c4b5 100644 --- a/Codechef/Battery_Low/Battery_Low.py +++ b/Codechef/Battery_Low/Battery_Low.py @@ -5,4 +5,4 @@ if X <= 15: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Best_Bats/Best_Bats.py b/Codechef/Best_Bats/Best_Bats.py index 1f414815..a05c6990 100644 --- a/Codechef/Best_Bats/Best_Bats.py +++ b/Codechef/Best_Bats/Best_Bats.py @@ -1,4 +1,5 @@ import math + T = int(input()) while T: T -= 1 @@ -11,4 +12,4 @@ for i in range(11 - K, 11): if L[i] == g: c += 1 - print(math.comb(c1, c)) \ No newline at end of file + print(math.comb(c1, c)) diff --git a/Codechef/Best_Of_Two/Best_Of_Two.py b/Codechef/Best_Of_Two/Best_Of_Two.py index e9e1c2c2..9a4846cc 100644 --- a/Codechef/Best_Of_Two/Best_Of_Two.py +++ b/Codechef/Best_Of_Two/Best_Of_Two.py @@ -1,4 +1,4 @@ T = int(input()) for i in range(T): - X, Y=map(int, input().split()) - print(max(X, Y)) \ No newline at end of file + X, Y = map(int, input().split()) + print(max(X, Y)) diff --git a/Codechef/Bet_Deal/Bet_Deal.py b/Codechef/Bet_Deal/Bet_Deal.py index 4bd886bf..d309d9c8 100644 --- a/Codechef/Bet_Deal/Bet_Deal.py +++ b/Codechef/Bet_Deal/Bet_Deal.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B = map(int, input().split()) - min_A = 100 - A + min_A = 100 - A min_B = 200 - (B * 200) / 100 # print(min_A, "\n" , min_B) if min_A < min_B: @@ -10,4 +10,4 @@ elif min_A > min_B: print("SECOND") else: - print("BOTH") \ No newline at end of file + print("BOTH") diff --git a/Codechef/Binary_Sub/Binary_Sub.py b/Codechef/Binary_Sub/Binary_Sub.py index 3172f7f0..68abaa51 100644 --- a/Codechef/Binary_Sub/Binary_Sub.py +++ b/Codechef/Binary_Sub/Binary_Sub.py @@ -1,21 +1,21 @@ T = int(input()) while T: T -= 1 - S = input() + S = input() N = len(S) M = 998244353 dp = [0] * N - dp[0] = 1 - if(N == 1): + dp[0] = 1 + if N == 1: print(dp[0]) else: - if(S[0] == S[1]): - dp[1] = 1 + if S[0] == S[1]: + dp[1] = 1 else: - dp[1] = 2 + dp[1] = 2 for i in range(2, N): - if(S[i] == S[i - 1]): - dp[i] = (dp[i - 1]) % M + if S[i] == S[i - 1]: + dp[i] = (dp[i - 1]) % M else: - dp[i] = (dp[i - 1] + dp[i - 2]) % M - print(dp[N - 1]) \ No newline at end of file + dp[i] = (dp[i - 1] + dp[i - 2]) % M + print(dp[N - 1]) diff --git a/Codechef/Black_Jack/Black_Jack.py b/Codechef/Black_Jack/Black_Jack.py index d3b0487d..c8d6e707 100644 --- a/Codechef/Black_Jack/Black_Jack.py +++ b/Codechef/Black_Jack/Black_Jack.py @@ -6,4 +6,4 @@ if C <= 10: print(C) else: - print(-1) \ No newline at end of file + print(-1) diff --git a/Codechef/Book_Pack/Book_Pack.py b/Codechef/Book_Pack/Book_Pack.py index 82f7ff6a..8b14d114 100644 --- a/Codechef/Book_Pack/Book_Pack.py +++ b/Codechef/Book_Pack/Book_Pack.py @@ -1,9 +1,10 @@ import math + T = int(input()) while T: T -= 1 X, Y, Z = map(int, input().split()) - if (Y <= Z): + if Y <= Z: print(X) else: - print(X * math.ceil(Y/Z)) \ No newline at end of file + print(X * math.ceil(Y / Z)) diff --git a/Codechef/Bottom/Bottom.py b/Codechef/Bottom/Bottom.py index db47fe1c..3d80e5dc 100644 --- a/Codechef/Bottom/Bottom.py +++ b/Codechef/Bottom/Bottom.py @@ -2,4 +2,4 @@ while T: T -= 1 X = int(input()) - print(7 - X) \ No newline at end of file + print(7 - X) diff --git a/Codechef/Brackets/Brackets.py b/Codechef/Brackets/Brackets.py index fe2ddb20..fe632b69 100644 --- a/Codechef/Brackets/Brackets.py +++ b/Codechef/Brackets/Brackets.py @@ -5,10 +5,10 @@ balance = 0 max_balance = 0 for i in range(len(A)): - if A[i] == '(': + if A[i] == "(": balance += 1 - if A[i] == ')': - balance -= 1 - + if A[i] == ")": + balance -= 1 + max_balance = max(max_balance, balance) - print("("*max_balance+")"*max_balance) \ No newline at end of file + print("(" * max_balance + ")" * max_balance) diff --git a/Codechef/Breadstick/Breadstick.py b/Codechef/Breadstick/Breadstick.py index 8e74845f..6cffd1a8 100644 --- a/Codechef/Breadstick/Breadstick.py +++ b/Codechef/Breadstick/Breadstick.py @@ -2,10 +2,10 @@ while T: T -= 1 N, X = map(int, input().split()) - - if (N % X == 0): + + if N % X == 0: print("YES") - elif ((N % 2 == 0 and X % 2 == 0) or (X % 2 == 1)): + elif (N % 2 == 0 and X % 2 == 0) or (X % 2 == 1): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Broken_Phone/Broken_Phone.py b/Codechef/Broken_Phone/Broken_Phone.py index a53034bf..68a7d304 100644 --- a/Codechef/Broken_Phone/Broken_Phone.py +++ b/Codechef/Broken_Phone/Broken_Phone.py @@ -4,7 +4,7 @@ X, Y = map(int, input().split()) if X < Y: print("REPAIR") - elif (X > Y): + elif X > Y: print("NEW PHONE") else: - print("ANY") \ No newline at end of file + print("ANY") diff --git a/Codechef/Broken_String/Broken_String.py b/Codechef/Broken_String/Broken_String.py index 1e2c49d2..aa7f3f74 100644 --- a/Codechef/Broken_String/Broken_String.py +++ b/Codechef/Broken_String/Broken_String.py @@ -1,16 +1,16 @@ T = int(input()) while T: - T -= 1 + T -= 1 N = int(input()) S = input() l1 = [] l2 = [] - for k in range(0, N//2): + for k in range(0, N // 2): l1.append(S[k]) - for j in range(N//2, N): + for j in range(N // 2, N): l2.append(S[j]) - if (l1 == l2): + if l1 == l2: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Bscost/Bscost.py b/Codechef/Bscost/Bscost.py index bfc92637..3a8a8bee 100644 --- a/Codechef/Bscost/Bscost.py +++ b/Codechef/Bscost/Bscost.py @@ -7,7 +7,7 @@ if X < Y: l.sort() else: - l.sort(reverse=True) # Sorting by 1 + l.sort(reverse=True) # Sorting by 1 c1 = 0 c2 = 0 for i in range(len(l) - 1): @@ -16,4 +16,4 @@ elif l[i] == "1" and l[i + 1] == "0": c2 += 1 print(c1, ",", c2) - print((X * c1) + (Y * c2)) \ No newline at end of file + print((X * c1) + (Y * c2)) diff --git a/Codechef/Btry_Hlth/Btry_Hlth.py b/Codechef/Btry_Hlth/Btry_Hlth.py index bc940979..acc7e58c 100644 --- a/Codechef/Btry_Hlth/Btry_Hlth.py +++ b/Codechef/Btry_Hlth/Btry_Hlth.py @@ -5,4 +5,4 @@ if X >= 80: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Bud_Tech/Bud_Tech.py b/Codechef/Bud_Tech/Bud_Tech.py index b4e565bc..26236480 100644 --- a/Codechef/Bud_Tech/Bud_Tech.py +++ b/Codechef/Bud_Tech/Bud_Tech.py @@ -1,7 +1,7 @@ T = int(input()) while T: - T-= 1 + T -= 1 R = int(input()) R *= 1000 R /= 2 - print(int(R/5)) \ No newline at end of file + print(int(R / 5)) diff --git a/Codechef/Budget_/Budget_.py b/Codechef/Budget_/Budget_.py index f4dd5169..6ad13a8c 100644 --- a/Codechef/Budget_/Budget_.py +++ b/Codechef/Budget_/Budget_.py @@ -6,4 +6,4 @@ if expense <= X: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Bull_Bear/Bull_Bear.py b/Codechef/Bull_Bear/Bull_Bear.py index 09704632..b50e1b60 100644 --- a/Codechef/Bull_Bear/Bull_Bear.py +++ b/Codechef/Bull_Bear/Bull_Bear.py @@ -7,4 +7,4 @@ elif Y < X: print("LOSS") else: - print("NEUTRAL") \ No newline at end of file + print("NEUTRAL") diff --git a/Codechef/Bullet/Bullet.py b/Codechef/Bullet/Bullet.py index dff36887..3ec7ada8 100644 --- a/Codechef/Bullet/Bullet.py +++ b/Codechef/Bullet/Bullet.py @@ -2,8 +2,8 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - t = Y//X - if (Z > t): + t = Y // X + if Z > t: print(Z - t) else: - print("0") \ No newline at end of file + print("0") diff --git a/Codechef/Burgers/Burgers.py b/Codechef/Burgers/Burgers.py index 344ec6d8..cf50b781 100644 --- a/Codechef/Burgers/Burgers.py +++ b/Codechef/Burgers/Burgers.py @@ -2,4 +2,4 @@ while T: T -= 1 A, B = map(int, input().split()) - print(min(A, B)) \ No newline at end of file + print(min(A, B)) diff --git a/Codechef/CANDY123/CANDY123.py b/Codechef/CANDY123/CANDY123.py index c9b47cb9..32e937ff 100644 --- a/Codechef/CANDY123/CANDY123.py +++ b/Codechef/CANDY123/CANDY123.py @@ -6,11 +6,11 @@ for i in range(1, 1000): if i % 2 == 1: A = A - i - if(A < 0): + if A < 0: print("Bob") break else: B = B - i - if(B < 0): + if B < 0: print("Limak") - break \ No newline at end of file + break diff --git a/Codechef/CB_Speed/CB_Speed.py b/Codechef/CB_Speed/CB_Speed.py index e5845901..d82bf52b 100644 --- a/Codechef/CB_Speed/CB_Speed.py +++ b/Codechef/CB_Speed/CB_Speed.py @@ -1,5 +1,5 @@ X, Y = map(int, input().split()) -if (Y <= X): +if Y <= X: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/CCHOCOLATES/CCHOCOLATES.py b/Codechef/CCHOCOLATES/CCHOCOLATES.py index 9d65fee6..4d9f657d 100644 --- a/Codechef/CCHOCOLATES/CCHOCOLATES.py +++ b/Codechef/CCHOCOLATES/CCHOCOLATES.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - print(((5 * X) + (10 * Y)) // Z) \ No newline at end of file + print(((5 * X) + (10 * Y)) // Z) diff --git a/Codechef/CHEFSTEP/CHEFSTEP.py b/Codechef/CHEFSTEP/CHEFSTEP.py index 13dd0855..3868c0d6 100644 --- a/Codechef/CHEFSTEP/CHEFSTEP.py +++ b/Codechef/CHEFSTEP/CHEFSTEP.py @@ -5,7 +5,7 @@ D = list(map(int, input().split())) for i in D: if int(i) % K == 0: - print(1, end='') + print(1, end="") else: - print(0, end='') - print() \ No newline at end of file + print(0, end="") + print() diff --git a/Codechef/CHEFSTLT/CHEFSTLT.py b/Codechef/CHEFSTLT/CHEFSTLT.py index f566f1af..1bf69f6a 100644 --- a/Codechef/CHEFSTLT/CHEFSTLT.py +++ b/Codechef/CHEFSTLT/CHEFSTLT.py @@ -5,8 +5,8 @@ S2 = input() N, M = 0, 0 for j in range(len(S1)): - if (S1[j] =='?' or S2[j] =='?'): + if S1[j] == "?" or S2[j] == "?": N += 1 - elif (S1[j] != S2[j]): + elif S1[j] != S2[j]: M += 1 - print(M, (M + N)) \ No newline at end of file + print(M, (M + N)) diff --git a/Codechef/CHEFSTR1/CHEFSTR1.py b/Codechef/CHEFSTR1/CHEFSTR1.py index a4b1fe33..994dd7f5 100644 --- a/Codechef/CHEFSTR1/CHEFSTR1.py +++ b/Codechef/CHEFSTR1/CHEFSTR1.py @@ -2,8 +2,8 @@ while T: T -= 1 N = int(input()) - A = list(map(int,input().split())) + A = list(map(int, input().split())) c = 0 for i in range(N - 1): - c += (abs(A[i + 1] - A[i]) - 1) - print(c) \ No newline at end of file + c += abs(A[i + 1] - A[i]) - 1 + print(c) diff --git a/Codechef/CHEGLOVE/CHEGLOVE.py b/Codechef/CHEGLOVE/CHEGLOVE.py index 9f5b7c29..2fb0ae16 100644 --- a/Codechef/CHEGLOVE/CHEGLOVE.py +++ b/Codechef/CHEGLOVE/CHEGLOVE.py @@ -10,11 +10,11 @@ f = False if L[i] > G[N - i - 1]: b = False - if (f and b): + if f and b: print("both") - elif (f): + elif f: print("front") - elif (b): + elif b: print("back") else: - print("none") \ No newline at end of file + print("none") diff --git a/Codechef/CHFRICH/CHFRICH.py b/Codechef/CHFRICH/CHFRICH.py index 01350e28..4651a704 100644 --- a/Codechef/CHFRICH/CHFRICH.py +++ b/Codechef/CHFRICH/CHFRICH.py @@ -1,4 +1,4 @@ -T = int(input()) +T = int(input()) while T: T -= 1 A, B, X = map(int, input().split()) @@ -6,6 +6,6 @@ while True: A += X c += 1 - if (A == B): + if A == B: print(c) - break \ No newline at end of file + break diff --git a/Codechef/CHFSPL/CHFSPL.py b/Codechef/CHFSPL/CHFSPL.py index aefde283..64eadc56 100644 --- a/Codechef/CHFSPL/CHFSPL.py +++ b/Codechef/CHFSPL/CHFSPL.py @@ -2,4 +2,4 @@ while T: T -= 1 A, B, C = map(int, input().split()) - print(max((A + B), (B + C), (A + C))) \ No newline at end of file + print(max((A + B), (B + C), (A + C))) diff --git a/Codechef/CHF_Heist/CHF_Heist.py b/Codechef/CHF_Heist/CHF_Heist.py index 57427987..3f546741 100644 --- a/Codechef/CHF_Heist/CHF_Heist.py +++ b/Codechef/CHF_Heist/CHF_Heist.py @@ -2,5 +2,7 @@ while T: T -= 1 D, d, P, Q = map(int, input().split()) - res = ((d * (D // d) * (2 * P + ((D // d) - 1) * Q)) // 2) + ((D % d) * (P + (D // d) * Q)) - print(res) \ No newline at end of file + res = ((d * (D // d) * (2 * P + ((D // d) - 1) * Q)) // 2) + ( + (D % d) * (P + (D // d) * Q) + ) + print(res) diff --git a/Codechef/COLOR8TEST/COLOR8TEST.py b/Codechef/COLOR8TEST/COLOR8TEST.py index 565eaa5f..fc1a4ba5 100644 --- a/Codechef/COLOR8TEST/COLOR8TEST.py +++ b/Codechef/COLOR8TEST/COLOR8TEST.py @@ -1,7 +1,8 @@ import math + T = int(input()) while T: T -= 1 N, X1, X2, X3, X4, X5, X6 = list(map(int, input().split())) - X = (X1 + X2 + X3 + X4 + X5 + X6 ) * math.ceil((N / 2)) - print(X) \ No newline at end of file + X = (X1 + X2 + X3 + X4 + X5 + X6) * math.ceil((N / 2)) + print(X) diff --git a/Codechef/COUNTP/COUNTP.py b/Codechef/COUNTP/COUNTP.py index 0e8184b1..0b173af0 100644 --- a/Codechef/COUNTP/COUNTP.py +++ b/Codechef/COUNTP/COUNTP.py @@ -5,9 +5,9 @@ A = list(map(int, input().split())) F, C = 0, 0 for i in A: - if(i % 2 == 1): + if i % 2 == 1: C += 1 - if(C % 2 == 1 or C == 0): - print('NO') + if C % 2 == 1 or C == 0: + print("NO") else: - print('YES') \ No newline at end of file + print("YES") diff --git a/Codechef/COVID19/COVID19.py b/Codechef/COVID19/COVID19.py index c9f70dbe..234c8645 100644 --- a/Codechef/COVID19/COVID19.py +++ b/Codechef/COVID19/COVID19.py @@ -6,4 +6,4 @@ for i in range(1, N + 1, 2): for j in range(1, M + 1, 2): c += 1 - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/CRITLIST/CRITLIST.py b/Codechef/CRITLIST/CRITLIST.py index fe361fc1..05ea0265 100644 --- a/Codechef/CRITLIST/CRITLIST.py +++ b/Codechef/CRITLIST/CRITLIST.py @@ -5,8 +5,10 @@ def solve(head): current = head.next old_val = head.val while not current.next is None: - if (old_val < current.val and current.next.val < current.val) or (old_val > current.val and current.next.val > current.val): - count += 1 + if (old_val < current.val and current.next.val < current.val) or ( + old_val > current.val and current.next.val > current.val + ): + count += 1 old_val = current.val current = current.next - return count \ No newline at end of file + return count diff --git a/Codechef/CS2023_STK/CS2023_STK.py b/Codechef/CS2023_STK/CS2023_STK.py index a7b2c5e0..6b737f46 100644 --- a/Codechef/CS2023_STK/CS2023_STK.py +++ b/Codechef/CS2023_STK/CS2023_STK.py @@ -13,17 +13,17 @@ om_count += 1 else: om_count = 0 - + if B[i] != 0: addy_count += 1 else: addy_count = 0 om_streak = max(om_count, om_streak) addy_streak = max(addy_count, addy_streak) - + if om_streak > addy_streak: print("Om") elif om_streak < addy_streak: print("Addy") else: - print("Draw") \ No newline at end of file + print("Draw") diff --git a/Codechef/CSTOCK/CSTOCK.py b/Codechef/CSTOCK/CSTOCK.py index 8390c142..695274a7 100644 --- a/Codechef/CSTOCK/CSTOCK.py +++ b/Codechef/CSTOCK/CSTOCK.py @@ -1,9 +1,9 @@ T = int(input()) while T: T -= 1 - A, B, C, D = list(map(int, input().split(' '))) + A, B, C, D = list(map(int, input().split(" "))) E = (100 + D) / 100 * A - if (E >= B and E <= C): + if E >= B and E <= C: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/C_Wire_Frame/C_Wire_Frame.py b/Codechef/C_Wire_Frame/C_Wire_Frame.py index 64aa92db..3dc76281 100644 --- a/Codechef/C_Wire_Frame/C_Wire_Frame.py +++ b/Codechef/C_Wire_Frame/C_Wire_Frame.py @@ -3,4 +3,4 @@ while T: T -= 1 N, M, X = map(int, input().split()) - print(((X * ((2 * N) + (2 * M))))) \ No newline at end of file + print(((X * ((2 * N) + (2 * M))))) diff --git a/Codechef/Cabs/Cabs.py b/Codechef/Cabs/Cabs.py index e20b5b02..d36de868 100644 --- a/Codechef/Cabs/Cabs.py +++ b/Codechef/Cabs/Cabs.py @@ -2,9 +2,9 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (X < Y): + if X < Y: print("FIRST") - elif(X > Y): + elif X > Y: print("SECOND") else: - print("ANY") \ No newline at end of file + print("ANY") diff --git a/Codechef/Caesar/Caesar.py b/Codechef/Caesar/Caesar.py index a2738a8c..161cc0fc 100644 --- a/Codechef/Caesar/Caesar.py +++ b/Codechef/Caesar/Caesar.py @@ -6,22 +6,22 @@ T = input() U = input() rotK_U = "" - if (T[0] > S[0]): + if T[0] > S[0]: cipher = ord(T[0]) - ord(S[0]) for i in range(N): if (ord(U[i]) + cipher) > 122: rotK_U += chr(((ord(U[i]) + cipher)) - 26) else: rotK_U += chr(((ord(U[i]) + cipher))) - elif (T[0] < S[0]): + elif T[0] < S[0]: cipher = ord(S[0]) - ord(T[0]) for i in range(N): if (ord(U[i]) - cipher) < 97: rotK_U += chr(((ord(U[i]) - cipher)) + 26) else: rotK_U += chr(((ord(U[i]) - cipher))) - + else: print(U) print(rotK_U) - # print(rotK_U) \ No newline at end of file + # print(rotK_U) diff --git a/Codechef/Can_Chef/Can_Chef.py b/Codechef/Can_Chef/Can_Chef.py index dd6e1f41..e0128c74 100644 --- a/Codechef/Can_Chef/Can_Chef.py +++ b/Codechef/Can_Chef/Can_Chef.py @@ -5,4 +5,4 @@ if (15 * X) >= (2 * Y): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Can_Divide/Can_Divide.py b/Codechef/Can_Divide/Can_Divide.py index 73db2ec3..9d4f0f77 100644 --- a/Codechef/Can_Divide/Can_Divide.py +++ b/Codechef/Can_Divide/Can_Divide.py @@ -5,4 +5,4 @@ if N % 3 == 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Candy_Store/Candy_Store.py b/Codechef/Candy_Store/Candy_Store.py index 1dc67a4d..b8c6b222 100644 --- a/Codechef/Candy_Store/Candy_Store.py +++ b/Codechef/Candy_Store/Candy_Store.py @@ -2,8 +2,8 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (Y <= X): + if Y <= X: print(Y) - + else: - print(X + 2 * (Y - X)) \ No newline at end of file + print(X + 2 * (Y - X)) diff --git a/Codechef/Car_Trip/Car_Trip.py b/Codechef/Car_Trip/Car_Trip.py index bb4615cc..f03d7f68 100644 --- a/Codechef/Car_Trip/Car_Trip.py +++ b/Codechef/Car_Trip/Car_Trip.py @@ -5,4 +5,4 @@ if X < 300: print("3000") else: - print(X * 10) \ No newline at end of file + print(X * 10) diff --git a/Codechef/Cclearn/Cclearn.py b/Codechef/Cclearn/Cclearn.py index c7989d26..4d5834cc 100644 --- a/Codechef/Cclearn/Cclearn.py +++ b/Codechef/Cclearn/Cclearn.py @@ -1 +1 @@ -print(2 * (int(input()))) \ No newline at end of file +print(2 * (int(input()))) diff --git a/Codechef/Cfr_Test/Cfr_Test.py b/Codechef/Cfr_Test/Cfr_Test.py index 12ca5969..12237e96 100644 --- a/Codechef/Cfr_Test/Cfr_Test.py +++ b/Codechef/Cfr_Test/Cfr_Test.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) L = list(map(int, input().split())) - print(len(set(L))) \ No newline at end of file + print(len(set(L))) diff --git a/Codechef/Cheap_Food/Cheap_Food.py b/Codechef/Cheap_Food/Cheap_Food.py index a1cc8fbb..8fbc51f9 100644 --- a/Codechef/Cheap_Food/Cheap_Food.py +++ b/Codechef/Cheap_Food/Cheap_Food.py @@ -3,4 +3,4 @@ T -= 1 X = int(input()) ten = 0.1 * X - print(int(max(ten, 100))) \ No newline at end of file + print(int(max(ten, 100))) diff --git a/Codechef/Chef_Apps/Chef_Apps.py b/Codechef/Chef_Apps/Chef_Apps.py index 653e77aa..ea5db94f 100644 --- a/Codechef/Chef_Apps/Chef_Apps.py +++ b/Codechef/Chef_Apps/Chef_Apps.py @@ -5,7 +5,7 @@ remain = S - (X + Y) if Z <= remain: print(0) - elif (S >= X + Z or S >= Y + Z): + elif S >= X + Z or S >= Y + Z: print(1) else: - print(2) \ No newline at end of file + print(2) diff --git a/Codechef/Chef_Bottle/Chef_Bottle.py b/Codechef/Chef_Bottle/Chef_Bottle.py index 13b78a0d..e5a2578d 100644 --- a/Codechef/Chef_Bottle/Chef_Bottle.py +++ b/Codechef/Chef_Bottle/Chef_Bottle.py @@ -3,11 +3,11 @@ T -= 1 N, X, K = map(int, input().split()) if X <= K: - num = K//X - if (num >= N): + num = K // X + if num >= N: print(N) else: print(num) - + else: - print(K//X) \ No newline at end of file + print(K // X) diff --git a/Codechef/Chef_On_Date/Chef_On_Date.py b/Codechef/Chef_On_Date/Chef_On_Date.py index a7b5e961..8c0c1669 100644 --- a/Codechef/Chef_On_Date/Chef_On_Date.py +++ b/Codechef/Chef_On_Date/Chef_On_Date.py @@ -1,8 +1,8 @@ T = int(input()) while T: - T-= 1 + T -= 1 X, Y = map(int, input().split()) if X >= Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Chefa/Chefa.py b/Codechef/Chefa/Chefa.py index 0c1ff22e..45d98621 100644 --- a/Codechef/Chefa/Chefa.py +++ b/Codechef/Chefa/Chefa.py @@ -6,6 +6,6 @@ L.sort(reverse=True) s = 0 for i in range(N): - if (i % 2 == 0): + if i % 2 == 0: s += L[i] - print(s) \ No newline at end of file + print(s) diff --git a/Codechef/Chefstud/Chefstud.py b/Codechef/Chefstud/Chefstud.py index 39928b99..ea1dfaf6 100644 --- a/Codechef/Chefstud/Chefstud.py +++ b/Codechef/Chefstud/Chefstud.py @@ -4,7 +4,7 @@ s = input() c = 0 for i in range(len(s) - 1): - + if s[i] == "<" and s[i + 1] == ">": c += 1 - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/Chess_Time/Chess_Time.py b/Codechef/Chess_Time/Chess_Time.py index 44077f99..bb426409 100644 --- a/Codechef/Chess_Time/Chess_Time.py +++ b/Codechef/Chess_Time/Chess_Time.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) N *= 60 - print(int(N/20)) \ No newline at end of file + print(int(N / 20)) diff --git a/Codechef/Chf_Rich/Chf_Rich.py b/Codechef/Chf_Rich/Chf_Rich.py index a61ecd21..8ee13780 100644 --- a/Codechef/Chf_Rich/Chf_Rich.py +++ b/Codechef/Chf_Rich/Chf_Rich.py @@ -2,4 +2,4 @@ while T: T -= 1 A, B, X = map(int, input().split()) - print((B - A)// X) \ No newline at end of file + print((B - A) // X) diff --git a/Codechef/Cndy/Cndy.py b/Codechef/Cndy/Cndy.py index 741cb5fb..d546bd25 100644 --- a/Codechef/Cndy/Cndy.py +++ b/Codechef/Cndy/Cndy.py @@ -19,6 +19,6 @@ break if c > 0: print("NO") - + else: print("YES") diff --git a/Codechef/Cnt_Wrd/Cnt_Word.py b/Codechef/Cnt_Wrd/Cnt_Word.py index 7aadf02e..8b2ce15d 100644 --- a/Codechef/Cnt_Wrd/Cnt_Word.py +++ b/Codechef/Cnt_Wrd/Cnt_Word.py @@ -2,4 +2,4 @@ while T: T -= 1 N, M = map(int, input().split()) - print(N * M) \ No newline at end of file + print(N * M) diff --git a/Codechef/Coconut/Coconut,.py b/Codechef/Coconut/Coconut,.py index 8e20221e..00d64329 100644 --- a/Codechef/Coconut/Coconut,.py +++ b/Codechef/Coconut/Coconut,.py @@ -2,6 +2,6 @@ while T: T -= 1 xa, xb, Xa, Xb = map(int, input().split()) - req_1 = Xa//xa - req_2 = Xb//xb - print(req_1 + req_2) \ No newline at end of file + req_1 = Xa // xa + req_2 = Xb // xb + print(req_1 + req_2) diff --git a/Codechef/Colour/Colour.py b/Codechef/Colour/Colour.py index 153591ea..4de3d3db 100644 --- a/Codechef/Colour/Colour.py +++ b/Codechef/Colour/Colour.py @@ -12,7 +12,7 @@ if Z > 0: c += 1 - + X_remain = X - 1 Y_remain = Y - 1 Z_remain = Z - 1 @@ -25,4 +25,4 @@ c += 2 elif r[1] >= 1: c += 1 - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/Complexity/Complexity.py b/Codechef/Complexity/Complexity.py index 425855c0..f0bc1b07 100644 --- a/Codechef/Complexity/Complexity.py +++ b/Codechef/Complexity/Complexity.py @@ -1,8 +1,8 @@ -T = int(input()) +T = int(input()) while T: T -= 1 X, Y = map(int, input().split()) if X > Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Covid_19/Covid_19.py b/Codechef/Covid_19/Covid_19.py index 7cf9dccc..3653af39 100644 --- a/Codechef/Covid_19/Covid_19.py +++ b/Codechef/Covid_19/Covid_19.py @@ -1,6 +1,6 @@ T = int(input()) while T: - T -= 1 + T -= 1 N = int(input()) X = list(map(int, input().split())) final_worst, final_best = 1, 1 @@ -13,4 +13,4 @@ new_X.append(c) c = 1 new_X.append(c) - print(min(new_X), max(new_X)) \ No newline at end of file + print(min(new_X), max(new_X)) diff --git a/Codechef/Cred_Coins/Cred_Coins.py b/Codechef/Cred_Coins/Cred_Coins.py index cb9beb49..b316ef98 100644 --- a/Codechef/Cred_Coins/Cred_Coins.py +++ b/Codechef/Cred_Coins/Cred_Coins.py @@ -3,4 +3,4 @@ T -= 1 X, Y = map(int, input().split()) prod = X * Y - print(prod//100) \ No newline at end of file + print(prod // 100) diff --git a/Codechef/Cred_Score/Cred_Score.py b/Codechef/Cred_Score/Cred_Score.py index 5f70ef1a..7398fb6e 100644 --- a/Codechef/Cred_Score/Cred_Score.py +++ b/Codechef/Cred_Score/Cred_Score.py @@ -2,4 +2,4 @@ if X >= 750: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Credits/Credits.py b/Codechef/Credits/Credits.py index eb728e01..0f711592 100644 --- a/Codechef/Credits/Credits.py +++ b/Codechef/Credits/Credits.py @@ -7,4 +7,4 @@ elif X < 35: print("UNDERLOAD") else: - print("NORMAL") \ No newline at end of file + print("NORMAL") diff --git a/Codechef/Creds/Creds.py b/Codechef/Creds/Creds.py index 443eebf8..b9fea41e 100644 --- a/Codechef/Creds/Creds.py +++ b/Codechef/Creds/Creds.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - print(4 * X + 2 * Y) \ No newline at end of file + print(4 * X + 2 * Y) diff --git a/Codechef/Cut_Off/Cut_Off.py b/Codechef/Cut_Off/Cut_Off.py index de5d9a78..9d5d9181 100644 --- a/Codechef/Cut_Off/Cut_Off.py +++ b/Codechef/Cut_Off/Cut_Off.py @@ -4,4 +4,4 @@ N, X = map(int, input().split()) A = list(map(int, input().split())) A.sort() - print(A[N - X] - 1) \ No newline at end of file + print(A[N - X] - 1) diff --git a/Codechef/Cut_Paper/Cut_Paper.py b/Codechef/Cut_Paper/Cut_Paper.py index 2955fb60..aab370bd 100644 --- a/Codechef/Cut_Paper/Cut_Paper.py +++ b/Codechef/Cut_Paper/Cut_Paper.py @@ -2,4 +2,4 @@ while T: T -= 1 N, K = map(int, input().split()) - print((N//K) * (N//K)) \ No newline at end of file + print((N // K) * (N // K)) diff --git a/Codechef/DIET/DIET.py b/Codechef/DIET/DIET.py index a44cb0a3..08f1feb6 100644 --- a/Codechef/DIET/DIET.py +++ b/Codechef/DIET/DIET.py @@ -13,4 +13,4 @@ if c > 0: print("NO", (i + 1)) else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/DIGSMPAR/DIGSMPAR.py b/Codechef/DIGSMPAR/DIGSMPAR.py index fe232291..99299696 100644 --- a/Codechef/DIGSMPAR/DIGSMPAR.py +++ b/Codechef/DIGSMPAR/DIGSMPAR.py @@ -9,4 +9,4 @@ if (s1 % 2 == 0 and s2 % 2 == 0) or (s1 % 2 == 1 and s2 % 2 == 1): print(N + 2) else: - print(N + 1) \ No newline at end of file + print(N + 1) diff --git a/Codechef/DIVNUMB/DIVNUMB.py b/Codechef/DIVNUMB/DIVNUMB.py index 56d8ad14..ebb3bd1f 100644 --- a/Codechef/DIVNUMB/DIVNUMB.py +++ b/Codechef/DIVNUMB/DIVNUMB.py @@ -1,11 +1,11 @@ T = int(input()) while T: T -= 1 - N, A, B, C = map(int,input().split()) + N, A, B, C = map(int, input().split()) lst = set() for i in range(1, N + 1): lst.add(i * A) lst.add(i * B) lst.add(i * C) lst = sorted(lst) - print(lst[N - 1]) \ No newline at end of file + print(lst[N - 1]) diff --git a/Codechef/DNASTORAGE/DNASTORAGE.py b/Codechef/DNASTORAGE/DNASTORAGE.py index d303fbc4..34c726f4 100644 --- a/Codechef/DNASTORAGE/DNASTORAGE.py +++ b/Codechef/DNASTORAGE/DNASTORAGE.py @@ -5,12 +5,12 @@ Z = "" H = str(input()) for j in range(0, A, 2): - if(H[j] + H[j + 1] == "00"): + if H[j] + H[j + 1] == "00": Z = Z + "A" - elif(H[j] + H[j + 1] == "01"): + elif H[j] + H[j + 1] == "01": Z = Z + "T" - elif(H[j] + H[j + 1] == "10"): + elif H[j] + H[j + 1] == "10": Z = Z + "C" else: Z = Z + "G" - print(Z) \ No newline at end of file + print(Z) diff --git a/Codechef/DR/DR.py b/Codechef/DR/DR.py index 5554d1ee..2c3f0650 100644 --- a/Codechef/DR/DR.py +++ b/Codechef/DR/DR.py @@ -1,7 +1,7 @@ T = int(input()) for i in range(T): X = int(input()) - Y = list(map(int,input().split())) + Y = list(map(int, input().split())) A = [] B = [] for j in range(0, len(Y)): @@ -9,10 +9,10 @@ A.append(Y[j]) else: B.append(Y[j]) - + for k in A: if k in B: B.remove(k) - C = str(B)[1 : -1] - D = C.replace(',', '') - print(D) \ No newline at end of file + C = str(B)[1:-1] + D = C.replace(",", "") + print(D) diff --git a/Codechef/Daily/Daily.py b/Codechef/Daily/Daily.py index bf92cc78..8ce3a199 100644 --- a/Codechef/Daily/Daily.py +++ b/Codechef/Daily/Daily.py @@ -7,8 +7,8 @@ H = input() i, j = 0, 54 for _ in range(9): - l = H[i:i+4] + H[j - 2:j] - c += math.comb(l.count('0'), X) + l = H[i : i + 4] + H[j - 2 : j] + c += math.comb(l.count("0"), X) i += 4 j -= 2 -print(c) \ No newline at end of file +print(c) diff --git a/Codechef/Detscore/Detscore.py b/Codechef/Detscore/Detscore.py index e3583423..0316127c 100644 --- a/Codechef/Detscore/Detscore.py +++ b/Codechef/Detscore/Detscore.py @@ -4,4 +4,4 @@ X, N = map(int, input().split()) X /= 10 score = int(N * X) - print(score) \ No newline at end of file + print(score) diff --git a/Codechef/Discnt/Discnt.py b/Codechef/Discnt/Discnt.py index 8dcce7b4..5e9b2426 100644 --- a/Codechef/Discnt/Discnt.py +++ b/Codechef/Discnt/Discnt.py @@ -2,4 +2,4 @@ while T: T -= 1 x = int(input()) - print(100 - x) \ No newline at end of file + print(100 - x) diff --git a/Codechef/Dist_Code/Dist_Code.py b/Codechef/Dist_Code/Dist_Code.py index b4c8ab69..bc78576d 100644 --- a/Codechef/Dist_Code/Dist_Code.py +++ b/Codechef/Dist_Code/Dist_Code.py @@ -5,12 +5,11 @@ d = {} c = 0 for i in range(len(S) - 1): - x = S[i:i + 2] + x = S[i : i + 2] d[x] = 0 for i in range(len(S) - 1): - x = S[i:i + 2] + x = S[i : i + 2] if d[x] == 0: d[x] += 1 c += 1 print(c) - \ No newline at end of file diff --git a/Codechef/Distinct_Col/Distinct_Col.py b/Codechef/Distinct_Col/Distinct_Col.py index 44a0c4cb..f34ca9f7 100644 --- a/Codechef/Distinct_Col/Distinct_Col.py +++ b/Codechef/Distinct_Col/Distinct_Col.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) A = list(map(int, input().split())) - print(max(A)) \ No newline at end of file + print(max(A)) diff --git a/Codechef/Divide_Make_EQ/Divide_Make_EQ.py b/Codechef/Divide_Make_EQ/Divide_Make_EQ.py index 90ed7703..541be3f9 100644 --- a/Codechef/Divide_Make_EQ/Divide_Make_EQ.py +++ b/Codechef/Divide_Make_EQ/Divide_Make_EQ.py @@ -1,4 +1,5 @@ from math import gcd + T = int(input()) while T: T -= 1 @@ -7,4 +8,4 @@ if gcd(*A) != min(A): print(len(A)) else: - print(len(A) - A.count(min(A))) \ No newline at end of file + print(len(A) - A.count(min(A))) diff --git a/Codechef/Dominant/Dominant.py b/Codechef/Dominant/Dominant.py index e773d2c3..4dd64092 100644 --- a/Codechef/Dominant/Dominant.py +++ b/Codechef/Dominant/Dominant.py @@ -2,16 +2,15 @@ while T: T -= 1 Na, Nb, Nc = map(int, input().split()) - + if Na > (Nb + Nc): print("YES") - + elif Nb > (Na + Nc): print("YES") - + elif Nc > (Na + Nb): print("YES") - else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Dominant_2/Dominant_2.py b/Codechef/Dominant_2/Dominant_2.py index 76335da0..8656d88f 100644 --- a/Codechef/Dominant_2/Dominant_2.py +++ b/Codechef/Dominant_2/Dominant_2.py @@ -1,4 +1,5 @@ from collections import Counter + T = int(input()) while T: T -= 1 @@ -8,7 +9,7 @@ L1 = [i for i in L.values()] # print(L1) m = max(L1) - if (L1.count(m) == 1): + if L1.count(m) == 1: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Doreward/Doreward.py b/Codechef/Doreward/Doreward.py index 313aff3e..c13ea99d 100644 --- a/Codechef/Doreward/Doreward.py +++ b/Codechef/Doreward/Doreward.py @@ -2,9 +2,9 @@ while T: T -= 1 X = int(input()) - if (X <= 3): + if X <= 3: print("BRONZE") - elif (X > 3 and X <= 6): + elif X > 3 and X <= 6: print("SILVER") else: - print("GOLD") \ No newline at end of file + print("GOLD") diff --git a/Codechef/ELECTIONS/ELECTIONS.py b/Codechef/ELECTIONS/ELECTIONS.py index 0adbc90d..5ae24455 100644 --- a/Codechef/ELECTIONS/ELECTIONS.py +++ b/Codechef/ELECTIONS/ELECTIONS.py @@ -2,11 +2,11 @@ while T: T -= 1 Xa, Xb, Xc = map(int, input().split()) - if (Xa > 50 and (Xb <= 50 and Xc <= 50)): + if Xa > 50 and (Xb <= 50 and Xc <= 50): print("A") - elif (Xb > 50 and (Xa <= 50 and Xc <= 50)): + elif Xb > 50 and (Xa <= 50 and Xc <= 50): print("B") - elif (Xc > 50 and (Xa <= 50 and Xb <= 50)): + elif Xc > 50 and (Xa <= 50 and Xb <= 50): print("C") else: - print("NOTA") \ No newline at end of file + print("NOTA") diff --git a/Codechef/EMPR/EMPR.py b/Codechef/EMPR/EMPR.py index 8b362a5e..1fc21d9c 100644 --- a/Codechef/EMPR/EMPR.py +++ b/Codechef/EMPR/EMPR.py @@ -3,7 +3,7 @@ T -= 1 P, X, Y, Z = map(int, input().split()) if Z == 1: - P = P+ ( (P * Y) / 100) + P = P + ((P * Y) / 100) else: P = P - ((P * X / 100)) - print('{0:.10f}'.format(P)) \ No newline at end of file + print("{0:.10f}".format(P)) diff --git a/Codechef/ENCMSG/ENCMSG.py b/Codechef/ENCMSG/ENCMSG.py index 8b01c0f0..bbf572b3 100644 --- a/Codechef/ENCMSG/ENCMSG.py +++ b/Codechef/ENCMSG/ENCMSG.py @@ -3,11 +3,11 @@ T -= 1 N = int(input()) S = input() - FS = '' + FS = "" i = 0 S = list(S) while i < N - 1: - j = '' + j = "" j += S[i] S[i] = S[i + 1] S[i + 1] = j diff --git a/Codechef/EQUALIZEAB/EQUALIZEAB.py b/Codechef/EQUALIZEAB/EQUALIZEAB.py index 4e672fec..ccbb9af4 100644 --- a/Codechef/EQUALIZEAB/EQUALIZEAB.py +++ b/Codechef/EQUALIZEAB/EQUALIZEAB.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, X = map(int, input().split()) - if(((A - B) / 2) % X == 0): + if ((A - B) / 2) % X == 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/EUREKA/EUREKA.py b/Codechef/EUREKA/EUREKA.py index 931e7eda..64565695 100644 --- a/Codechef/EUREKA/EUREKA.py +++ b/Codechef/EUREKA/EUREKA.py @@ -1,8 +1,9 @@ def calc(n): - return round(((0.143 * n)**n)) + return round(((0.143 * n) ** n)) + T = int(input()) while T: T -= 1 N = int(input()) - print(calc(N)) \ No newline at end of file + print(calc(N)) diff --git a/Codechef/EVENTUAL/EVENTUAL.py b/Codechef/EVENTUAL/EVENTUAL.py index a8ff7013..12fcc8a5 100644 --- a/Codechef/EVENTUAL/EVENTUAL.py +++ b/Codechef/EVENTUAL/EVENTUAL.py @@ -11,7 +11,7 @@ for i in S: if i in d.keys(): d[i] += 1 - + else: d[i] = 1 diff --git a/Codechef/EXAMTIME/EXAMTIME.py b/Codechef/EXAMTIME/EXAMTIME.py index 4b3ae400..296b327a 100644 --- a/Codechef/EXAMTIME/EXAMTIME.py +++ b/Codechef/EXAMTIME/EXAMTIME.py @@ -5,17 +5,17 @@ SDSA, STOC, SDM = map(int, input().split()) D_tot = DDSA + DTOC + DDM S_tot = SDSA + STOC + SDM - if (D_tot > S_tot): + if D_tot > S_tot: print("Dragon") - elif (S_tot > D_tot): - print("Sloth") - elif (D_tot == S_tot and DDSA > SDSA): + elif S_tot > D_tot: + print("Sloth") + elif D_tot == S_tot and DDSA > SDSA: print("Dragon") - elif (D_tot == S_tot and SDSA > DDSA): + elif D_tot == S_tot and SDSA > DDSA: print("Sloth") - elif (D_tot == S_tot and DTOC > STOC): + elif D_tot == S_tot and DTOC > STOC: print("Dragon") - elif (D_tot == S_tot and STOC > DTOC): + elif D_tot == S_tot and STOC > DTOC: print("Sloth") - elif (D_tot == S_tot and SDSA == DDSA): - print("TIE") \ No newline at end of file + elif D_tot == S_tot and SDSA == DDSA: + print("TIE") diff --git a/Codechef/EXPRESSION_3/EXPRESSION_3.py b/Codechef/EXPRESSION_3/EXPRESSION_3.py index 0d88603f..af69b3a6 100644 --- a/Codechef/EXPRESSION_3/EXPRESSION_3.py +++ b/Codechef/EXPRESSION_3/EXPRESSION_3.py @@ -1,10 +1,10 @@ T = int(input()) while T: T -= 1 - L = list(map(int,input().split())) + L = list(map(int, input().split())) max_L = max(L) L.remove(max_L) if max_L == sum(L): print("Yes") else: - print("No") \ No newline at end of file + print("No") diff --git a/Codechef/EZSPEAK/EZSPEAK.py b/Codechef/EZSPEAK/EZSPEAK.py index 177214b4..9ea2e2c8 100644 --- a/Codechef/EZSPEAK/EZSPEAK.py +++ b/Codechef/EZSPEAK/EZSPEAK.py @@ -6,13 +6,13 @@ c = 0 ans = False for i in str(S): - if i != 'a' and i != 'e' and i != 'i' and i != 'o' and i != 'u': + if i != "a" and i != "e" and i != "i" and i != "o" and i != "u": c += 1 else: c = 0 - if (c >= 4): + if c >= 4: ans = True - if (ans == False): + if ans == False: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Email_Rem/Email_Rem.py b/Codechef/Email_Rem/Email_Rem.py index 6417edf0..5a0f60a2 100644 --- a/Codechef/Email_Rem/Email_Rem.py +++ b/Codechef/Email_Rem/Email_Rem.py @@ -1,2 +1,2 @@ N, U = map(int, input().split()) -print(N - U) \ No newline at end of file +print(N - U) diff --git a/Codechef/End_Sorted/End_Sorted.py b/Codechef/End_Sorted/End_Sorted.py index cdc2bbe3..c35317cc 100644 --- a/Codechef/End_Sorted/End_Sorted.py +++ b/Codechef/End_Sorted/End_Sorted.py @@ -9,4 +9,4 @@ if index_1 < index_n: print(index_1 + N - 1 - index_n) else: - print(index_1 + N - 2 - index_n) \ No newline at end of file + print(index_1 + N - 2 - index_n) diff --git a/Codechef/Enspace/Enspace.py b/Codechef/Enspace/Enspace.py index 2fa1a018..c8a0f8bc 100644 --- a/Codechef/Enspace/Enspace.py +++ b/Codechef/Enspace/Enspace.py @@ -3,7 +3,7 @@ T -= 1 N, X, Y = map(int, input().split()) tot = X + 2 * Y - if (tot > N): + if tot > N: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/Equal_Ele/Equal_Ele.py b/Codechef/Equal_Ele/Equal_Ele.py index 55f72cdd..e417eb38 100644 --- a/Codechef/Equal_Ele/Equal_Ele.py +++ b/Codechef/Equal_Ele/Equal_Ele.py @@ -1,8 +1,9 @@ from collections import Counter + T = int(input()) while T: T -= 1 N = int(input()) A = list(map(int, input().split())) D = Counter(A) - print(N - max(D.values())) \ No newline at end of file + print(N - max(D.values())) diff --git a/Codechef/Equality/Equality.py b/Codechef/Equality/Equality.py index 34280b14..f443340f 100644 --- a/Codechef/Equality/Equality.py +++ b/Codechef/Equality/Equality.py @@ -5,5 +5,5 @@ A = list(map(int, input().split())) S = sum(A) // (N - 1) for i in A: - print(S - i, end = " ") - print() \ No newline at end of file + print(S - i, end=" ") + print() diff --git a/Codechef/Equinox/Equinox.py b/Codechef/Equinox/Equinox.py index 405cc9b9..bc1752a9 100644 --- a/Codechef/Equinox/Equinox.py +++ b/Codechef/Equinox/Equinox.py @@ -11,9 +11,9 @@ c1 += A else: c2 += B - if (c1 > c2): + if c1 > c2: print("SARTHAK") - elif (c1 < c2): + elif c1 < c2: print("ANURADHA") else: - print("DRAW") \ No newline at end of file + print("DRAW") diff --git a/Codechef/Existence/Existence.py b/Codechef/Existence/Existence.py index e1e6bddf..cc774f45 100644 --- a/Codechef/Existence/Existence.py +++ b/Codechef/Existence/Existence.py @@ -4,7 +4,7 @@ X, Y = map(int, input().split()) LHS = X**4 + (4 * Y**2) RHS = 4 * (X**2 * Y) - if (LHS == RHS): + if LHS == RHS: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Expenses/Expenses.py b/Codechef/Expenses/Expenses.py index 17ba0995..5236efed 100644 --- a/Codechef/Expenses/Expenses.py +++ b/Codechef/Expenses/Expenses.py @@ -4,9 +4,9 @@ N, X = map(int, input().split()) salary = 2**X if N == 1: - print(int(salary - 0.5*salary)) + print(int(salary - 0.5 * salary)) else: - salary -= 0.5*salary + salary -= 0.5 * salary for i in range(N - 1): - salary -= 0.5*salary - print(int(salary)) \ No newline at end of file + salary -= 0.5 * salary + print(int(salary)) diff --git a/Codechef/Expert/Expert.py b/Codechef/Expert/Expert.py index b70c9a72..188368ba 100644 --- a/Codechef/Expert/Expert.py +++ b/Codechef/Expert/Expert.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (Y >= 0.5 * X): + if Y >= 0.5 * X: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Expiry/Expiry.py b/Codechef/Expiry/Expiry.py index e698f285..9e469eca 100644 --- a/Codechef/Expiry/Expiry.py +++ b/Codechef/Expiry/Expiry.py @@ -2,7 +2,7 @@ while T: T -= 1 N, M, K = map(int, input().split()) - if (M * K >= N): + if M * K >= N: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/F1_Rule/F1_Rule.py b/Codechef/F1_Rule/F1_Rule.py index 2bffb453..37791364 100644 --- a/Codechef/F1_Rule/F1_Rule.py +++ b/Codechef/F1_Rule/F1_Rule.py @@ -3,7 +3,7 @@ T -= 1 X, Y = map(int, input().split()) time = 1.07 * X - if (Y > time): + if Y > time: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/FARAWAY/FARAWAY.py b/Codechef/FARAWAY/FARAWAY.py index ac758e92..243d194a 100644 --- a/Codechef/FARAWAY/FARAWAY.py +++ b/Codechef/FARAWAY/FARAWAY.py @@ -11,4 +11,4 @@ maximum = abs(A[i] - M) summation = summation + maximum maximum = 0 - print(summation) \ No newline at end of file + print(summation) diff --git a/Codechef/FIT/FIT.py b/Codechef/FIT/FIT.py index 5c9ed5ee..ffcb8db3 100644 --- a/Codechef/FIT/FIT.py +++ b/Codechef/FIT/FIT.py @@ -1,6 +1,6 @@ T = int(input()) while T: - T -= 1 + T -= 1 X = int(input()) - distance = 10 * X - print(distance) \ No newline at end of file + distance = 10 * X + print(distance) diff --git a/Codechef/FNDINT/FNDINT.py b/Codechef/FNDINT/FNDINT.py index 1f33353f..572c255a 100644 --- a/Codechef/FNDINT/FNDINT.py +++ b/Codechef/FNDINT/FNDINT.py @@ -1,14 +1,14 @@ T = int(input()) -while(T): +while T: T -= 1 X = int(input()) X = X + 1 X = str(X) s = len(set(X)) l = len(X) - while(s != l): + while s != l: X = int(X) + 1 X = str(X) s = len(set(X)) l = len(X) - print(int(X)) \ No newline at end of file + print(int(X)) diff --git a/Codechef/Fair_Pass/Fair_Pass.py b/Codechef/Fair_Pass/Fair_Pass.py index f06e07d8..cb9fc84e 100644 --- a/Codechef/Fair_Pass/Fair_Pass.py +++ b/Codechef/Fair_Pass/Fair_Pass.py @@ -6,4 +6,4 @@ if K >= req: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Fever/Fever.py b/Codechef/Fever/Fever.py index 3be44e4e..a41bfb1d 100644 --- a/Codechef/Fever/Fever.py +++ b/Codechef/Fever/Fever.py @@ -5,4 +5,4 @@ if X > 98: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Find_Shoes/Find_Shoes.py b/Codechef/Find_Shoes/Find_Shoes.py index 7d8abc77..4672eed8 100644 --- a/Codechef/Find_Shoes/Find_Shoes.py +++ b/Codechef/Find_Shoes/Find_Shoes.py @@ -5,4 +5,4 @@ if N < M: print(N) else: - print((N - M) + N) \ No newline at end of file + print((N - M) + N) diff --git a/Codechef/Fine/Fine.py b/Codechef/Fine/Fine.py index f9d0636a..52f7f549 100644 --- a/Codechef/Fine/Fine.py +++ b/Codechef/Fine/Fine.py @@ -2,9 +2,9 @@ while T: T -= 1 X = int(input()) - if (X > 70 and X <= 100): + if X > 70 and X <= 100: print("500") - elif (X >= 100): + elif X >= 100: print("2000") else: - print("0") \ No newline at end of file + print("0") diff --git a/Codechef/Floors/Floors.py b/Codechef/Floors/Floors.py index 9f9d02cf..4680fe5f 100644 --- a/Codechef/Floors/Floors.py +++ b/Codechef/Floors/Floors.py @@ -1,8 +1,9 @@ import math + T = int(input()) while T: T -= 1 X, Y = map(int, input().split()) x = math.ceil(X / 10) y = math.ceil(Y / 10) - print(abs(x - y)) \ No newline at end of file + print(abs(x - y)) diff --git a/Codechef/Food_Plan/Food_Plan.py b/Codechef/Food_Plan/Food_Plan.py index 82f306f9..802fc6e0 100644 --- a/Codechef/Food_Plan/Food_Plan.py +++ b/Codechef/Food_Plan/Food_Plan.py @@ -2,12 +2,11 @@ while T: T -= 1 N, M = map(int, input().split()) - N -= 0.1*N + N -= 0.1 * N least = min(M, N) if M == N: - print("EITHER") + print("EITHER") elif least == N: print("ONLINE") elif least == M: print("DINING") - \ No newline at end of file diff --git a/Codechef/Foot_Cup/Foot_Cup.py b/Codechef/Foot_Cup/Foot_Cup.py index f0bd1add..5eb36f87 100644 --- a/Codechef/Foot_Cup/Foot_Cup.py +++ b/Codechef/Foot_Cup/Foot_Cup.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if ((X == Y) and (X != 0 and Y != 0)): + if (X == Y) and (X != 0 and Y != 0): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Four_Tickets/Four_Tickets.py b/Codechef/Four_Tickets/Four_Tickets.py index ffba66aa..b207c994 100644 --- a/Codechef/Four_Tickets/Four_Tickets.py +++ b/Codechef/Four_Tickets/Four_Tickets.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (4 * X <= 1000): + if 4 * X <= 1000: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/GRPASSN/GRPASSN.py b/Codechef/GRPASSN/GRPASSN.py index 7ed0e578..abedaa64 100644 --- a/Codechef/GRPASSN/GRPASSN.py +++ b/Codechef/GRPASSN/GRPASSN.py @@ -6,7 +6,7 @@ groups = set(P) for g in groups: if P.count(g) % g != 0: - print('NO') + print("NO") break else: - print('YES') \ No newline at end of file + print("YES") diff --git a/Codechef/Gd_Turn/Gd_Turn.py b/Codechef/Gd_Turn/Gd_Turn.py index 258a3124..ae3f01c4 100644 --- a/Codechef/Gd_Turn/Gd_Turn.py +++ b/Codechef/Gd_Turn/Gd_Turn.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (X + Y > 6): + if X + Y > 6: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Guess/Guess.py b/Codechef/Guess/Guess.py index f36be9b7..ff8ac0e3 100644 --- a/Codechef/Guess/Guess.py +++ b/Codechef/Guess/Guess.py @@ -19,4 +19,4 @@ if l % 2 == 0: print("1/2") else: - print(str(l // 2), "/", str(l), sep='') + print(str(l // 2), "/", str(l), sep="") diff --git a/Codechef/HAPPYSTR/HAPPYSTR.py b/Codechef/HAPPYSTR/HAPPYSTR.py index 0ec24af2..862b9872 100644 --- a/Codechef/HAPPYSTR/HAPPYSTR.py +++ b/Codechef/HAPPYSTR/HAPPYSTR.py @@ -6,9 +6,9 @@ length = len(S) c = 0 for i in range(length - 2): - if S[i] in vowels and S[i+1] in vowels and S[i+2] in vowels: + if S[i] in vowels and S[i + 1] in vowels and S[i + 2] in vowels: c = 1 - if (c == 1): + if c == 1: print("Happy") else: - print("Sad") \ No newline at end of file + print("Sad") diff --git a/Codechef/HEADBOB/HEADBOB.py b/Codechef/HEADBOB/HEADBOB.py index 8b4afb58..ceee37b8 100644 --- a/Codechef/HEADBOB/HEADBOB.py +++ b/Codechef/HEADBOB/HEADBOB.py @@ -11,9 +11,9 @@ c2 += 1 elif S[i] == "I": c3 += 1 - if (c2 == N): + if c2 == N: print("NOT SURE") - elif (c1 > 0): + elif c1 > 0: print("NOT INDIAN") - elif (c3 > 0): - print("INDIAN") \ No newline at end of file + elif c3 > 0: + print("INDIAN") diff --git a/Codechef/High_Score/High_Score.py b/Codechef/High_Score/High_Score.py index bfc51aa0..7f9d7e56 100644 --- a/Codechef/High_Score/High_Score.py +++ b/Codechef/High_Score/High_Score.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) Na, Nb, Nc, Nd = map(int, input().split()) - print(max(Na, Nb, Nc, Nd)) \ No newline at end of file + print(max(Na, Nb, Nc, Nd)) diff --git a/Codechef/Hills/Hills.py b/Codechef/Hills/Hills.py index d97f602f..4bdadaf3 100644 --- a/Codechef/Hills/Hills.py +++ b/Codechef/Hills/Hills.py @@ -7,22 +7,20 @@ for i in range(N - 1): l1, l2 = H[i], H[i + 1] # print(l1, " ", l2) - if (((l2 - l1) <= U) and ((l2 - l1) > 0)): + if ((l2 - l1) <= U) and ((l2 - l1) > 0): c += 1 - elif ((l1 - l2) > D and c1 == 0): + elif (l1 - l2) > D and c1 == 0: c1 += 1 c += 1 # print(c1) - - elif ((((l1 - l2) <= D) and c1 <= 1) and ((l1 - l2) > 0)): + + elif (((l1 - l2) <= D) and c1 <= 1) and ((l1 - l2) > 0): c += 1 - elif ((l1 - l2) == 0): + elif (l1 - l2) == 0: c += 1 else: break - - + print(c) - \ No newline at end of file diff --git a/Codechef/Hire_Test/Hire_Test.py b/Codechef/Hire_Test/Hire_Test.py index 9faa239e..9fff9928 100644 --- a/Codechef/Hire_Test/Hire_Test.py +++ b/Codechef/Hire_Test/Hire_Test.py @@ -6,10 +6,10 @@ inp = [] for i in range(N): inp.append(input()) - s = '' + s = "" for i in inp: - if (i.count("F") >= X or (i.count("F") >= (X - 1) and i.count("P") >= Y)): - s += '1' + if i.count("F") >= X or (i.count("F") >= (X - 1) and i.count("P") >= Y): + s += "1" else: - s += '0' - print(s) \ No newline at end of file + s += "0" + print(s) diff --git a/Codechef/Hoops/Hoops.py b/Codechef/Hoops/Hoops.py index 5b31981a..238119e7 100644 --- a/Codechef/Hoops/Hoops.py +++ b/Codechef/Hoops/Hoops.py @@ -2,4 +2,4 @@ while T: T -= 1 N = int(input()) - print((N + 1) // 2) \ No newline at end of file + print((N + 1) // 2) diff --git a/Codechef/Horses/Horses.py b/Codechef/Horses/Horses.py index 102ec7f6..e7d355e9 100644 --- a/Codechef/Horses/Horses.py +++ b/Codechef/Horses/Horses.py @@ -9,4 +9,4 @@ for i in range(1, N): minimum.append(S[i] - S[i - 1]) - print(min(minimum)) \ No newline at end of file + print(min(minimum)) diff --git a/Codechef/Hot_Cold/Hot_Cold.py b/Codechef/Hot_Cold/Hot_Cold.py index e81f4d35..e5fdf0fc 100644 --- a/Codechef/Hot_Cold/Hot_Cold.py +++ b/Codechef/Hot_Cold/Hot_Cold.py @@ -5,4 +5,4 @@ if C > 20: print("HOT") else: - print("COLD") \ No newline at end of file + print("COLD") diff --git a/Codechef/Hotel/Hotel.py b/Codechef/Hotel/Hotel.py index a9c10b4f..de63fede 100644 --- a/Codechef/Hotel/Hotel.py +++ b/Codechef/Hotel/Hotel.py @@ -17,5 +17,5 @@ current -= 1 if current > maximum: maximum = current - - print(maximum) \ No newline at end of file + + print(maximum) diff --git a/Codechef/How_Many/How_Many.py b/Codechef/How_Many/How_Many.py index 98870b56..e9073e63 100644 --- a/Codechef/How_Many/How_Many.py +++ b/Codechef/How_Many/How_Many.py @@ -8,4 +8,4 @@ elif size == 3: print("3") else: - print("More than 3 digits") \ No newline at end of file + print("More than 3 digits") diff --git a/Codechef/IIT/IIT.py b/Codechef/IIT/IIT.py index d42b7a2c..9138a3ea 100644 --- a/Codechef/IIT/IIT.py +++ b/Codechef/IIT/IIT.py @@ -6,6 +6,6 @@ for i in range(B): b1 = int(input()) if b1 in A1: - print('Found') + print("Found") else: - print('Not Found') \ No newline at end of file + print("Not Found") diff --git a/Codechef/IMDB/IMDB.py b/Codechef/IMDB/IMDB.py index 46bdda9f..2c9f4755 100644 --- a/Codechef/IMDB/IMDB.py +++ b/Codechef/IMDB/IMDB.py @@ -7,4 +7,4 @@ L = list(map(int, input().split())) if L[0] <= X: G.append(L[1]) - print(max(G)) \ No newline at end of file + print(max(G)) diff --git a/Codechef/INCDECS/INCDECS.py b/Codechef/INCDECS/INCDECS.py index 2c78a379..aac9ae34 100644 --- a/Codechef/INCDECS/INCDECS.py +++ b/Codechef/INCDECS/INCDECS.py @@ -9,7 +9,7 @@ S = [] B = reversed(A) for i in B: - P = bisect_left(D ,i) + P = bisect_left(D, i) if P == len(D): D.append(i) else: @@ -24,4 +24,4 @@ else: D[P] = i R = max(R, len(D) + S.pop() - 1) - print(R) \ No newline at end of file + print(R) diff --git a/Codechef/INSDEDLL/INSDEDLL.py b/Codechef/INSDEDLL/INSDEDLL.py index 2de9c52d..09fbb31b 100644 --- a/Codechef/INSDEDLL/INSDEDLL.py +++ b/Codechef/INSDEDLL/INSDEDLL.py @@ -4,6 +4,7 @@ def __init__(self, data): self.next = None self.prev = None + def insertNode(head, position, value): new_node = Node(value) if position == 1: @@ -28,6 +29,7 @@ def insertNode(head, position, value): return head + def deleteNode(head, position): if not head: return None @@ -52,5 +54,3 @@ def deleteNode(head, position): current.next.prev = prev_node return head - - \ No newline at end of file diff --git a/Codechef/INTR_Dsgn/INTR_Dsgn.py b/Codechef/INTR_Dsgn/INTR_Dsgn.py index 0a75e20b..0c75578a 100644 --- a/Codechef/INTR_Dsgn/INTR_Dsgn.py +++ b/Codechef/INTR_Dsgn/INTR_Dsgn.py @@ -2,4 +2,4 @@ while T: T -= 1 X1, Y1, X2, Y2 = map(int, input().split()) - print(min((X1 + Y1), (X2 + Y2))) \ No newline at end of file + print(min((X1 + Y1), (X2 + Y2))) diff --git a/Codechef/Indivisible/Indivisible.py b/Codechef/Indivisible/Indivisible.py index 9c8d8759..e19900d1 100644 --- a/Codechef/Indivisible/Indivisible.py +++ b/Codechef/Indivisible/Indivisible.py @@ -3,6 +3,6 @@ T -= 1 A, B, C = map(int, input().split()) for i in range(1, 100): - if (A % i != 0 and B % i != 0 and C % i != 0): + if A % i != 0 and B % i != 0 and C % i != 0: print(i) - break \ No newline at end of file + break diff --git a/Codechef/Instagram/Instagram.py b/Codechef/Instagram/Instagram.py index 60978b84..8865aa8b 100644 --- a/Codechef/Instagram/Instagram.py +++ b/Codechef/Instagram/Instagram.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (X > (10 * Y)): + if X > (10 * Y): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Insurance/Insurance.py b/Codechef/Insurance/Insurance.py index dbb058e2..8df85e14 100644 --- a/Codechef/Insurance/Insurance.py +++ b/Codechef/Insurance/Insurance.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (X < Y): + if X < Y: print(X) else: - print(Y) \ No newline at end of file + print(Y) diff --git a/Codechef/Intest/Intest.py b/Codechef/Intest/Intest.py index eba075b5..d794392f 100644 --- a/Codechef/Intest/Intest.py +++ b/Codechef/Intest/Intest.py @@ -4,4 +4,4 @@ a = int(input()) if a % K == 0: c += 1 -print(c) \ No newline at end of file +print(c) diff --git a/Codechef/Investment/Investment.py b/Codechef/Investment/Investment.py index 26531988..49b5075d 100644 --- a/Codechef/Investment/Investment.py +++ b/Codechef/Investment/Investment.py @@ -5,4 +5,4 @@ if X >= 2 * Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/JOHNY/JOHNY.py b/Codechef/JOHNY/JOHNY.py index b3aba66d..b79f145c 100644 --- a/Codechef/JOHNY/JOHNY.py +++ b/Codechef/JOHNY/JOHNY.py @@ -1,4 +1,4 @@ -T = int(input()) +T = int(input()) while T: T -= 1 N = int(input()) @@ -6,4 +6,4 @@ P = int(input()) temp = K[P - 1] K.sort() - print(K.index(temp) + 1) \ No newline at end of file + print(K.index(temp) + 1) diff --git a/Codechef/Jenga/Jenga.py b/Codechef/Jenga/Jenga.py index 756cb766..d307df1c 100644 --- a/Codechef/Jenga/Jenga.py +++ b/Codechef/Jenga/Jenga.py @@ -2,7 +2,7 @@ while T: T -= 1 N, X = map(int, input().split()) - if (X % N == 0): + if X % N == 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Jerry_Chase/Jerry_Chase.py b/Codechef/Jerry_Chase/Jerry_Chase.py index 934fe929..e1d0e144 100644 --- a/Codechef/Jerry_Chase/Jerry_Chase.py +++ b/Codechef/Jerry_Chase/Jerry_Chase.py @@ -5,4 +5,4 @@ if X < Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/KGRPREV/KGRPREV.py b/Codechef/KGRPREV/KGRPREV.py index 1806bf21..5ae5ea7d 100644 --- a/Codechef/KGRPREV/KGRPREV.py +++ b/Codechef/KGRPREV/KGRPREV.py @@ -7,4 +7,4 @@ for i in range(0, N, M): temp = arr[i : i + M] res += temp[::-1] - print(*res) \ No newline at end of file + print(*res) diff --git a/Codechef/KITCHEN_COST/KITCHEN_COST.py b/Codechef/KITCHEN_COST/KITCHEN_COST.py index b5546894..a61aabf3 100644 --- a/Codechef/KITCHEN_COST/KITCHEN_COST.py +++ b/Codechef/KITCHEN_COST/KITCHEN_COST.py @@ -6,6 +6,6 @@ B = list(map(int, input().split())) c = 0 for i in range(N): - if(A[i] >= X): + if A[i] >= X: c += B[i] - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/KNGATK/KNGATK.py b/Codechef/KNGATK/KNGATK.py index 61f7298f..df727216 100644 --- a/Codechef/KNGATK/KNGATK.py +++ b/Codechef/KNGATK/KNGATK.py @@ -4,4 +4,4 @@ N = int(input()) A = [int(i) for i in input().split()] A.sort() - print(A[1]) \ No newline at end of file + print(A[1]) diff --git a/Codechef/Kngtor/Kngtor.py b/Codechef/Kngtor/Kngtor.py index 85950e90..3d42d529 100644 --- a/Codechef/Kngtor/Kngtor.py +++ b/Codechef/Kngtor/Kngtor.py @@ -2,4 +2,4 @@ while T: T -= 1 N, M = map(int, input().split()) - print((N*5) + (M * 7)) \ No newline at end of file + print((N * 5) + (M * 7)) diff --git a/Codechef/LAPTOPREC/LAPTOPREC.py b/Codechef/LAPTOPREC/LAPTOPREC.py index b0f0c8ba..c8e8eb44 100644 --- a/Codechef/LAPTOPREC/LAPTOPREC.py +++ b/Codechef/LAPTOPREC/LAPTOPREC.py @@ -1,8 +1,9 @@ from collections import Counter + for _ in range(int(input())): N = int(input()) A = Counter(input().split()).most_common(2) - if (len(A) == 2): + if len(A) == 2: print(A[0][0] if A[0][1] > A[1][1] else "CONFUSED") else: - print(A[0][0]) \ No newline at end of file + print(A[0][0]) diff --git a/Codechef/LARGESECOND/LARGESECOND.py b/Codechef/LARGESECOND/LARGESECOND.py index cc7ead6d..fce69766 100644 --- a/Codechef/LARGESECOND/LARGESECOND.py +++ b/Codechef/LARGESECOND/LARGESECOND.py @@ -9,4 +9,4 @@ new_A.append(i) new_A = list(map(int, new_A)) new_A.sort(reverse=True) - print(new_A[0] + new_A[1]) \ No newline at end of file + print(new_A[0] + new_A[1]) diff --git a/Codechef/LINKLP/LINKLP.py b/Codechef/LINKLP/LINKLP.py index 5812931a..a2e3083a 100644 --- a/Codechef/LINKLP/LINKLP.py +++ b/Codechef/LINKLP/LINKLP.py @@ -1,22 +1,23 @@ def solve(head): - #Return -1 if no loop exists else return the size of the loop - s=head - f=s - c=0 - if(s!=None): - while(s!=None and f!=None and s.next!=None and f.next!=None): - s=s.next - f=f.next.next - if(f==s): - c+=1 + # Return -1 if no loop exists else return the size of the loop + s = head + f = s + c = 0 + if s != None: + while s != None and f != None and s.next != None and f.next != None: + s = s.next + f = f.next.next + if f == s: + c += 1 + break + s = s.next + c1 = 1 + if c != 0: + while s.next != None: + s = s.next + c1 += 1 + if s == f: break - s=s.next - c1=1 - if(c!=0): - while(s.next!=None): - s=s.next - c1+=1 - if(s==f):break return c1 - if(c==0): - return -1 \ No newline at end of file + if c == 0: + return -1 diff --git a/Codechef/LLMID/LLMID.py b/Codechef/LLMID/LLMID.py index 9b6228bd..4c5bdbb4 100644 --- a/Codechef/LLMID/LLMID.py +++ b/Codechef/LLMID/LLMID.py @@ -3,10 +3,10 @@ def getMiddleElement(head): current = head while current: current = current.next - count += 1 + count += 1 count = count // 2 current = head while count > 0: current = current.next - count -= 1 - return current.data \ No newline at end of file + count -= 1 + return current.data diff --git a/Codechef/LUCNUM/LUCNUM.py b/Codechef/LUCNUM/LUCNUM.py index a5024c54..fe182a77 100644 --- a/Codechef/LUCNUM/LUCNUM.py +++ b/Codechef/LUCNUM/LUCNUM.py @@ -2,8 +2,8 @@ while T: T -= 1 N = int(input()) - count = 0 + count = 0 while N % 2 == 0: - N = N//2 - count += 1 - print(1 - (count % 2)) \ No newline at end of file + N = N // 2 + count += 1 + print(1 - (count % 2)) diff --git a/Codechef/L_Time/L_Time.py b/Codechef/L_Time/L_Time.py index d872bae0..4f1927f1 100644 --- a/Codechef/L_Time/L_Time.py +++ b/Codechef/L_Time/L_Time.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X >= 1 and X <= 4): + if X >= 1 and X <= 4: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Laddu/Laddu.py b/Codechef/Laddu/Laddu.py index 36e68e53..032a8c81 100644 --- a/Codechef/Laddu/Laddu.py +++ b/Codechef/Laddu/Laddu.py @@ -4,26 +4,26 @@ activities = list(map(str, input().split())) points = 0 for i in range(int(activities[0])): - all_inputs= list(input().split()) - - if ("WON" in all_inputs[0]): - if (int(all_inputs[1]) <= 20): + all_inputs = list(input().split()) + + if "WON" in all_inputs[0]: + if int(all_inputs[1]) <= 20: points += 300 + (20 - int(all_inputs[1])) else: points += 300 - - if ("TOP" in all_inputs[0]): + + if "TOP" in all_inputs[0]: points += 300 if "BUG" in all_inputs[0]: - if (int(all_inputs[1]) >= 50 and int(all_inputs[1]) <= 1000): + if int(all_inputs[1]) >= 50 and int(all_inputs[1]) <= 1000: points += int(all_inputs[1]) if "HOSTED" in all_inputs[0]: points += 50 - if (activities[1] == "INDIAN"): + if activities[1] == "INDIAN": print(points) - print(points//200) + print(points // 200) else: - print(points//400) \ No newline at end of file + print(points // 400) diff --git a/Codechef/League/League.py b/Codechef/League/League.py index 0f6ee4a9..8e3fba9a 100644 --- a/Codechef/League/League.py +++ b/Codechef/League/League.py @@ -3,6 +3,6 @@ T -= 1 N = int(input()) if N % 2 == 0: - print(int((N/2) * 3)) + print(int((N / 2) * 3)) else: - print(int(((N - 1)/2) * 3)) \ No newline at end of file + print(int(((N - 1) / 2) * 3)) diff --git a/Codechef/Learn_SQL/Learn_SQL.py b/Codechef/Learn_SQL/Learn_SQL.py index ba613e26..f3737a22 100644 --- a/Codechef/Learn_SQL/Learn_SQL.py +++ b/Codechef/Learn_SQL/Learn_SQL.py @@ -1,2 +1,2 @@ R, C, E = map(int, input().split()) -print((R * C) + (E * C)) \ No newline at end of file +print((R * C) + (E * C)) diff --git a/Codechef/Loop/Loop.py b/Codechef/Loop/Loop.py index e51415a3..46abe1f8 100644 --- a/Codechef/Loop/Loop.py +++ b/Codechef/Loop/Loop.py @@ -4,4 +4,4 @@ A, B, M = map(int, input().split()) t1 = abs(A - B) t2 = abs(M - t1) - print(min(t1, t2)) \ No newline at end of file + print(min(t1, t2)) diff --git a/Codechef/Ludo/Ludo.py b/Codechef/Ludo/Ludo.py index 4b973350..fb8244d1 100644 --- a/Codechef/Ludo/Ludo.py +++ b/Codechef/Ludo/Ludo.py @@ -5,4 +5,4 @@ if X != 6: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/MAGICHF/MAGICHF.py b/Codechef/MAGICHF/MAGICHF.py index 94125551..816293d7 100644 --- a/Codechef/MAGICHF/MAGICHF.py +++ b/Codechef/MAGICHF/MAGICHF.py @@ -9,4 +9,4 @@ new_x = B elif new_x == B: new_x = A - print(new_x) \ No newline at end of file + print(new_x) diff --git a/Codechef/MAKEMONEY/MAKEMONEY.py b/Codechef/MAKEMONEY/MAKEMONEY.py index d963fb12..f73c2bc0 100644 --- a/Codechef/MAKEMONEY/MAKEMONEY.py +++ b/Codechef/MAKEMONEY/MAKEMONEY.py @@ -8,4 +8,4 @@ if A[i] < X and (X - A[i] > C): A[i] = X c += 1 - print(sum(A) - (c * C)) \ No newline at end of file + print(sum(A) - (c * C)) diff --git a/Codechef/MASKPOL/MASKPOL.py b/Codechef/MASKPOL/MASKPOL.py index e2787e88..37e73bf0 100644 --- a/Codechef/MASKPOL/MASKPOL.py +++ b/Codechef/MASKPOL/MASKPOL.py @@ -3,4 +3,4 @@ T -= 1 N, A = map(int, input().split()) uninf = N - A - print(min(A, uninf)) \ No newline at end of file + print(min(A, uninf)) diff --git a/Codechef/MONSTER1/MONSTER1.py b/Codechef/MONSTER1/MONSTER1.py index 502a7f0c..7194ed0d 100644 --- a/Codechef/MONSTER1/MONSTER1.py +++ b/Codechef/MONSTER1/MONSTER1.py @@ -2,7 +2,7 @@ while T: T -= 1 H, X, Y = map(int, input().split()) - if (Y >= X): + if Y >= X: print(0) else: - print(1) \ No newline at end of file + print(1) diff --git a/Codechef/MSNSADM1/MSNSADM1.py b/Codechef/MSNSADM1/MSNSADM1.py index 6877f5b1..beb7fbb9 100644 --- a/Codechef/MSNSADM1/MSNSADM1.py +++ b/Codechef/MSNSADM1/MSNSADM1.py @@ -7,6 +7,6 @@ sum = [] * N for i in range(N): sum.append((20 * A[i]) - (10 * B[i])) - if (sum[i] < 0): + if sum[i] < 0: sum[i] = 0 - print(max(sum)) \ No newline at end of file + print(max(sum)) diff --git a/Codechef/MVR/MVR.py b/Codechef/MVR/MVR.py index 5fcd6e9e..562b56ef 100644 --- a/Codechef/MVR/MVR.py +++ b/Codechef/MVR/MVR.py @@ -1,7 +1,7 @@ A, B, X, Y = map(int, input().split()) -if (((2 * A) + B) > ((2 * X) + Y)): +if ((2 * A) + B) > ((2 * X) + Y): print("MESSI") -elif (((2 * A) + B) < ((2 * X) + Y)): +elif ((2 * A) + B) < ((2 * X) + Y): print("RONALDO") else: - print("EQUAL") \ No newline at end of file + print("EQUAL") diff --git a/Codechef/MXVENSUB/MXVENSUB.py b/Codechef/MXVENSUB/MXVENSUB.py index 07710331..ca1f9258 100644 --- a/Codechef/MXVENSUB/MXVENSUB.py +++ b/Codechef/MXVENSUB/MXVENSUB.py @@ -6,4 +6,4 @@ if cont_subs % 2 == 0: print(N) else: - print(N - 1) \ No newline at end of file + print(N - 1) diff --git a/Codechef/Manapts/Manapts.py b/Codechef/Manapts/Manapts.py index 46006085..a4d08209 100644 --- a/Codechef/Manapts/Manapts.py +++ b/Codechef/Manapts/Manapts.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print(Y // X) # Prints the output by taking int value of Y/X \ No newline at end of file + print(Y // X) # Prints the output by taking int value of Y/X diff --git a/Codechef/Mangoes/Mangoes.py b/Codechef/Mangoes/Mangoes.py index 7e92f5a6..0c9c7666 100644 --- a/Codechef/Mangoes/Mangoes.py +++ b/Codechef/Mangoes/Mangoes.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - print((Z - Y) // X) \ No newline at end of file + print((Z - Y) // X) diff --git a/Codechef/Many_Sums/Many_Sums.py b/Codechef/Many_Sums/Many_Sums.py index 7d262d27..b3dbb4d8 100644 --- a/Codechef/Many_Sums/Many_Sums.py +++ b/Codechef/Many_Sums/Many_Sums.py @@ -1,7 +1,7 @@ T = int(input()) while T: T -= 1 - L, R = map(int, input().split()) + L, R = map(int, input().split()) L = 2 * L R = 2 * R - print(R - L + 1) \ No newline at end of file + print(R - L + 1) diff --git a/Codechef/Markstw/Markstw.py b/Codechef/Markstw/Markstw.py index 297f8534..ba83d66a 100644 --- a/Codechef/Markstw/Markstw.py +++ b/Codechef/Markstw/Markstw.py @@ -1,5 +1,5 @@ X, Y = map(int, input().split()) -if (X >= 2 * Y): +if X >= 2 * Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Matches/Matches.py b/Codechef/Matches/Matches.py index 944ca6fd..dd76e423 100644 --- a/Codechef/Matches/Matches.py +++ b/Codechef/Matches/Matches.py @@ -2,9 +2,9 @@ while T: T -= 1 A, B = map(int, input().split()) - d = {0 : 6, 1 : 2, 2 : 5, 3 : 5, 4 : 4, 5 : 5, 6 : 6, 7 : 3, 8 : 7, 9 : 6} + d = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} total = A + B c = 0 for i in str(total): c += d[int(i)] - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/MaxDiff/MaxDiff.py b/Codechef/MaxDiff/MaxDiff.py index b9ab8ce4..66c10db6 100644 --- a/Codechef/MaxDiff/MaxDiff.py +++ b/Codechef/MaxDiff/MaxDiff.py @@ -3,6 +3,6 @@ T -= 1 N, S = map(int, input().split()) t1 = min(N, S) - t2 = (S - t1) - max_diff = (t1 - t2) - print(max_diff) \ No newline at end of file + t2 = S - t1 + max_diff = t1 - t2 + print(max_diff) diff --git a/Codechef/Max_Comp/Max_Comp.py b/Codechef/Max_Comp/Max_Comp.py index 172cc86a..b66a1b17 100644 --- a/Codechef/Max_Comp/Max_Comp.py +++ b/Codechef/Max_Comp/Max_Comp.py @@ -9,5 +9,7 @@ V[S][E] = max(V[S][E], C) for end in range(49): for begin in range(end): - maximum_list[end] = max(maximum_list[end], V[begin][end] + maximum_list[begin]) - print(maximum_list[48]) \ No newline at end of file + maximum_list[end] = max( + maximum_list[end], V[begin][end] + maximum_list[begin] + ) + print(maximum_list[48]) diff --git a/Codechef/Max_Diff/Max_Diff.py b/Codechef/Max_Diff/Max_Diff.py index e3f10639..2354bd38 100644 --- a/Codechef/Max_Diff/Max_Diff.py +++ b/Codechef/Max_Diff/Max_Diff.py @@ -5,5 +5,5 @@ Q = min(N - K, K) W = list(map(int, input().split())) W.sort() - sum_kid, sum_Chef = sum(W[ : Q]), sum(W[Q : N]) - print(sum_Chef - sum_kid) \ No newline at end of file + sum_kid, sum_Chef = sum(W[:Q]), sum(W[Q:N]) + print(sum_Chef - sum_kid) diff --git a/Codechef/Max_Diff_Min/Max_Diff_Min.py b/Codechef/Max_Diff_Min/Max_Diff_Min.py index 3a90965e..22980dcd 100644 --- a/Codechef/Max_Diff_Min/Max_Diff_Min.py +++ b/Codechef/Max_Diff_Min/Max_Diff_Min.py @@ -3,4 +3,3 @@ T -= 1 A, B, C = map(int, input().split()) print(max(A, B, C) - min(A, B, C)) - \ No newline at end of file diff --git a/Codechef/Max_Taste/Max_Taste.py b/Codechef/Max_Taste/Max_Taste.py index bcfb70fe..4ea2ee91 100644 --- a/Codechef/Max_Taste/Max_Taste.py +++ b/Codechef/Max_Taste/Max_Taste.py @@ -2,4 +2,4 @@ while T: T -= 1 a, b, c, d = map(int, input().split()) - print(max(a, b) + max(c, d)) \ No newline at end of file + print(max(a, b) + max(c, d)) diff --git a/Codechef/Maximum_Subs/Maximum_Subs.py b/Codechef/Maximum_Subs/Maximum_Subs.py index c6f30ef5..72dd19da 100644 --- a/Codechef/Maximum_Subs/Maximum_Subs.py +++ b/Codechef/Maximum_Subs/Maximum_Subs.py @@ -2,4 +2,4 @@ while T: T -= 1 N = int(input()) - print(int((N * 60)/30)) \ No newline at end of file + print(int((N * 60) / 30)) diff --git a/Codechef/Mg_Crnk/Mg_Crnk.py b/Codechef/Mg_Crnk/Mg_Crnk.py index 3be8ebcb..0b86c718 100644 --- a/Codechef/Mg_Crnk/Mg_Crnk.py +++ b/Codechef/Mg_Crnk/Mg_Crnk.py @@ -10,4 +10,4 @@ for i in range(1, n): for j in range(1, n): temp[i][j] += max(temp[i - 1][j], temp[i][j - 1]) - print(temp[n - 1][n - 1] / (2 * n - 3) if temp[n - 1][n - 1] >= 0 else "Bad Judges") \ No newline at end of file + print(temp[n - 1][n - 1] / (2 * n - 3) if temp[n - 1][n - 1] >= 0 else "Bad Judges") diff --git a/Codechef/Mileage/Mileage.py b/Codechef/Mileage/Mileage.py index d93231a6..dad2b52a 100644 --- a/Codechef/Mileage/Mileage.py +++ b/Codechef/Mileage/Mileage.py @@ -2,11 +2,11 @@ while T: T -= 1 N, X, Y, A, B = map(int, input().split()) - petrol = (N/A)* X - diesel = (N/B)* Y + petrol = (N / A) * X + diesel = (N / B) * Y if petrol > diesel: print("DIESEL") elif petrol < diesel: print("PETROL") else: - print("ANY") \ No newline at end of file + print("ANY") diff --git a/Codechef/Min_Cars/Min_Cars.py b/Codechef/Min_Cars/Min_Cars.py index f0e71b8b..033cf854 100644 --- a/Codechef/Min_Cars/Min_Cars.py +++ b/Codechef/Min_Cars/Min_Cars.py @@ -1,6 +1,7 @@ import math + T = int(input()) while T: T -= 1 X = int(input()) - print(math.ceil(X/4)) \ No newline at end of file + print(math.ceil(X / 4)) diff --git a/Codechef/Min_Eat/Min_Eat.py b/Codechef/Min_Eat/Min_Eat.py index f1f68d10..e8c1ff67 100644 --- a/Codechef/Min_Eat/Min_Eat.py +++ b/Codechef/Min_Eat/Min_Eat.py @@ -1,28 +1,31 @@ from math import ceil + + def eat_complete(bananas, k, h): elapsed = 0 - for pile in bananas: - elapsed += ceil(pile/k) + for pile in bananas: + elapsed += ceil(pile / k) if elapsed > h: - return False + return False return True + T = int(input()) while T: T -= 1 N, H = map(int, input().split()) - A = list(map(int, input().split())) + A = list(map(int, input().split())) i = 1 j = max(A) min_k = j while i <= j: - m = (i+j) // 2 + m = (i + j) // 2 if eat_complete(A, m, H): if m < min_k: min_k = m - j = m-1 + j = m - 1 else: break else: - i = m+1 - print(min_k) \ No newline at end of file + i = m + 1 + print(min_k) diff --git a/Codechef/Min_Height/Min_Height.py b/Codechef/Min_Height/Min_Height.py index 6c48244e..669985db 100644 --- a/Codechef/Min_Height/Min_Height.py +++ b/Codechef/Min_Height/Min_Height.py @@ -5,4 +5,4 @@ if X >= H: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Min_Pizza/Min_Pizza.py b/Codechef/Min_Pizza/Min_Pizza.py index e052e301..ff153fd7 100644 --- a/Codechef/Min_Pizza/Min_Pizza.py +++ b/Codechef/Min_Pizza/Min_Pizza.py @@ -1,7 +1,8 @@ import math + T = int(input()) while T: T -= 1 N, X = map(int, input().split()) slices = N * X - print(math.ceil(slices/4)) \ No newline at end of file + print(math.ceil(slices / 4)) diff --git a/Codechef/Missp/Missp.py b/Codechef/Missp/Missp.py index 65ecd41e..a2dcba75 100644 --- a/Codechef/Missp/Missp.py +++ b/Codechef/Missp/Missp.py @@ -9,4 +9,4 @@ for i in L: if L.count(i) % 2 == 1: print(i) - break \ No newline at end of file + break diff --git a/Codechef/Monopoly/Monopoly.py b/Codechef/Monopoly/Monopoly.py index b7a48f35..5030d9c7 100644 --- a/Codechef/Monopoly/Monopoly.py +++ b/Codechef/Monopoly/Monopoly.py @@ -2,11 +2,11 @@ while T: T -= 1 R1, R2, R3 = map(int, input().split()) - if (R1 > (R2 + R3)): + if R1 > (R2 + R3): print("YES") - elif (R2 > (R1 + R3)): + elif R2 > (R1 + R3): print("YES") - elif (R3 > (R1 + R2)): + elif R3 > (R1 + R2): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Monsoon/Monsoon.py b/Codechef/Monsoon/Monsoon.py index afd4fde8..2b707052 100644 --- a/Codechef/Monsoon/Monsoon.py +++ b/Codechef/Monsoon/Monsoon.py @@ -1,6 +1,6 @@ T = int(input()) while T: - T -= 1 + T -= 1 N, M, H = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) @@ -15,5 +15,5 @@ if X[i] < (Y[i] * H): c = c + X[i] else: - c = c+( Y[i] * H) - print(c) \ No newline at end of file + c = c + (Y[i] * H) + print(c) diff --git a/Codechef/My_Serve/My_Serve.py b/Codechef/My_Serve/My_Serve.py index 049561f0..7c042c28 100644 --- a/Codechef/My_Serve/My_Serve.py +++ b/Codechef/My_Serve/My_Serve.py @@ -3,7 +3,7 @@ T -= 1 P, Q = map(int, input().split()) points = P + Q - if (points % 4 == 0 or points % 4 == 1): + if points % 4 == 0 or points % 4 == 1: print("ALICE") else: - print("BOB") \ No newline at end of file + print("BOB") diff --git a/Codechef/NEARESTEXIT/NEARESTEXIT.py b/Codechef/NEARESTEXIT/NEARESTEXIT.py index 5351333b..cd131e28 100644 --- a/Codechef/NEARESTEXIT/NEARESTEXIT.py +++ b/Codechef/NEARESTEXIT/NEARESTEXIT.py @@ -5,4 +5,4 @@ if X <= 50: print("LEFT") else: - print("RIGHT") \ No newline at end of file + print("RIGHT") diff --git a/Codechef/NEW_PIECE/NEW_PIECE.py b/Codechef/NEW_PIECE/NEW_PIECE.py index 0f75795e..e8449d55 100644 --- a/Codechef/NEW_PIECE/NEW_PIECE.py +++ b/Codechef/NEW_PIECE/NEW_PIECE.py @@ -2,9 +2,9 @@ while T: T -= 1 A, B, P, Q = map(int, input().split()) - if (A == P and B == Q): + if A == P and B == Q: print(0) - elif ((A + B) % 2 == (P + Q) % 2): + elif (A + B) % 2 == (P + Q) % 2: print(2) else: - print(1) \ No newline at end of file + print(1) diff --git a/Codechef/NFS/NFS.py b/Codechef/NFS/NFS.py index fb342ae6..438ced6a 100644 --- a/Codechef/NFS/NFS.py +++ b/Codechef/NFS/NFS.py @@ -2,8 +2,8 @@ while T: T -= 1 U, V, A, S = map(int, input().split()) - measure_v = (U ** 2) - (2 * A * S) - if measure_v > (V ** 2): + measure_v = (U**2) - (2 * A * S) + if measure_v > (V**2): print("No") else: - print("Yes") \ No newline at end of file + print("Yes") diff --git a/Codechef/NODEAD/NODEAD.py b/Codechef/NODEAD/NODEAD.py index 05dc0b15..0b1e8a45 100644 --- a/Codechef/NODEAD/NODEAD.py +++ b/Codechef/NODEAD/NODEAD.py @@ -6,4 +6,4 @@ arr.pop(arr2[1] - 1) else: arr.insert(arr2[1] - 1, arr2[2]) - print(*arr) \ No newline at end of file + print(*arr) diff --git a/Codechef/NUMREC/NUMREC.py b/Codechef/NUMREC/NUMREC.py index 4881f9b6..85205646 100644 --- a/Codechef/NUMREC/NUMREC.py +++ b/Codechef/NUMREC/NUMREC.py @@ -1,5 +1,5 @@ T = int(input()) while T: T -= 1 - N, M = map(int,input().split()) - print((M * (M + 1) * N * (N + 1)) // 4 - (N * M)) \ No newline at end of file + N, M = map(int, input().split()) + print((M * (M + 1) * N * (N + 1)) // 4 - (N * M)) diff --git a/Codechef/Nearest_Court/Nearest_Court.py b/Codechef/Nearest_Court/Nearest_Court.py index 9acf8e71..ebee3ca6 100644 --- a/Codechef/Nearest_Court/Nearest_Court.py +++ b/Codechef/Nearest_Court/Nearest_Court.py @@ -2,5 +2,5 @@ while T: T -= 1 X, Y = map(int, input().split()) - middle = (X + Y)//2 - print(max(abs(middle - X), abs(middle - Y))) \ No newline at end of file + middle = (X + Y) // 2 + print(max(abs(middle - X), abs(middle - Y))) diff --git a/Codechef/Netflix/Netflix.py b/Codechef/Netflix/Netflix.py index d9005edf..410e7157 100644 --- a/Codechef/Netflix/Netflix.py +++ b/Codechef/Netflix/Netflix.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, C, X = map(int, input().split()) - if ((A + B) >= X or(A + C) >= X or(B + C) >= X): + if (A + B) >= X or (A + C) >= X or (B + C) >= X: print("YES") else: print("NO") diff --git a/Codechef/Nibble/Nibble.py b/Codechef/Nibble/Nibble.py index b83f782b..8fbc783b 100644 --- a/Codechef/Nibble/Nibble.py +++ b/Codechef/Nibble/Nibble.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X % 4 == 0): + if X % 4 == 0: print("Good") else: - print("Not Good") \ No newline at end of file + print("Not Good") diff --git a/Codechef/Notebook/Notebook.py b/Codechef/Notebook/Notebook.py index ca48e349..925db16d 100644 --- a/Codechef/Notebook/Notebook.py +++ b/Codechef/Notebook/Notebook.py @@ -2,4 +2,4 @@ while T: T -= 1 N = int(input()) - print(int((N * 1000)/100)) \ No newline at end of file + print(int((N * 1000) / 100)) diff --git a/Codechef/ODDPAIRS/ODDPAIRS.py b/Codechef/ODDPAIRS/ODDPAIRS.py index 5a2d3cdc..3176cde2 100644 --- a/Codechef/ODDPAIRS/ODDPAIRS.py +++ b/Codechef/ODDPAIRS/ODDPAIRS.py @@ -2,4 +2,4 @@ while T: T -= 1 N = int(input()) - print((N*N)//2) \ No newline at end of file + print((N * N) // 2) diff --git a/Codechef/Odd_Sum_Pair/Odd_Sum_Pair.py b/Codechef/Odd_Sum_Pair/Odd_Sum_Pair.py index efdb82f8..40d163e9 100644 --- a/Codechef/Odd_Sum_Pair/Odd_Sum_Pair.py +++ b/Codechef/Odd_Sum_Pair/Odd_Sum_Pair.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, C = map(int, input().split()) - if (((A + B) % 2 == 1) or ((A + C) % 2 == 1) or ((B + C) % 2 == 1)): + if ((A + B) % 2 == 1) or ((A + C) % 2 == 1) or ((B + C) % 2 == 1): print("YES") else: print("NO") diff --git a/Codechef/Office/Office.py b/Codechef/Office/Office.py index 62326870..f31c211a 100644 --- a/Codechef/Office/Office.py +++ b/Codechef/Office/Office.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print((X * 4) + Y) \ No newline at end of file + print((X * 4) + Y) diff --git a/Codechef/One_More/One_More.py b/Codechef/One_More/One_More.py index b6ad338b..03510ead 100644 --- a/Codechef/One_More/One_More.py +++ b/Codechef/One_More/One_More.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X - 24 > 0): + if X - 24 > 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Oneful_Pairs/Oneful_Pairs.py b/Codechef/Oneful_Pairs/Oneful_Pairs.py index 2029cdc7..590ded6c 100644 --- a/Codechef/Oneful_Pairs/Oneful_Pairs.py +++ b/Codechef/Oneful_Pairs/Oneful_Pairs.py @@ -1,5 +1,5 @@ A, B = map(int, input().split()) -if ((A + B) + (A * B) == 111): +if (A + B) + (A * B) == 111: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PIXDAM/PIXDAM.py b/Codechef/PIXDAM/PIXDAM.py index f5ef987f..d740d55f 100644 --- a/Codechef/PIXDAM/PIXDAM.py +++ b/Codechef/PIXDAM/PIXDAM.py @@ -2,7 +2,7 @@ while T: T -= 1 H, W, X, Y, K = list(map(int, input().split())) - if (((H - Y) * (H -Y )) + ((W - X) * (W - X))) ** 0.5 < K: + if (((H - Y) * (H - Y)) + ((W - X) * (W - X))) ** 0.5 < K: print(1) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/PIZZA_BURGER/PIZZA_BURGER.py b/Codechef/PIZZA_BURGER/PIZZA_BURGER.py index 53d284ae..93def605 100644 --- a/Codechef/PIZZA_BURGER/PIZZA_BURGER.py +++ b/Codechef/PIZZA_BURGER/PIZZA_BURGER.py @@ -2,9 +2,9 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - if (X >= Y): + if X >= Y: print("PIZZA") - elif (X >= Z and Y > Z): + elif X >= Z and Y > Z: print("BURGER") else: - print("NOTHING") \ No newline at end of file + print("NOTHING") diff --git a/Codechef/PLAYSTR/PLAYSTR.py b/Codechef/PLAYSTR/PLAYSTR.py index f861fcd3..a6849c68 100644 --- a/Codechef/PLAYSTR/PLAYSTR.py +++ b/Codechef/PLAYSTR/PLAYSTR.py @@ -4,7 +4,7 @@ N = int(input()) S = list(input()) R = list(input()) - if ((S.count('1') == R.count('1')) and (S.count('0') == R.count('0'))): + if (S.count("1") == R.count("1")) and (S.count("0") == R.count("0")): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PMD7/PMD7.py b/Codechef/PMD7/PMD7.py index 6629033d..26842779 100644 --- a/Codechef/PMD7/PMD7.py +++ b/Codechef/PMD7/PMD7.py @@ -5,9 +5,9 @@ numNew = "" for i in str(X): d = int(i) - numNew += str(d ** M % 10) + numNew += str(d**M % 10) revNum = numNew[::-1] if int(revNum) % 7 == 0: print("Yes") else: - print("No") \ No newline at end of file + print("No") diff --git a/Codechef/POOK/POOK.py b/Codechef/POOK/POOK.py index 2241ae45..16718173 100644 --- a/Codechef/POOK/POOK.py +++ b/Codechef/POOK/POOK.py @@ -1,10 +1,10 @@ def pookQueens(N): - L = [ [0] ] * N + L = [[0]] * N # print(L) return _ + for _ in range(int(input())): N = int(input()) print(pookQueens(N)) # logic here - diff --git a/Codechef/PREP08/PREP08.py b/Codechef/PREP08/PREP08.py index 4c57f2a9..6eff037a 100644 --- a/Codechef/PREP08/PREP08.py +++ b/Codechef/PREP08/PREP08.py @@ -13,6 +13,7 @@ def is_painting_possible(walls, painters, time_per_unit, max_time): total_time = wall * time_per_unit return painters_needed <= painters + def minimum_painting_time(walls, painters, time_per_unit): low, high = max(walls) * time_per_unit, sum(walls) * time_per_unit result = -1 @@ -27,6 +28,7 @@ def minimum_painting_time(walls, painters, time_per_unit): low = mid + 1 return result + T = int(input()) for _ in range(T): N, A, B = map(int, input().split()) @@ -34,4 +36,4 @@ def minimum_painting_time(walls, painters, time_per_unit): # Find the minimum time required to paint N walls result = minimum_painting_time(walls, A, B) - print(result) \ No newline at end of file + print(result) diff --git a/Codechef/PREP11/PREP11.py b/Codechef/PREP11/PREP11.py index 49b2710e..e1440d25 100644 --- a/Codechef/PREP11/PREP11.py +++ b/Codechef/PREP11/PREP11.py @@ -13,6 +13,7 @@ def is_allocation_possible(books, students, max_pages): pages_allocated = pages return students_needed <= students + def allocate_books(books, students): low, high = max(books), sum(books) result = -1 @@ -27,6 +28,7 @@ def allocate_books(books, students): low = mid + 1 return result + T = int(input()) for _ in range(T): N, A = map(int, input().split()) @@ -34,4 +36,4 @@ def allocate_books(books, students): # Find the minimum value for the maximum sum of pages result = allocate_books(books, A) - print(result) \ No newline at end of file + print(result) diff --git a/Codechef/PREP38/PREP38.py b/Codechef/PREP38/PREP38.py index 70ae7588..eb563c2d 100644 --- a/Codechef/PREP38/PREP38.py +++ b/Codechef/PREP38/PREP38.py @@ -14,6 +14,7 @@ def find_starting_position(arr, x): right = mid - 1 return start_pos + def find_ending_position(arr, x): left, right = 0, len(arr) - 1 end_pos = -1 @@ -30,6 +31,7 @@ def find_ending_position(arr, x): right = mid - 1 return end_pos + def process_queries(N, Q, arr, queries): updated_arr = list(arr) @@ -48,9 +50,10 @@ def process_queries(N, Q, arr, queries): else: print(start_pos + 1, end_pos + 1) + T = int(input()) for _ in range(T): N, Q = map(int, input().split()) arr = list(map(int, input().split())) queries = [list(map(int, input().split())) for _ in range(Q)] - process_queries(N, Q, arr, queries) \ No newline at end of file + process_queries(N, Q, arr, queries) diff --git a/Codechef/PRIME1/PRIME1.py b/Codechef/PRIME1/PRIME1.py index e7566783..a57ee89d 100644 --- a/Codechef/PRIME1/PRIME1.py +++ b/Codechef/PRIME1/PRIME1.py @@ -5,13 +5,14 @@ def prime(n): return True elif n % 2 == 0 or n % 3 == 0: return False - for i in range(5, int(n ** 0.5) + 1, 6): + for i in range(5, int(n**0.5) + 1, 6): if n % i == 0 or n % (i + 2) == 0: return False return True + for _ in range(int(input())): N1, N2 = list(map(int, input().split())) for i in range(N1, N2 + 1): if prime(i): - print(i) \ No newline at end of file + print(i) diff --git a/Codechef/PROGLANG/PROGLANG.py b/Codechef/PROGLANG/PROGLANG.py index e28d0e4c..e4e60afa 100644 --- a/Codechef/PROGLANG/PROGLANG.py +++ b/Codechef/PROGLANG/PROGLANG.py @@ -1,6 +1,6 @@ T = int(input()) while T: - T -= 1 + T -= 1 A, B, A1, B1, A2, B2 = map(int, input().split()) l1 = [A1, B1] l2 = [A2, B2] @@ -10,4 +10,4 @@ elif A in l2 and B in l2: print(2) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/PRTSCH/PRTSCH.py b/Codechef/PRTSCH/PRTSCH.py index 3b570018..d1fb8426 100644 --- a/Codechef/PRTSCH/PRTSCH.py +++ b/Codechef/PRTSCH/PRTSCH.py @@ -5,8 +5,8 @@ A = set(list(map(int, input().split()))) B = list(map(int, input().split())) for i in range(M): - if(B[i] in A): - print("Yes", end = " ") + if B[i] in A: + print("Yes", end=" ") else: - print("No", end = " ") - print() \ No newline at end of file + print("No", end=" ") + print() diff --git a/Codechef/PSEUDOSORT/PSEUDOSORT.py b/Codechef/PSEUDOSORT/PSEUDOSORT.py index 1bb29fe4..29354ccb 100644 --- a/Codechef/PSEUDOSORT/PSEUDOSORT.py +++ b/Codechef/PSEUDOSORT/PSEUDOSORT.py @@ -4,10 +4,10 @@ N = int(input()) A = list(map(int, input().split())) for i in range(N - 1): - if(A[i + 1] < A[i]): + if A[i + 1] < A[i]: A[i + 1], A[i] = A[i], A[i + 1] break - if (sorted(A) == A): + if sorted(A) == A: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PYCC44/PYCC44.py b/Codechef/PYCC44/PYCC44.py index 152ac6aa..aa23788d 100644 --- a/Codechef/PYCC44/PYCC44.py +++ b/Codechef/PYCC44/PYCC44.py @@ -1,9 +1,9 @@ N = int(input()) for i in range(N): S, X, Y, Z = [int(x) for x in input().split()] - if(X + Y + Z <= S): + if X + Y + Z <= S: print(0) - elif(Z + min(X, Y) > S): + elif Z + min(X, Y) > S: print(2) else: - print(1) \ No newline at end of file + print(1) diff --git a/Codechef/PYCC47/PYCC47.py b/Codechef/PYCC47/PYCC47.py index d876f2d7..9f2ac764 100644 --- a/Codechef/PYCC47/PYCC47.py +++ b/Codechef/PYCC47/PYCC47.py @@ -3,5 +3,5 @@ T -= 1 X, Y = map(int, input().split()) ans1 = 500 - 2 * X + 1000 - 4 * (X + Y) - ans2 = 500 - 2 *(X + Y) + 1000 - 4 * Y - print(max(ans1, ans2)) \ No newline at end of file + ans2 = 500 - 2 * (X + Y) + 1000 - 4 * Y + print(max(ans1, ans2)) diff --git a/Codechef/PYCC48/PYCC48.py b/Codechef/PYCC48/PYCC48.py index 4bde66be..b244ec6b 100644 --- a/Codechef/PYCC48/PYCC48.py +++ b/Codechef/PYCC48/PYCC48.py @@ -3,6 +3,6 @@ T -= 1 X, Y = map(int, input().split()) ans1 = (500 - (X * 2)) + (1000 - ((X + Y) * 4)) - ans2 = (500 - (X + Y) * 2) + 1000 - (Y * 4) + ans2 = (500 - (X + Y) * 2) + 1000 - (Y * 4) A = max(ans1, ans2) - print(A) \ No newline at end of file + print(A) diff --git a/Codechef/PYCC49/PYCC49.py b/Codechef/PYCC49/PYCC49.py index acc41106..39cef562 100644 --- a/Codechef/PYCC49/PYCC49.py +++ b/Codechef/PYCC49/PYCC49.py @@ -6,4 +6,4 @@ if total >= P: print("Pass") else: - print("Fail") \ No newline at end of file + print("Fail") diff --git a/Codechef/PYCC50/PYCC50.py b/Codechef/PYCC50/PYCC50.py index 081167ef..919c08dd 100644 --- a/Codechef/PYCC50/PYCC50.py +++ b/Codechef/PYCC50/PYCC50.py @@ -5,4 +5,4 @@ if (A + C) == 180 or (B + D) == 180: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PYCC51/PYCC51.py b/Codechef/PYCC51/PYCC51.py index 0ea34653..891e0c1c 100644 --- a/Codechef/PYCC51/PYCC51.py +++ b/Codechef/PYCC51/PYCC51.py @@ -1,6 +1,7 @@ import math + T = int(input()) while T: - T-= 1 + T -= 1 N = int(input()) - print(math.ceil(N/10)) \ No newline at end of file + print(math.ceil(N / 10)) diff --git a/Codechef/PYCC52/PYCC52.py b/Codechef/PYCC52/PYCC52.py index 4960d4d0..270f06c0 100644 --- a/Codechef/PYCC52/PYCC52.py +++ b/Codechef/PYCC52/PYCC52.py @@ -1,2 +1,2 @@ N = int(input()) -print((N * N) // 2) \ No newline at end of file +print((N * N) // 2) diff --git a/Codechef/PYCC53/PYCC53.py b/Codechef/PYCC53/PYCC53.py index ad2d4f4e..b4bcd30a 100644 --- a/Codechef/PYCC53/PYCC53.py +++ b/Codechef/PYCC53/PYCC53.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) X = N // 5 - print(N - X) \ No newline at end of file + print(N - X) diff --git a/Codechef/PYDEBUG37/PYDEBUG37.py b/Codechef/PYDEBUG37/PYDEBUG37.py index 3f201b57..c8674128 100644 --- a/Codechef/PYDEBUG37/PYDEBUG37.py +++ b/Codechef/PYDEBUG37/PYDEBUG37.py @@ -1,7 +1,7 @@ T = int(input()) while T: T -= 1 - S, X, Y, Z = map(int,input().split()) + S, X, Y, Z = map(int, input().split()) if (S - X - Y) >= Z: print(0) else: @@ -9,4 +9,3 @@ print(1) else: print(2) - \ No newline at end of file diff --git a/Codechef/PYDEBUG38/PYDEBUG38.py b/Codechef/PYDEBUG38/PYDEBUG38.py index 799d5d06..bb4e3bbe 100644 --- a/Codechef/PYDEBUG38/PYDEBUG38.py +++ b/Codechef/PYDEBUG38/PYDEBUG38.py @@ -5,4 +5,4 @@ if abs(X - Y) <= D: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PYDEBUG39/PYDEBUG39.py b/Codechef/PYDEBUG39/PYDEBUG39.py index 8d8a2f3b..dde95c8b 100644 --- a/Codechef/PYDEBUG39/PYDEBUG39.py +++ b/Codechef/PYDEBUG39/PYDEBUG39.py @@ -7,4 +7,4 @@ for i in A: if i >= 10 and i <= 60: count += 1 - print(count) \ No newline at end of file + print(count) diff --git a/Codechef/PYDEBUG40/PYDEBUG40.py b/Codechef/PYDEBUG40/PYDEBUG40.py index 4573e59e..96ce4695 100644 --- a/Codechef/PYDEBUG40/PYDEBUG40.py +++ b/Codechef/PYDEBUG40/PYDEBUG40.py @@ -3,9 +3,9 @@ T -= 1 X, Y = map(int, input().split()) count = 0 - A = (500 - 2 *X ) + (1000 - 4 * (X + Y)) + A = (500 - 2 * X) + (1000 - 4 * (X + Y)) B = (1000 - 4 * Y) + (500 - 2 * (X + Y)) - if(A >B ): + if A > B: print(A) else: - print(B) \ No newline at end of file + print(B) diff --git a/Codechef/PYDEBUG41/PYDEBUG41.py b/Codechef/PYDEBUG41/PYDEBUG41.py index 13723b6a..ff015850 100644 --- a/Codechef/PYDEBUG41/PYDEBUG41.py +++ b/Codechef/PYDEBUG41/PYDEBUG41.py @@ -3,7 +3,7 @@ T -= 1 N, X, P = map(int, input().split()) total = X * 3 + (N - X) * (-1) - if (total >= P): + if total >= P: print("PASS") else: - print("FAIL") \ No newline at end of file + print("FAIL") diff --git a/Codechef/PYDEBUG42/PYDEBUG42.py b/Codechef/PYDEBUG42/PYDEBUG42.py index 2e341645..7efb6629 100644 --- a/Codechef/PYDEBUG42/PYDEBUG42.py +++ b/Codechef/PYDEBUG42/PYDEBUG42.py @@ -5,4 +5,4 @@ if (A + C == 180) and (B + D == 180): print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/PYDEBUG43/PYDEBUG43.py b/Codechef/PYDEBUG43/PYDEBUG43.py index 3885b21d..891e0c1c 100644 --- a/Codechef/PYDEBUG43/PYDEBUG43.py +++ b/Codechef/PYDEBUG43/PYDEBUG43.py @@ -1,6 +1,7 @@ import math + T = int(input()) while T: T -= 1 N = int(input()) - print(math.ceil(N/10)) \ No newline at end of file + print(math.ceil(N / 10)) diff --git a/Codechef/PYDEBUG44/PYDEBUG44.py b/Codechef/PYDEBUG44/PYDEBUG44.py index 1251f9cb..f3c1e3be 100644 --- a/Codechef/PYDEBUG44/PYDEBUG44.py +++ b/Codechef/PYDEBUG44/PYDEBUG44.py @@ -1,3 +1,3 @@ N = int(input()) res = (N * N) / 2 -print(int(res)) \ No newline at end of file +print(int(res)) diff --git a/Codechef/PYDEBUG45/PYDEBUG45.py b/Codechef/PYDEBUG45/PYDEBUG45.py index 3b172dd2..7f20e978 100644 --- a/Codechef/PYDEBUG45/PYDEBUG45.py +++ b/Codechef/PYDEBUG45/PYDEBUG45.py @@ -2,4 +2,4 @@ while T: T -= 1 N = int(input()) - print(N - (N // 5)) \ No newline at end of file + print(N - (N // 5)) diff --git a/Codechef/Par2/Par2.py b/Codechef/Par2/Par2.py index 66e2d165..5872f3e2 100644 --- a/Codechef/Par2/Par2.py +++ b/Codechef/Par2/Par2.py @@ -2,7 +2,7 @@ while T: T -= 1 N = int(input()) - if(N % 2 == 0): + if N % 2 == 0: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Penalty/Penalty.py b/Codechef/Penalty/Penalty.py index 4a9d5cfe..579736bf 100644 --- a/Codechef/Penalty/Penalty.py +++ b/Codechef/Penalty/Penalty.py @@ -6,9 +6,9 @@ even = [A[i] for i in range(len(A)) if (i % 2 == 0)] odd_one_count = [i for i in odd if i == 1] even_one_count = [i for i in even if i == 1] - if (odd_one_count > even_one_count): + if odd_one_count > even_one_count: print(2) - elif (odd_one_count < even_one_count): + elif odd_one_count < even_one_count: print(1) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/Perm_Exis/Perm_Exis.py b/Codechef/Perm_Exis/Perm_Exis.py index 0c2ebe51..a551f392 100644 --- a/Codechef/Perm_Exis/Perm_Exis.py +++ b/Codechef/Perm_Exis/Perm_Exis.py @@ -12,4 +12,4 @@ if c > 0: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/Play_Fit/Play_Fit.py b/Codechef/Play_Fit/Play_Fit.py index f83422a5..e41baff4 100644 --- a/Codechef/Play_Fit/Play_Fit.py +++ b/Codechef/Play_Fit/Play_Fit.py @@ -27,4 +27,4 @@ if maximum > 0: print(maximum) else: - print("UNFIT") \ No newline at end of file + print("UNFIT") diff --git a/Codechef/Podium/Podium.py b/Codechef/Podium/Podium.py index 1d40e33a..b6f11bbc 100644 --- a/Codechef/Podium/Podium.py +++ b/Codechef/Podium/Podium.py @@ -2,4 +2,4 @@ while T: T -= 1 A, B = map(int, input().split()) - print(A + B) \ No newline at end of file + print(A + B) diff --git a/Codechef/Poly_Bags/Poly_Bags.py b/Codechef/Poly_Bags/Poly_Bags.py index 3885b21d..891e0c1c 100644 --- a/Codechef/Poly_Bags/Poly_Bags.py +++ b/Codechef/Poly_Bags/Poly_Bags.py @@ -1,6 +1,7 @@ import math + T = int(input()) while T: T -= 1 N = int(input()) - print(math.ceil(N/10)) \ No newline at end of file + print(math.ceil(N / 10)) diff --git a/Codechef/Population/Population.py b/Codechef/Population/Population.py index e294188d..eff99cee 100644 --- a/Codechef/Population/Population.py +++ b/Codechef/Population/Population.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - print(X - Y + Z) \ No newline at end of file + print(X - Y + Z) diff --git a/Codechef/Prac_List/Prac_List.py b/Codechef/Prac_List/Prac_List.py index 3eba500f..f6f8b0a9 100644 --- a/Codechef/Prac_List/Prac_List.py +++ b/Codechef/Prac_List/Prac_List.py @@ -1,2 +1,2 @@ X, Y = map(int, input().split()) -print(X - Y) \ No newline at end of file +print(X - Y) diff --git a/Codechef/Presents/Presents.py b/Codechef/Presents/Presents.py index 5217c887..77cec4f3 100644 --- a/Codechef/Presents/Presents.py +++ b/Codechef/Presents/Presents.py @@ -1,10 +1,10 @@ T = int(input()) while T: - T-= 1 + T -= 1 N = int(input()) if N % 5 == 0: temp = int(N / 5) print(4 * temp) else: temp = N // 5 - print(N - temp) \ No newline at end of file + print(N - temp) diff --git a/Codechef/Prime_Dice/Prime_Dice.py b/Codechef/Prime_Dice/Prime_Dice.py index 2aa85aa2..c982e3b6 100644 --- a/Codechef/Prime_Dice/Prime_Dice.py +++ b/Codechef/Prime_Dice/Prime_Dice.py @@ -1,9 +1,9 @@ def isPrime(X): c = 1 for i in range(2, X + 1): - if (X % i == 0): + if X % i == 0: c += 1 - if (c == 2): + if c == 2: return True else: return False @@ -14,7 +14,7 @@ def isPrime(X): T -= 1 A, B = map(int, input().split()) total = A + B - if (isPrime(total)): + if isPrime(total): print("ALICE") else: - print("BOB") \ No newline at end of file + print("BOB") diff --git a/Codechef/Primereverse/Primereverse.py b/Codechef/Primereverse/Primereverse.py index 3898ed7c..f2c0783b 100644 --- a/Codechef/Primereverse/Primereverse.py +++ b/Codechef/Primereverse/Primereverse.py @@ -4,15 +4,15 @@ N = int(input()) A = input() B = input() - mp1 = {"1" : 0, "0" : 0} - mp2 = {"1" : 0, "0" : 0} + mp1 = {"1": 0, "0": 0} + mp2 = {"1": 0, "0": 0} for i in A: if i in mp1.keys(): mp1[i] += 1 else: mp1[i] = 1 - + for i in B: if i in mp2.keys(): mp2[i] += 1 @@ -22,4 +22,3 @@ print("YES") else: print("NO") - \ No newline at end of file diff --git a/Codechef/Prize_Pool/Prize_Pool.py b/Codechef/Prize_Pool/Prize_Pool.py index f363a81f..8f1b72dd 100644 --- a/Codechef/Prize_Pool/Prize_Pool.py +++ b/Codechef/Prize_Pool/Prize_Pool.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print((X * 10) + (Y * 90)) \ No newline at end of file + print((X * 10) + (Y * 90)) diff --git a/Codechef/Prob_Cat/Prob_Cat.py b/Codechef/Prob_Cat/Prob_Cat.py index 4ef8861c..32e07f9f 100644 --- a/Codechef/Prob_Cat/Prob_Cat.py +++ b/Codechef/Prob_Cat/Prob_Cat.py @@ -7,4 +7,4 @@ elif X >= 100 and X < 200: print("Medium") elif X >= 200 and X <= 300: - print("Hard") \ No newline at end of file + print("Hard") diff --git a/Codechef/Prog_Lang/Prog_Lang.py b/Codechef/Prog_Lang/Prog_Lang.py index 09d74446..c892fb6e 100644 --- a/Codechef/Prog_Lang/Prog_Lang.py +++ b/Codechef/Prog_Lang/Prog_Lang.py @@ -7,4 +7,4 @@ elif A in [A2, B2] and B in [A2, B2]: print(2) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/QTOO_2523/QTOO_2523.py b/Codechef/QTOO_2523/QTOO_2523.py index bc9ee1df..f21c3d57 100644 --- a/Codechef/QTOO_2523/QTOO_2523.py +++ b/Codechef/QTOO_2523/QTOO_2523.py @@ -7,4 +7,4 @@ if len(S1) == len(S): print(-1) else: - print(len(S) - 2) \ No newline at end of file + print(len(S) - 2) diff --git a/Codechef/QUEENATTACK/QUEENATTACK.py b/Codechef/QUEENATTACK/QUEENATTACK.py index c576a2b0..9f927e5c 100644 --- a/Codechef/QUEENATTACK/QUEENATTACK.py +++ b/Codechef/QUEENATTACK/QUEENATTACK.py @@ -3,6 +3,8 @@ T -= 1 N, X, Y = map(int, input().split()) cells_in_row_column = (N - 1) * 2 - cells_in_diagonals = min(N - X, N - Y) + min(X - 1, Y - 1) + min(N - X, Y - 1) + min(X - 1, N - Y) + cells_in_diagonals = ( + min(N - X, N - Y) + min(X - 1, Y - 1) + min(N - X, Y - 1) + min(X - 1, N - Y) + ) cells_under_attack = cells_in_row_column + cells_in_diagonals - print(cells_under_attack) \ No newline at end of file + print(cells_under_attack) diff --git a/Codechef/Qualify/Qualify.py b/Codechef/Qualify/Qualify.py index b02c3638..c5818ce7 100644 --- a/Codechef/Qualify/Qualify.py +++ b/Codechef/Qualify/Qualify.py @@ -2,7 +2,7 @@ while T: T -= 1 X, A, B = map(int, input().split()) - if (A + (B * 2) >= X): + if A + (B * 2) >= X: print("Qualify") else: - print("NotQualify") \ No newline at end of file + print("NotQualify") diff --git a/Codechef/RAIN8TEST/RAIN8TEST.py b/Codechef/RAIN8TEST/RAIN8TEST.py index 2c5af110..7406824a 100644 --- a/Codechef/RAIN8TEST/RAIN8TEST.py +++ b/Codechef/RAIN8TEST/RAIN8TEST.py @@ -9,4 +9,4 @@ for i in range(len(D)): if D[i] == 1 or (i != 0 and D[i - 1] == 1): cost += X - print(cost) \ No newline at end of file + print(cost) diff --git a/Codechef/RATING_PRAC/RATING_PRAC.py b/Codechef/RATING_PRAC/RATING_PRAC.py index c70d469b..1d9f970f 100644 --- a/Codechef/RATING_PRAC/RATING_PRAC.py +++ b/Codechef/RATING_PRAC/RATING_PRAC.py @@ -14,4 +14,4 @@ if R == 1: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/REMDUP/REMDUP.py b/Codechef/REMDUP/REMDUP.py index 8fad20f3..924df529 100644 --- a/Codechef/REMDUP/REMDUP.py +++ b/Codechef/REMDUP/REMDUP.py @@ -6,4 +6,4 @@ B = set(A) B = list(B) B.sort() - print(*B) \ No newline at end of file + print(*B) diff --git a/Codechef/REMOVEBAD/REMOVEBAD.py b/Codechef/REMOVEBAD/REMOVEBAD.py index 99abbb3f..d0c7eb6e 100644 --- a/Codechef/REMOVEBAD/REMOVEBAD.py +++ b/Codechef/REMOVEBAD/REMOVEBAD.py @@ -1,4 +1,5 @@ from collections import Counter + T = int(input()) while T: T -= 1 @@ -7,4 +8,4 @@ C = Counter(A) for A, B in C.most_common(1): M = B - print(N - M) \ No newline at end of file + print(N - M) diff --git a/Codechef/REMOVECARDS/REMOVECARDS.py b/Codechef/REMOVECARDS/REMOVECARDS.py index 7ba50f0f..3ed87ab9 100644 --- a/Codechef/REMOVECARDS/REMOVECARDS.py +++ b/Codechef/REMOVECARDS/REMOVECARDS.py @@ -1,4 +1,5 @@ from statistics import mode + T = int(input()) while T: T -= 1 @@ -6,4 +7,4 @@ A = list(map(int, input().split())) J = mode(A) CN = A.count(J) - print(N - CN) \ No newline at end of file + print(N - CN) diff --git a/Codechef/REVSEG/REVSEG.py b/Codechef/REVSEG/REVSEG.py index 3e52dee1..c14a2686 100644 --- a/Codechef/REVSEG/REVSEG.py +++ b/Codechef/REVSEG/REVSEG.py @@ -5,28 +5,26 @@ def __init__(self, data): self.next = None """ + def reverseSegment(head, L, R): - if L==R: + if L == R: return head dummy = Node(0) - + dummy.next = head prev = dummy - i = 1 - while i Y and X > Z: print("ALICE") elif Y > X and Y > Z: print("BOB") elif Z > X and Z > Y: - print("CHARLIE") \ No newline at end of file + print("CHARLIE") diff --git a/Codechef/Rainfall_1/Rainfall_1.py b/Codechef/Rainfall_1/Rainfall_1.py index 36d5c7e5..82fada35 100644 --- a/Codechef/Rainfall_1/Rainfall_1.py +++ b/Codechef/Rainfall_1/Rainfall_1.py @@ -2,9 +2,9 @@ while T: T -= 1 X = int(input()) - if (X < 3): + if X < 3: print("LIGHT") - elif (X >= 3 and X < 7): + elif X >= 3 and X < 7: print("MODERATE") - elif (X >= 7): - print("HEAVY") \ No newline at end of file + elif X >= 7: + print("HEAVY") diff --git a/Codechef/Rating/Rating.py b/Codechef/Rating/Rating.py index 1d120269..fbd36f86 100644 --- a/Codechef/Rating/Rating.py +++ b/Codechef/Rating/Rating.py @@ -2,4 +2,4 @@ while T: T -= 1 S = int(input()) - print(-S - 1) \ No newline at end of file + print(-S - 1) diff --git a/Codechef/Reach_Fast/Reach_Fast.py b/Codechef/Reach_Fast/Reach_Fast.py index 09eca50f..8991f993 100644 --- a/Codechef/Reach_Fast/Reach_Fast.py +++ b/Codechef/Reach_Fast/Reach_Fast.py @@ -1,12 +1,13 @@ import math + T = int(input()) while T: T -= 1 X, Y, K = map(int, input().split()) if X <= Y: - least = math.ceil((Y - X)/K) + least = math.ceil((Y - X) / K) elif X >= Y: - least = math.ceil((X - Y)/K) + least = math.ceil((X - Y) / K) else: print(0) - print(least) \ No newline at end of file + print(least) diff --git a/Codechef/Reach_Home/Reach_Home.py b/Codechef/Reach_Home/Reach_Home.py index bd0fda79..2155fd7a 100644 --- a/Codechef/Reach_Home/Reach_Home.py +++ b/Codechef/Reach_Home/Reach_Home.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (5 * X >= Y): + if 5 * X >= Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Reach_Target/Reach_Target.py b/Codechef/Reach_Target/Reach_Target.py index df27931b..63ce4f9d 100644 --- a/Codechef/Reach_Target/Reach_Target.py +++ b/Codechef/Reach_Target/Reach_Target.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print(X - Y) \ No newline at end of file + print(X - Y) diff --git a/Codechef/Read_Pages/Read_Pages.py b/Codechef/Read_Pages/Read_Pages.py index 881620f5..7007e129 100644 --- a/Codechef/Read_Pages/Read_Pages.py +++ b/Codechef/Read_Pages/Read_Pages.py @@ -2,7 +2,7 @@ while T: T -= 1 N, X, Y = map(int, input().split()) - if ((X * Y) >= N): + if (X * Y) >= N: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Recipe/Recipe.py b/Codechef/Recipe/Recipe.py index b78b8479..cc4f1a9b 100644 --- a/Codechef/Recipe/Recipe.py +++ b/Codechef/Recipe/Recipe.py @@ -1,4 +1,5 @@ import numpy as np + T = int(input()) while T: T -= 1 @@ -11,7 +12,7 @@ for i in range(1, len(B)): g = np.gcd(g, B[i]) for i in range(len(B)): - C.append(B[i]//g) + C.append(B[i] // g) for i in range(len(C)): - print(C[i], end = ' ') - print() \ No newline at end of file + print(C[i], end=" ") + print() diff --git a/Codechef/Remove_Cards/Remove_Cards.py b/Codechef/Remove_Cards/Remove_Cards.py index c078778d..385f0822 100644 --- a/Codechef/Remove_Cards/Remove_Cards.py +++ b/Codechef/Remove_Cards/Remove_Cards.py @@ -11,11 +11,10 @@ else: freq_dict[l[i]] = 1 - highest_mode_number = max(freq_dict, key = lambda x : freq_dict[x]) + highest_mode_number = max(freq_dict, key=lambda x: freq_dict[x]) c = 0 for i in l: if i != highest_mode_number: c += 1 - - print(c) + print(c) diff --git a/Codechef/Repeat/Repeat.py b/Codechef/Repeat/Repeat.py index 22c098dd..e22b5acb 100644 --- a/Codechef/Repeat/Repeat.py +++ b/Codechef/Repeat/Repeat.py @@ -18,6 +18,6 @@ N, K, S = map(int, input().split()) c = 0 for i in range(2 * N + 1): - if (i % 2 == 1): + if i % 2 == 1: c += i - print(int((S - c)/(K - 1))) \ No newline at end of file + print(int((S - c) / (K - 1))) diff --git a/Codechef/Return_Change/Return_Change.py b/Codechef/Return_Change/Return_Change.py index af27ae5d..c189649d 100644 --- a/Codechef/Return_Change/Return_Change.py +++ b/Codechef/Return_Change/Return_Change.py @@ -5,4 +5,4 @@ nearest = round(X / 10) * 10 if abs(X - nearest >= 5): nearest += 10 - print(100 - nearest) \ No newline at end of file + print(100 - nearest) diff --git a/Codechef/Right_There/Right_There.py b/Codechef/Right_There/Right_There.py index dc160391..d1ce4e84 100644 --- a/Codechef/Right_There/Right_There.py +++ b/Codechef/Right_There/Right_There.py @@ -2,7 +2,7 @@ while T: T -= 1 N, X = map(int, input().split()) - if (N <= X): + if N <= X: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/SDIGIT/SDIGIT.py b/Codechef/SDIGIT/SDIGIT.py index ed3c841a..c50271fa 100644 --- a/Codechef/SDIGIT/SDIGIT.py +++ b/Codechef/SDIGIT/SDIGIT.py @@ -8,8 +8,8 @@ ans = A[0] * N else: while N: - if A[0] != '0' or not ans: + if A[0] != "0" or not ans: N -= 1 N, i = divmod(N, D) ans.insert(0, A[i]) - print(''.join(ans)) \ No newline at end of file + print("".join(ans)) diff --git a/Codechef/SEGEO/SEGEO.py b/Codechef/SEGEO/SEGEO.py index 0e87f3c9..dc051aad 100644 --- a/Codechef/SEGEO/SEGEO.py +++ b/Codechef/SEGEO/SEGEO.py @@ -11,4 +11,4 @@ else: odd.append(i) ans = even + odd - print(*ans) \ No newline at end of file + print(*ans) diff --git a/Codechef/SMIMIND/SMIMIND.py b/Codechef/SMIMIND/SMIMIND.py index 53a19d9a..d9cdea60 100644 --- a/Codechef/SMIMIND/SMIMIND.py +++ b/Codechef/SMIMIND/SMIMIND.py @@ -1,7 +1,7 @@ from bisect import bisect_left N, Q = map(int, input().split()) -A = list(map(int, ('0 ' + input()).split())) +A = list(map(int, ("0 " + input()).split())) for i in range(1, N + 1): A[i] += A[i - 1] ans = [] @@ -11,4 +11,4 @@ if j > N: j = -1 ans.append(j) -print(*ans) \ No newline at end of file +print(*ans) diff --git a/Codechef/SMOL/SMOL.py b/Codechef/SMOL/SMOL.py index 992bbb65..77bf7646 100644 --- a/Codechef/SMOL/SMOL.py +++ b/Codechef/SMOL/SMOL.py @@ -5,4 +5,4 @@ if N >= K and K != 0: print(N % K) else: - print(N) \ No newline at end of file + print(N) diff --git a/Codechef/SND_Max/SND_Max.py b/Codechef/SND_Max/SND_Max.py index db1d205b..5e23ee8a 100644 --- a/Codechef/SND_Max/SND_Max.py +++ b/Codechef/SND_Max/SND_Max.py @@ -3,4 +3,4 @@ N -= 1 A = list(map(int, input().split())) A.sort() - print(A[1]) \ No newline at end of file + print(A[1]) diff --git a/Codechef/SRTARR/SRTARR.py b/Codechef/SRTARR/SRTARR.py index 9f4b5427..359a9e86 100644 --- a/Codechef/SRTARR/SRTARR.py +++ b/Codechef/SRTARR/SRTARR.py @@ -1,4 +1,4 @@ -T= int(input()) +T = int(input()) while T: T -= 1 N = int(input()) @@ -7,4 +7,4 @@ for i in range(N): if S[i : i + 2] == "10": c += 1 - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/SRTLL/SRTLL.py b/Codechef/SRTLL/SRTLL.py index 35dbe7b5..f406bd56 100644 --- a/Codechef/SRTLL/SRTLL.py +++ b/Codechef/SRTLL/SRTLL.py @@ -4,4 +4,4 @@ N = int(input()) A = list(map(int, input().split())) A.sort() - print(*A) \ No newline at end of file + print(*A) diff --git a/Codechef/STRNG/STRNG.py b/Codechef/STRNG/STRNG.py index 54488473..7f5ec166 100644 --- a/Codechef/STRNG/STRNG.py +++ b/Codechef/STRNG/STRNG.py @@ -1,29 +1,30 @@ def gcd(x, y): - while(y): - x, y= y, x % y + while y: + x, y = y, x % y return x + for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) count = 0 a = [arr[0]] - b = [arr[n-1]] + b = [arr[n - 1]] for i in range(1, n): a.append(gcd(a[-1], arr[i])) - b.append(gcd(b[-1], arr[n-1-i])) + b.append(gcd(b[-1], arr[n - 1 - i])) ans = a[-1] for i in range(n): - if(i > 0 and i < n - 1): - if(gcd(a[i - 1], b[n - 2 - i]) != 1): + if i > 0 and i < n - 1: + if gcd(a[i - 1], b[n - 2 - i]) != 1: count += 1 - if(i == 0): - if(b[n - 2] != 1): + if i == 0: + if b[n - 2] != 1: count += 1 - if(i == n - 1): - if(a[n - 2] != 1): + if i == n - 1: + if a[n - 2] != 1: count += 1 - if(ans == 1): + if ans == 1: print(count) else: - print(n) \ No newline at end of file + print(n) diff --git a/Codechef/Sale/Sale.py b/Codechef/Sale/Sale.py index 28049460..2ef68660 100644 --- a/Codechef/Sale/Sale.py +++ b/Codechef/Sale/Sale.py @@ -4,4 +4,4 @@ A, B, C = map(int, input().split()) minimum = min(A, B, C) total = (A + B + C) - minimum - print(total) \ No newline at end of file + print(total) diff --git a/Codechef/Scalene/Scalene.py b/Codechef/Scalene/Scalene.py index e2e09786..1540a69f 100644 --- a/Codechef/Scalene/Scalene.py +++ b/Codechef/Scalene/Scalene.py @@ -6,4 +6,4 @@ if len(scalene) == 3: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Seat_Number/Seat_Number.py b/Codechef/Seat_Number/Seat_Number.py index 86197797..118d990e 100644 --- a/Codechef/Seat_Number/Seat_Number.py +++ b/Codechef/Seat_Number/Seat_Number.py @@ -2,11 +2,11 @@ while T: T -= 1 N = int(input()) - if (N <= 10): + if N <= 10: print("LOWER DOUBLE") - elif (N >= 11 and N <= 15): + elif N >= 11 and N <= 15: print("LOWER SINGLE") - elif (N >= 16 and N <= 25): + elif N >= 16 and N <= 25: print("UPPER DOUBLE") else: - print("UPPER SINGLE") \ No newline at end of file + print("UPPER SINGLE") diff --git a/Codechef/Sem_Courses/Sem_Courses.py b/Codechef/Sem_Courses/Sem_Courses.py index 7d342d0e..0e3e13fa 100644 --- a/Codechef/Sem_Courses/Sem_Courses.py +++ b/Codechef/Sem_Courses/Sem_Courses.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - print(X * Y * Z) \ No newline at end of file + print(X * Y * Z) diff --git a/Codechef/Shk_Num/Shk_Num.py b/Codechef/Shk_Num/Shk_Num.py index 420cabb9..b462f788 100644 --- a/Codechef/Shk_Num/Shk_Num.py +++ b/Codechef/Shk_Num/Shk_Num.py @@ -8,7 +8,7 @@ while T: T -= 1 N = int(input()) - i = 0 - while(L[i] < N): - i += 1 - print(min(abs(L[i] - N), abs(N - L[i - 1]))) \ No newline at end of file + i = 0 + while L[i] < N: + i += 1 + print(min(abs(L[i] - N), abs(N - L[i - 1]))) diff --git a/Codechef/Shop_Change/Shop_Change.py b/Codechef/Shop_Change/Shop_Change.py index d85527f0..24a4c1dc 100644 --- a/Codechef/Shop_Change/Shop_Change.py +++ b/Codechef/Shop_Change/Shop_Change.py @@ -2,4 +2,4 @@ while T: T -= 1 X = int(input()) - print(100 - X) \ No newline at end of file + print(100 - X) diff --git a/Codechef/Single_Use/Single_Use.py b/Codechef/Single_Use/Single_Use.py index f639052d..6e32396b 100644 --- a/Codechef/Single_Use/Single_Use.py +++ b/Codechef/Single_Use/Single_Use.py @@ -1,9 +1,10 @@ import math + T = int(input()) while T: T -= 1 H, X, Y = map(int, input().split()) H -= Y - attacks = math.ceil(H/X) + 1 - print(attacks) \ No newline at end of file + attacks = math.ceil(H / X) + 1 + print(attacks) diff --git a/Codechef/Six_Friends/Six_Friends.py b/Codechef/Six_Friends/Six_Friends.py index 0059acb3..e40219fd 100644 --- a/Codechef/Six_Friends/Six_Friends.py +++ b/Codechef/Six_Friends/Six_Friends.py @@ -2,4 +2,4 @@ while T: T -= 1 X, Y = map(int, input().split()) - print(min((3 * X), (2 * Y))) \ No newline at end of file + print(min((3 * X), (2 * Y))) diff --git a/Codechef/Slab/Slab.py b/Codechef/Slab/Slab.py index e56791a5..49e58ee0 100644 --- a/Codechef/Slab/Slab.py +++ b/Codechef/Slab/Slab.py @@ -2,26 +2,41 @@ while T: T -= 1 N = int(input()) - - if (N <= 250000): + + if N <= 250000: net_total = N - elif (N > 250000 and N <= 500000): - net_total = N - ((N - 250000) * 0.05) - - elif (N > 500000 and N <= 750000): - net_total = N - ((250000 * 0.05) + (N - 500000) * 0.1) - - elif (N > 750000 and N <= 1000000): + elif N > 250000 and N <= 500000: + net_total = N - ((N - 250000) * 0.05) + + elif N > 500000 and N <= 750000: + net_total = N - ((250000 * 0.05) + (N - 500000) * 0.1) + + elif N > 750000 and N <= 1000000: net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (N - 750000) * 0.15) - - elif (N > 1000000 and N <= 1250000): - net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (N - 1000000) * 0.2) - - elif (N > 1250000 and N <= 1500000): - net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (250000 * 0.2) + (N - 1250000) * 0.25) - - elif (N > 1500000): - net_total = N - ((250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (250000 * 0.2) + (250000 * 0.25) + (N - 1500000) * 0.3) - - print(int(net_total)) \ No newline at end of file + + elif N > 1000000 and N <= 1250000: + net_total = N - ( + (250000 * 0.05) + (250000 * 0.1) + (250000 * 0.15) + (N - 1000000) * 0.2 + ) + + elif N > 1250000 and N <= 1500000: + net_total = N - ( + (250000 * 0.05) + + (250000 * 0.1) + + (250000 * 0.15) + + (250000 * 0.2) + + (N - 1250000) * 0.25 + ) + + elif N > 1500000: + net_total = N - ( + (250000 * 0.05) + + (250000 * 0.1) + + (250000 * 0.15) + + (250000 * 0.2) + + (250000 * 0.25) + + (N - 1500000) * 0.3 + ) + + print(int(net_total)) diff --git a/Codechef/Sleep/Sleep.py b/Codechef/Sleep/Sleep.py index c8e07ebf..fb89fbb3 100644 --- a/Codechef/Sleep/Sleep.py +++ b/Codechef/Sleep/Sleep.py @@ -5,4 +5,4 @@ if X < 7: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Snake_Eat/Snake_Eat.py b/Codechef/Snake_Eat/Snake_Eat.py index 9269b607..f5f2cba2 100644 --- a/Codechef/Snake_Eat/Snake_Eat.py +++ b/Codechef/Snake_Eat/Snake_Eat.py @@ -6,19 +6,19 @@ N, Q = map(int, input().split()) L = list(map(int, input().split())) L.sort() - sum=[0] * N + sum = [0] * N for j in range(1, N): sum[j] = sum[j - 1] + L[j] for i in range(Q): K = int(input()) pos = bs.bisect_left(L, K) - l = 0 + l = 0 r = pos while l < r: m = (l + r) // 2 - need = K * (pos -m ) - (sum[pos - 1] - sum[m - 1]) - if(need <= m): + need = K * (pos - m) - (sum[pos - 1] - sum[m - 1]) + if need <= m: r = m else: l = m + 1 - print(N - r) \ No newline at end of file + print(N - r) diff --git a/Codechef/Snape/Snape.py b/Codechef/Snape/Snape.py index 2767822b..82b67456 100644 --- a/Codechef/Snape/Snape.py +++ b/Codechef/Snape/Snape.py @@ -1,6 +1,7 @@ from math import sqrt + T = int(input()) while T: T -= 1 B, LS = map(int, input().split()) - print(round(sqrt(LS**2 - B**2), 4), round(sqrt(LS**2 + B**2), 4)) \ No newline at end of file + print(round(sqrt(LS**2 - B**2), 4), round(sqrt(LS**2 + B**2), 4)) diff --git a/Codechef/Songs/Songs.py b/Codechef/Songs/Songs.py index e8f4a37f..2b921027 100644 --- a/Codechef/Songs/Songs.py +++ b/Codechef/Songs/Songs.py @@ -3,4 +3,4 @@ T -= 1 N, X = map(int, input().split()) total = X * 3 - print(N//total) \ No newline at end of file + print(N // total) diff --git a/Codechef/Speciality/Speciality.py b/Codechef/Speciality/Speciality.py index fb9da5be..42e3c6cc 100644 --- a/Codechef/Speciality/Speciality.py +++ b/Codechef/Speciality/Speciality.py @@ -11,4 +11,4 @@ if Y > Z: print("Tester") else: - print("Editorialist") \ No newline at end of file + print("Editorialist") diff --git a/Codechef/Speed_Test/Speed_Test.py b/Codechef/Speed_Test/Speed_Test.py index 847e1422..a6db31c2 100644 --- a/Codechef/Speed_Test/Speed_Test.py +++ b/Codechef/Speed_Test/Speed_Test.py @@ -2,9 +2,9 @@ while T: T -= 1 A, X, B, Y = map(int, input().split()) - if ((A/X) > (B/Y)): + if (A / X) > (B / Y): print("ALICE") - elif ((A/X) < (B/Y)): + elif (A / X) < (B / Y): print("BOB") else: - print("EQUAL") \ No newline at end of file + print("EQUAL") diff --git a/Codechef/Squats/Squats.py b/Codechef/Squats/Squats.py index 4ead1eca..baff3a08 100644 --- a/Codechef/Squats/Squats.py +++ b/Codechef/Squats/Squats.py @@ -2,4 +2,4 @@ while T: T -= 1 X = int(input()) - print(15 * X) \ No newline at end of file + print(15 * X) diff --git a/Codechef/Sticks/Sticks.py b/Codechef/Sticks/Sticks.py index 417a30f3..57dad4e3 100644 --- a/Codechef/Sticks/Sticks.py +++ b/Codechef/Sticks/Sticks.py @@ -6,12 +6,12 @@ s = set(A) l = [] for i in s: - if (A.count(i) >= 2): + if A.count(i) >= 2: l.append(i) - if (A.count(i) >= 4): + if A.count(i) >= 4: l.append(i) l.sort() - if (len(l) >= 2): + if len(l) >= 2: print(l[-1] * l[-2]) else: - print(-1) \ No newline at end of file + print(-1) diff --git a/Codechef/Stones/Stones.py b/Codechef/Stones/Stones.py index d5968a67..f45d2769 100644 --- a/Codechef/Stones/Stones.py +++ b/Codechef/Stones/Stones.py @@ -8,4 +8,4 @@ if i in J: c += 1 - print(c) \ No newline at end of file + print(c) diff --git a/Codechef/Sub_Inc/Sub_Inc.py b/Codechef/Sub_Inc/Sub_Inc.py index 4507e4bb..19523517 100644 --- a/Codechef/Sub_Inc/Sub_Inc.py +++ b/Codechef/Sub_Inc/Sub_Inc.py @@ -1,5 +1,5 @@ T = int(input()) -while T: +while T: T -= 1 N = int(input()) A = list(map(int, input().split())) @@ -13,4 +13,4 @@ count = 1 last = i ans += count * (count + 1) // 2 - print(ans) \ No newline at end of file + print(ans) diff --git a/Codechef/Sub_Task/Sub_Task.py b/Codechef/Sub_Task/Sub_Task.py index 2eb14855..a281f53b 100644 --- a/Codechef/Sub_Task/Sub_Task.py +++ b/Codechef/Sub_Task/Sub_Task.py @@ -6,12 +6,12 @@ one_count = 0 for i in A: if i == 1: - one_count += 1 + one_count += 1 else: break - if (one_count == N): - print(100) - elif (one_count >= M): - print(K) + if one_count == N: + print(100) + elif one_count >= M: + print(K) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/Subscribe/Subscribe.py b/Codechef/Subscribe/Subscribe.py index f27780e8..e2de98d6 100644 --- a/Codechef/Subscribe/Subscribe.py +++ b/Codechef/Subscribe/Subscribe.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X > 30): + if X > 30: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Sugercane/Sugercane.py b/Codechef/Sugercane/Sugercane.py index 687156b1..16ec899b 100644 --- a/Codechef/Sugercane/Sugercane.py +++ b/Codechef/Sugercane/Sugercane.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) price = 50 * N - print(int(0.3 *price)) \ No newline at end of file + print(int(0.3 * price)) diff --git a/Codechef/Sum_Train/Sum_Train.py b/Codechef/Sum_Train/Sum_Train.py index a2306b0b..f97b03ce 100644 --- a/Codechef/Sum_Train/Sum_Train.py +++ b/Codechef/Sum_Train/Sum_Train.py @@ -4,9 +4,9 @@ N = int(input()) A = [] for j in range(N): - M = list(map(int,input().split())) + M = list(map(int, input().split())) A.append(M) for j in range(N - 2, -1, -1): for k in range(0, j + 1): A[j][k] += max(A[j + 1][k], A[j + 1][k + 1]) - print(A[0][0]) \ No newline at end of file + print(A[0][0]) diff --git a/Codechef/Summ/Summ.py b/Codechef/Summ/Summ.py index 0bac5303..f210489a 100644 --- a/Codechef/Summ/Summ.py +++ b/Codechef/Summ/Summ.py @@ -2,7 +2,7 @@ while T: T -= 1 A, B, C = map(int, input().split()) - if ((A + B) == C): + if (A + B) == C: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Sunday/Sunday.py b/Codechef/Sunday/Sunday.py index 41009102..39a6fcb1 100644 --- a/Codechef/Sunday/Sunday.py +++ b/Codechef/Sunday/Sunday.py @@ -8,4 +8,4 @@ B[i] = int(B[i]) weekend = [6, 7, 13, 14, 20, 21, 27, 28] matching = [i for i in B if i in weekend] - print((len(B) - len(matching)) + 8) \ No newline at end of file + print((len(B) - len(matching)) + 8) diff --git a/Codechef/TALAZY/TALAZY.py b/Codechef/TALAZY/TALAZY.py index 6c9f28f5..05dd9d18 100644 --- a/Codechef/TALAZY/TALAZY.py +++ b/Codechef/TALAZY/TALAZY.py @@ -1,15 +1,15 @@ # comp, time, s = 0, 0, 1 s = 0 + def calculateTime(N, B, M): # global comp, time, s global s # print(comp, ", ", time) - if N == 0: return s - B - + else: if N % 2 == 0: s += N // 2 * M @@ -27,4 +27,4 @@ def calculateTime(N, B, M): T -= 1 N, B, M = map(int, input().split()) s = 0 - print(calculateTime(N, B, M)) \ No newline at end of file + print(calculateTime(N, B, M)) diff --git a/Codechef/THREEFR/THREEFR.py b/Codechef/THREEFR/THREEFR.py index 4655646b..a5f2d292 100644 --- a/Codechef/THREEFR/THREEFR.py +++ b/Codechef/THREEFR/THREEFR.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y, Z = map(int, input().split()) - if (X + Y == Z or Y + Z == X or Z + X == Y): - print('yes') + if X + Y == Z or Y + Z == X or Z + X == Y: + print("yes") else: - print('no') \ No newline at end of file + print("no") diff --git a/Codechef/TSORT/TSORT.py b/Codechef/TSORT/TSORT.py index d3bfb1f1..464acfd3 100644 --- a/Codechef/TSORT/TSORT.py +++ b/Codechef/TSORT/TSORT.py @@ -5,4 +5,4 @@ L.append(ele) L.sort() for i in L: - print(i) \ No newline at end of file + print(i) diff --git a/Codechef/TWOSTR/TWOSTR.py b/Codechef/TWOSTR/TWOSTR.py index 5ebc6836..4cb1ee70 100644 --- a/Codechef/TWOSTR/TWOSTR.py +++ b/Codechef/TWOSTR/TWOSTR.py @@ -5,11 +5,11 @@ Y = input() L = len(X) c = 0 - for i in range (L): - if(X[i] != '?' and Y[i] != '?'): - if(X[i] != Y[i]): + for i in range(L): + if X[i] != "?" and Y[i] != "?": + if X[i] != Y[i]: c += 1 - if (c): - print('No') + if c: + print("No") else: - print('Yes') \ No newline at end of file + print("Yes") diff --git a/Codechef/Tablets/Tablets.py b/Codechef/Tablets/Tablets.py index 00e7e04d..0d8bc3c0 100644 --- a/Codechef/Tablets/Tablets.py +++ b/Codechef/Tablets/Tablets.py @@ -2,7 +2,7 @@ while T: T -= 1 X, Y = map(int, input().split()) - if (3 * X <= Y): + if 3 * X <= Y: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Tach_Stck/Tach_Stck.py b/Codechef/Tach_Stck/Tach_Stck.py index 97ffbfb6..78d7b1c5 100644 --- a/Codechef/Tach_Stck/Tach_Stck.py +++ b/Codechef/Tach_Stck/Tach_Stck.py @@ -3,9 +3,9 @@ X.sort() i, a = 0, 0 while i < N - 1: - if X[i + 1] - X[ i ] <= M: + if X[i + 1] - X[i] <= M: a += 1 - i += 2 + i += 2 else: - i += 1 -print(a) \ No newline at end of file + i += 1 +print(a) diff --git a/Codechef/Taller/Taller.py b/Codechef/Taller/Taller.py index 252379c9..0bce23dc 100644 --- a/Codechef/Taller/Taller.py +++ b/Codechef/Taller/Taller.py @@ -5,4 +5,4 @@ if X > Y: print("A") else: - print("B") \ No newline at end of file + print("B") diff --git a/Codechef/Tandj1/Tandj1.py b/Codechef/Tandj1/Tandj1.py index 18680a56..3d48fc5f 100644 --- a/Codechef/Tandj1/Tandj1.py +++ b/Codechef/Tandj1/Tandj1.py @@ -5,7 +5,7 @@ steps = abs(c - a) + abs(d - b) if steps == K: print("Yes") - elif K > steps and (K - steps) %2 == 0: + elif K > steps and (K - steps) % 2 == 0: print("Yes") else: - print("No") \ No newline at end of file + print("No") diff --git a/Codechef/Taste_Dec/Taste_Dec.py b/Codechef/Taste_Dec/Taste_Dec.py index 54712b88..0866a9b6 100644 --- a/Codechef/Taste_Dec/Taste_Dec.py +++ b/Codechef/Taste_Dec/Taste_Dec.py @@ -2,9 +2,9 @@ while T: T -= 1 X, Y = map(int, input().split()) - if ((2 * X) > (5 * Y)): + if (2 * X) > (5 * Y): print("Chocolate") - elif((2 * X) < (5 * Y)): + elif (2 * X) < (5 * Y): print("Candy") else: - print("Either") \ No newline at end of file + print("Either") diff --git a/Codechef/Tax_Saving/Tax_Saving.py b/Codechef/Tax_Saving/Tax_Saving.py index cdc1bbc6..63ce4f9d 100644 --- a/Codechef/Tax_Saving/Tax_Saving.py +++ b/Codechef/Tax_Saving/Tax_Saving.py @@ -1,5 +1,5 @@ T = int(input()) while T: - T-= 1 - X, Y = map(int, input().split()) - print(X - Y) \ No newline at end of file + T -= 1 + X, Y = map(int, input().split()) + print(X - Y) diff --git a/Codechef/Taxes/Taxes.py b/Codechef/Taxes/Taxes.py index 11a89096..f4dc182e 100644 --- a/Codechef/Taxes/Taxes.py +++ b/Codechef/Taxes/Taxes.py @@ -4,4 +4,4 @@ X = int(input()) if X > 100: X -= 10 - print(X) \ No newline at end of file + print(X) diff --git a/Codechef/Tckt_Fine/Tckt_Fine.py b/Codechef/Tckt_Fine/Tckt_Fine.py index 21e2c14e..9a087b19 100644 --- a/Codechef/Tckt_Fine/Tckt_Fine.py +++ b/Codechef/Tckt_Fine/Tckt_Fine.py @@ -2,4 +2,4 @@ while T: T -= 1 X, P, Q = map(int, input().split()) - print((P - Q) * X) \ No newline at end of file + print((P - Q) * X) diff --git a/Codechef/Tea/Tea.py b/Codechef/Tea/Tea.py index 5dd18ea1..1511de39 100644 --- a/Codechef/Tea/Tea.py +++ b/Codechef/Tea/Tea.py @@ -12,4 +12,4 @@ i += 1 if X <= temp_Y: print(temp_Z) - break \ No newline at end of file + break diff --git a/Codechef/Test_Avg/Test_Avg.py b/Codechef/Test_Avg/Test_Avg.py index b7986b38..fe0d5260 100644 --- a/Codechef/Test_Avg/Test_Avg.py +++ b/Codechef/Test_Avg/Test_Avg.py @@ -1,9 +1,10 @@ import math + T = int(input()) while T: T -= 1 A, B, C = map(int, input().split()) - if (((A + B)/2 >= 35) and ((A + C)/2 >= 35) and ((B + C)/2 >= 35)): + if ((A + B) / 2 >= 35) and ((A + C) / 2 >= 35) and ((B + C) / 2 >= 35): print("PASS") else: - print("FAIL") \ No newline at end of file + print("FAIL") diff --git a/Codechef/Three_Topics/Three_Topics.py b/Codechef/Three_Topics/Three_Topics.py index d5e932d7..5f3e5f72 100644 --- a/Codechef/Three_Topics/Three_Topics.py +++ b/Codechef/Three_Topics/Three_Topics.py @@ -3,4 +3,4 @@ if X[3] in X[0:3]: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Timely/Timely.py b/Codechef/Timely/Timely.py index 6e733c31..298cb9c5 100644 --- a/Codechef/Timely/Timely.py +++ b/Codechef/Timely/Timely.py @@ -5,4 +5,4 @@ if X >= 30: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/Todo_List/Todo_List.py b/Codechef/Todo_List/Todo_List.py index 0494f9f8..39e9f26a 100644 --- a/Codechef/Todo_List/Todo_List.py +++ b/Codechef/Todo_List/Todo_List.py @@ -4,4 +4,4 @@ N = int(input()) l = list(map(int, input().split())) num = [i for i in l if i >= 1000] - print(len(num)) \ No newline at end of file + print(len(num)) diff --git a/Codechef/Top_10/Top_10.py b/Codechef/Top_10/Top_10.py index 39bc36d2..d72d82dc 100644 --- a/Codechef/Top_10/Top_10.py +++ b/Codechef/Top_10/Top_10.py @@ -2,7 +2,7 @@ while T: T -= 1 X = int(input()) - if (X > 10): + if X > 10: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/Train_Chain/Train_Chain.py b/Codechef/Train_Chain/Train_Chain.py index 57a14cc5..d7ce99f6 100644 --- a/Codechef/Train_Chain/Train_Chain.py +++ b/Codechef/Train_Chain/Train_Chain.py @@ -7,7 +7,7 @@ B = l.count("B") AB = l.count("AB") O = l.count("O") - if (A >= B): + if A >= B: print(A + AB + O) else: - print(B + AB + O) \ No newline at end of file + print(B + AB + O) diff --git a/Codechef/Transform/Transform.py b/Codechef/Transform/Transform.py index 0acba052..d014427d 100644 --- a/Codechef/Transform/Transform.py +++ b/Codechef/Transform/Transform.py @@ -1,10 +1,10 @@ T = int(input()) while T: - T-= 1 + T -= 1 X = int(input()) if X % 3 == 0: print("NORMAL") elif X % 3 == 1: print("HUGE") else: - print("SMALL") \ No newline at end of file + print("SMALL") diff --git a/Codechef/Tri_Coin/Tri_Coin.py b/Codechef/Tri_Coin/Tri_Coin.py index 359d1e33..4877a702 100644 --- a/Codechef/Tri_Coin/Tri_Coin.py +++ b/Codechef/Tri_Coin/Tri_Coin.py @@ -8,4 +8,4 @@ max_height += 1 N -= max_height - print(max_height) \ No newline at end of file + print(max_height) diff --git a/Codechef/Tv_Disc/Tv_Disc.py b/Codechef/Tv_Disc/Tv_Disc.py index 1d670590..a4175ec3 100644 --- a/Codechef/Tv_Disc/Tv_Disc.py +++ b/Codechef/Tv_Disc/Tv_Disc.py @@ -9,4 +9,4 @@ elif B < A: print("Second") else: - print("Any") \ No newline at end of file + print("Any") diff --git a/Codechef/Two_Dish/Two_Dish.py b/Codechef/Two_Dish/Two_Dish.py index 84289d72..0cbf0aa6 100644 --- a/Codechef/Two_Dish/Two_Dish.py +++ b/Codechef/Two_Dish/Two_Dish.py @@ -2,8 +2,8 @@ while T: T -= 1 N, A, B, C = map(int, input().split()) - D = A + C + D = A + C if N <= D and N <= B: - print('YES') + print("YES") else: - print('NO') \ No newline at end of file + print("NO") diff --git a/Codechef/Tyre/Tyre.py b/Codechef/Tyre/Tyre.py index e7001960..01abc49c 100644 --- a/Codechef/Tyre/Tyre.py +++ b/Codechef/Tyre/Tyre.py @@ -2,4 +2,4 @@ while T: T -= 1 N, M = map(int, input().split()) - print((N * 2) + (M * 4)) \ No newline at end of file + print((N * 2) + (M * 4)) diff --git a/Codechef/Tyres/Tyres.py b/Codechef/Tyres/Tyres.py index 2a1cb40c..f02b6975 100644 --- a/Codechef/Tyres/Tyres.py +++ b/Codechef/Tyres/Tyres.py @@ -2,7 +2,7 @@ while T: T -= 1 N = int(input()) - if (N % 4 == 0): + if N % 4 == 0: print("NO") else: - print("YES") \ No newline at end of file + print("YES") diff --git a/Codechef/UWCOI20A/UWCOI20A.py b/Codechef/UWCOI20A/UWCOI20A.py index 6e3472b2..0cb439b9 100644 --- a/Codechef/UWCOI20A/UWCOI20A.py +++ b/Codechef/UWCOI20A/UWCOI20A.py @@ -5,4 +5,4 @@ H = [] for i in range(N): H.append(int(input())) - print(max(H)) \ No newline at end of file + print(max(H)) diff --git a/Codechef/VCS/VCS.py b/Codechef/VCS/VCS.py index 55838d6d..ad0beecc 100644 --- a/Codechef/VCS/VCS.py +++ b/Codechef/VCS/VCS.py @@ -11,4 +11,4 @@ elif i not in A and i not in B: second += 1 - print(str(first), " ", str(second)) \ No newline at end of file + print(str(first), " ", str(second)) diff --git a/Codechef/VOTERS/VOTERS.py b/Codechef/VOTERS/VOTERS.py index 8afdc729..783183ac 100644 --- a/Codechef/VOTERS/VOTERS.py +++ b/Codechef/VOTERS/VOTERS.py @@ -40,4 +40,4 @@ result = list(result) print(len(result)) result.sort() -[print(i) for i in result] \ No newline at end of file +[print(i) for i in result] diff --git a/Codechef/Valentine/Valentine.py b/Codechef/Valentine/Valentine.py index 6af12376..68b61341 100644 --- a/Codechef/Valentine/Valentine.py +++ b/Codechef/Valentine/Valentine.py @@ -1,5 +1,5 @@ T = int(input()) while T: - T-= 1 + T -= 1 X, Y = map(int, input().split()) - print(X//Y) \ No newline at end of file + print(X // Y) diff --git a/Codechef/Vdates/Vdates.py b/Codechef/Vdates/Vdates.py index 42ab3efb..689cb040 100644 --- a/Codechef/Vdates/Vdates.py +++ b/Codechef/Vdates/Vdates.py @@ -2,9 +2,9 @@ while T: T -= 1 D, L, R = map(int, input().split()) - if(D >= L and D <= R): + if D >= L and D <= R: print("Take second dose now") - elif(D > R): + elif D > R: print("Too Late") else: - print("Too Early") \ No newline at end of file + print("Too Early") diff --git a/Codechef/Visa/Visa.py b/Codechef/Visa/Visa.py index a3a3cbe1..bf95bf52 100644 --- a/Codechef/Visa/Visa.py +++ b/Codechef/Visa/Visa.py @@ -5,4 +5,4 @@ if x2 >= x1 and y2 >= y1 and z2 <= z1: print("YES") else: - print("NO") \ No newline at end of file + print("NO") diff --git a/Codechef/WATSCORE/WATSCORE.py b/Codechef/WATSCORE/WATSCORE.py index 3067fa4e..5caf5967 100644 --- a/Codechef/WATSCORE/WATSCORE.py +++ b/Codechef/WATSCORE/WATSCORE.py @@ -7,4 +7,4 @@ X, Y = map(int, input().split()) if X <= 8: S[X - 1] = max(S[X - 1], Y) - print(sum(S)) \ No newline at end of file + print(sum(S)) diff --git a/Codechef/Wait_Time/Wait_Time.py b/Codechef/Wait_Time/Wait_Time.py index 6c9a9977..fe038e11 100644 --- a/Codechef/Wait_Time/Wait_Time.py +++ b/Codechef/Wait_Time/Wait_Time.py @@ -2,4 +2,4 @@ while T: T -= 1 K, X = map(int, input().split()) - print((7 * K) - X) \ No newline at end of file + print((7 * K) - X) diff --git a/Codechef/Walk/Walk.py b/Codechef/Walk/Walk.py index 36cde65a..7745efe4 100644 --- a/Codechef/Walk/Walk.py +++ b/Codechef/Walk/Walk.py @@ -3,4 +3,4 @@ T -= 1 N = int(input()) W = list(map(int, input().split())) - print(max([W[i] + i for i in range(N)])) \ No newline at end of file + print(max([W[i] + i for i in range(N)])) diff --git a/Codechef/Waterflow/Waterflow.py b/Codechef/Waterflow/Waterflow.py index ef7020e0..a2acf1c2 100644 --- a/Codechef/Waterflow/Waterflow.py +++ b/Codechef/Waterflow/Waterflow.py @@ -10,4 +10,3 @@ print("Unfilled") if total == X: print("Filled") - diff --git a/Codechef/Waterreq/Waterreq.py b/Codechef/Waterreq/Waterreq.py index fac20246..d58f76e0 100644 --- a/Codechef/Waterreq/Waterreq.py +++ b/Codechef/Waterreq/Waterreq.py @@ -1,4 +1,4 @@ T = int(input()) while T: T -= 1 - print(2 * int(input())) \ No newline at end of file + print(2 * int(input())) diff --git a/Codechef/Wav2/Wav2.py b/Codechef/Wav2/Wav2.py index 942f133b..c63d433b 100644 --- a/Codechef/Wav2/Wav2.py +++ b/Codechef/Wav2/Wav2.py @@ -1,4 +1,5 @@ import bisect + N, Q = map(int, input().split()) B = sorted([int(x) for x in input().split()]) for _ in range(Q): @@ -6,7 +7,7 @@ c = bisect.bisect_left(B, x) if c < N and B[c] == x: print("0") - elif c == N or (N - 1 - c) %2 != 0: + elif c == N or (N - 1 - c) % 2 != 0: print("POSITIVE") else: - print("NEGATIVE") \ No newline at end of file + print("NEGATIVE") diff --git a/Codechef/Weight_BL/Weight_BL.py b/Codechef/Weight_BL/Weight_BL.py index b35e9b4a..08c72817 100644 --- a/Codechef/Weight_BL/Weight_BL.py +++ b/Codechef/Weight_BL/Weight_BL.py @@ -1,8 +1,8 @@ T = int(input()) while T: - T -= 1 + T -= 1 W1, W2, X1, X2, M = map(int, input().split()) - if(W2 >= W1 + (M * X1) and W2 <= W1 + (M * X2)): + if W2 >= W1 + (M * X1) and W2 <= W1 + (M * X2): print(1) else: - print(0) \ No newline at end of file + print(0) diff --git a/Codechef/Winnerr/Winnerr.py b/Codechef/Winnerr/Winnerr.py index 0d618817..46cb0e10 100644 --- a/Codechef/Winnerr/Winnerr.py +++ b/Codechef/Winnerr/Winnerr.py @@ -4,9 +4,9 @@ Pa, Pb, Qa, Qb = map(int, input().split()) max_P = max(Pa, Pb) max_Q = max(Qa, Qb) - if (max_P > max_Q): + if max_P > max_Q: print("Q") - elif (max_P < max_Q): + elif max_P < max_Q: print("P") else: - print("TIE") \ No newline at end of file + print("TIE") diff --git a/Codechef/Wordle/Wordle.py b/Codechef/Wordle/Wordle.py index 88fe4237..8759651e 100644 --- a/Codechef/Wordle/Wordle.py +++ b/Codechef/Wordle/Wordle.py @@ -6,6 +6,6 @@ T = input() for i in range(5): if S[i] == T[i]: - print("G", end = '') + print("G", end="") else: - print("B", end = '') \ No newline at end of file + print("B", end="") diff --git a/Codechef/Xystr/Xystr.py b/Codechef/Xystr/Xystr.py index 47365fe7..50a5c007 100644 --- a/Codechef/Xystr/Xystr.py +++ b/Codechef/Xystr/Xystr.py @@ -5,6 +5,6 @@ L = list(S) c = 0 L1 = S.count("xy") - L3 = S.replace("xy","") + L3 = S.replace("xy", "") L2 = L3.count("yx") - print(L1 + L2) \ No newline at end of file + print(L1 + L2) diff --git a/Codechef/ZCO14002/ZCO14002.py b/Codechef/ZCO14002/ZCO14002.py index 4c34246c..0b9ee324 100644 --- a/Codechef/ZCO14002/ZCO14002.py +++ b/Codechef/ZCO14002/ZCO14002.py @@ -4,4 +4,4 @@ for i in range(3, T): S = min(c[-3:]) + X[i] c.append(S) -print(min(c[-3:])) \ No newline at end of file +print(min(c[-3:])) diff --git a/Codechef/ZCO14004/ZCO14004.py b/Codechef/ZCO14004/ZCO14004.py index d18c51d0..c05e7cbf 100644 --- a/Codechef/ZCO14004/ZCO14004.py +++ b/Codechef/ZCO14004/ZCO14004.py @@ -6,4 +6,4 @@ res[2] = max(L[0] + L[2], L[1] + L[2], L[0] + L[1]) for i in range(3, N): res[i] = max(L[i] + L[i - 1] + res[i - 3], L[i] + res[i - 2], res[i - 1]) -print(max(res)) \ No newline at end of file +print(max(res)) diff --git a/Codechef/ZCO15001/ZCO15001.py b/Codechef/ZCO15001/ZCO15001.py index 0e422493..4d4ef9b8 100644 --- a/Codechef/ZCO15001/ZCO15001.py +++ b/Codechef/ZCO15001/ZCO15001.py @@ -1,19 +1,21 @@ def check_palindrome(seq): return seq == seq[::-1] + def min_pal_seq(N, sequence): - dp = [float('inf')] * (N + 1) + dp = [float("inf")] * (N + 1) dp[0] = 0 - + for i in range(1, N + 1): for j in range(i): if check_palindrome(sequence[j:i]): dp[i] = min(dp[i], dp[j] + 1) - + return dp[N] + N = int(input()) sequence = list(map(int, input().split())) result = min_pal_seq(N, sequence) -print(result) \ No newline at end of file +print(result) diff --git a/Codechef/Zero_String/Zero_String.py b/Codechef/Zero_String/Zero_String.py index e69cf36c..b1b8ffe9 100644 --- a/Codechef/Zero_String/Zero_String.py +++ b/Codechef/Zero_String/Zero_String.py @@ -1,7 +1,7 @@ T = int(input()) while T: - + T -= 1 N = int(input()) S = input() @@ -11,4 +11,4 @@ if c1 >= c2: print(c2) else: - print(c1 + 1) \ No newline at end of file + print(c1 + 1) diff --git a/Leetcode/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py b/Leetcode/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py index 519f416b..8a99b971 100644 --- a/Leetcode/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py +++ b/Leetcode/Find_Closest_Number_to_Zero/Find_Closest_Number_to_Zero.py @@ -25,4 +25,4 @@ def findClosestNumber(self, nums): diff1, diff2 = min_pos, 0 - max_neg if diff1 < diff2: return min_pos - return max_neg \ No newline at end of file + return max_neg diff --git a/Leetcode/Merge_Strings_Alternately/Merge_Strings_Alternately.py b/Leetcode/Merge_Strings_Alternately/Merge_Strings_Alternately.py index 78a61128..c8433556 100644 --- a/Leetcode/Merge_Strings_Alternately/Merge_Strings_Alternately.py +++ b/Leetcode/Merge_Strings_Alternately/Merge_Strings_Alternately.py @@ -10,12 +10,12 @@ def mergeAlternately(self, word1, word2): if len(word1) < len(word2): for i in range(len(word1)): mergedword += word1[i] + word2[i] - mergedword += word2[len(word1):len(word2)] + mergedword += word2[len(word1) : len(word2)] return mergedword elif len(word1) > len(word2): for i in range(len(word2)): mergedword += word1[i] + word2[i] - mergedword += word1[len(word2):len(word1)] + mergedword += word1[len(word2) : len(word1)] return mergedword else: for i in range(len(word2)): @@ -31,4 +31,4 @@ def mergeAlternately(self, word1, word2): # if i < len(word2): # result.append(word2[i]) # i += 1 - # return ''.join(result) \ No newline at end of file + # return ''.join(result) diff --git a/Leetcode/roman_to_integer/roman_to_integer.py b/Leetcode/roman_to_integer/roman_to_integer.py index 4e3d86aa..247dc87d 100644 --- a/Leetcode/roman_to_integer/roman_to_integer.py +++ b/Leetcode/roman_to_integer/roman_to_integer.py @@ -4,15 +4,7 @@ def romanToInt(self, s): :type s: str :rtype: int """ - d = { - "I" : 1, - "V" : 5, - "X" : 10, - 'L' : 50, - "C" : 100, - 'D' : 500, - "M": 1000 - } + d = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} # print(d.keys(), "\n", d.values()) summ = 0 i = 0 @@ -24,4 +16,3 @@ def romanToInt(self, s): summ += d[s[i]] i += 1 return summ - \ No newline at end of file