diff --git "a/valid.csv" "b/valid.csv" new file mode 100644--- /dev/null +++ "b/valid.csv" @@ -0,0 +1,153078 @@ +problem_id,submission_id,status,code +p02957,s967596218,Wrong Answer,"a,b = map(int, input().split()) +print((a+b)/2) if ((a+b)%2 == 0)&(a!=0)&(b!=0) else print(""IMPOSSIBLE"")" +p03796,s776134701,Accepted,"n = int(input()) + +ans = 1 +for i in range(n): + ans = (ans * (i + 1)) % (10**9 + 7) +print(ans)" +p03309,s655762857,Accepted,"n = int(input().strip()) +a = list(map(int, input().split())) +b = [(a[i] - (i + 1)) for i in range(n)] +b.sort() +mid = b[n // 2] +ans = 0 +for i in range(n): + ans += abs(b[i] - mid) +print(ans) +" +p03860,s440347640,Wrong Answer,"xs = input().split() + +print(""A""+xs[2][0]+""C"")" +p03761,s516330622,Wrong Answer,"from collections import defaultdict + +N = int(input()) +S = [input() for _ in range(N)] + +d = defaultdict(lambda: N+1) + +for i in range(N): + for c in range(ord(""a""), ord(""z"")+1): + d[chr(c)] = min(d[chr(c)], S[i].count(chr(c))) + +ans = """" +for key, value in d.items(): + ans += key * value + +print(ans)" +p02918,s639685253,Accepted,"n, k = map(int, input().split()) +S = str(input()) +hap = 0 +for i in range(1, len(S)): + if S[i-1] == S[i]: + hap += 1 +ans = min(hap + k*2, n-1) +print(ans)" +p03644,s869953477,Accepted,"n=int(input()) +for i in range (0,8): + if 2**i<=n: + pass + else: + print(2**(i-1)) + break" +p03419,s748697785,Accepted,"N, M = map(int, input().split()) +print(max(N-2, N%2) * max(M-2, M%2))" +p02687,s611090748,Accepted,"s = input() +if s == 'ABC': + print('ARC') +else: + print('ABC')" +p03854,s130515449,Wrong Answer,"import re + +S = input() + +list_string = ['dream', 'dreamer', 'erase', 'eraser'] +regex = r'(dream(er)?eraser?)+|(eraser?dream(er)?)+|(((dream(er)?)|(eraser?))+)' + +def check(list_string, regex, S): + while S: + if re.search(regex, S): + S = re.sub(regex, '', S) + + else: + return 'NO' + return 'YES' + +print(check(list_string, regex, S))" +p02583,s007748597,Wrong Answer,"import itertools + +n = int(input()) + +li = list(map(int,input().split())) + +li = list(itertools.combinations(li, 3)) + +# print(li) +count = 0 + +for i in li: + print(i) + amari = sum(i) - max(i) + if amari > max(i): + if len(set(i)) == 3: + count += 1 + +print(count) + + +" +p03481,s011556476,Wrong Answer,"import math +import numpy + + +x,y = map(int,input().split("" "")) + +n = int(numpy.log2(numpy.longdouble(y/x))) + +print(n+1) +" +p02933,s802197618,Accepted,"a = int(input()) +s = input() + +if a < 3200: + print('red') +else: + print(s)" +p02823,s915933695,Accepted,"n, a, b = map(int, input().split()) +dist = abs(a-b)-1 +if dist % 2 != 0: + ans = dist//2+1 +else: + dist -= 1 + ans = min(a+dist//2+1, n-b+1+dist//2+1) + +print(ans) +" +p02766,s512245404,Accepted,"n,k=map(int, input().split()) +ans=1 +while 1: + n//=k + if n>0: ans+=1 + else: break +print(ans)" +p03387,s856770896,Accepted,"a = sorted(list(map(int, input().split("" "")))) +count = 0 +a[0] += a[2] - a[1] +count += a[2] - a[1] + +if (a[2] - a[0]) % 2 == 0: + print(count + ((a[2] - a[0]) // 2)) +else: + print(count + ((a[2] - a[0]) // 2) + 2)" +p02829,s061287095,Accepted,"a = int(input()) +b = int(input()) + +c = 6 - a - b +print(c) +" +p02546,s010607320,Wrong Answer,"s=input() +if s[-1]==s: + s+='es' +else: + s+='s' +print(s)" +p03761,s339882020,Accepted,"n = int(input()) +ns = list(list(input()) for i in range(n)) +ns_set = set() +for i in range(n): + ns_set |= set(ns[i]) +from collections import defaultdict +dic = defaultdict(lambda : 50) +for i in range(n): + for s in ns_set: + if s in ns[i]: + dic[s] = min(dic[s], ns[i].count(s)) + else: + dic[s] = 0 +result = '' +for key, value in sorted(dic.items(), key=lambda x: x[0]): + result += key*value +print(result)" +p02988,s479442651,Wrong Answer,"n=int(input()) +p=list(map(int,input().split())) + +c=0 +for i in range(n-1): + if p[i-1]<=p[i]<=p[i+1] or p[i+1]<=p[i]<=p[i-1]: + c+=1 +print(c) +" +p03679,s638275529,Wrong Answer,"x, a, b = map(int, input().split()) +if b - a <= 0: + print(""delicious"") +elif b - a < x and 0 < b - a: + print(""safe"") +else: + print(""dangerous"") +" +p03427,s090842171,Wrong Answer,"n = input() + +if set(list(n)) == {'9'}: + print(len(list(n))*9) + exit() + +tmp = '' +for i in range(1,len(n)): + if n[i] == '9': + tmp += n[i-1] + else: + tmp += str(int(n[i-1])-1) + '9'*(len(n)-i) + break +else: + tmp += '9' + +ans=0 +for i in range(len(tmp)): + ans += int(tmp[i]) + +print(ans) +" +p03592,s646632326,Accepted,"N,M,K = map(int, input().split()) +for i in range(N+1): + b = i * M + for j in range(M+1): + b -= i + b += N-i + if b == K: + print('Yes') + exit() +print('No') +" +p02814,s863558818,Wrong Answer,"import functools +N,M = map(int,input().split()) +A = [int(i)//2 for i in input().split()] + +def euclid(a,b): + if b==0: + return a + else: + return euclid(b,a%b) + +def mul(a,b): + return a*b//euclid(a,b) + +def lcm(S): + + return functools.reduce(mul,S) + +ans = M//lcm(A) +ans = (ans+1)//2 +print(ans)" +p02831,s163671649,Wrong Answer,"a, b = map(int, input().split()) +ans = 0 +if a > b: + for i in range(b, a + 1): + if b * i % a == 0: + ans = b * i + break +else: + for i in range(a, b + 1): + if a * i % b == 0: + ans = a * i + break +print(ans) +" +p03136,s066983810,Accepted,"input() +L = list(map(int, input().split())) +print(""Yes"" if sum(L) > 2*max(L) else ""No"")" +p02641,s792287075,Accepted," +def resolve(): + X, N = map(int, input().split()) + if N == 0: + print(X) + return + A = set(map(int, input().split())) + dic = {} + for i in range(-10, 110): + if i not in A: + dic[i] = abs(X-i) + + sorted_A = sorted(dic.items(), key=lambda x:(x[1], x[0])) + print(sorted_A[0][0]) + +if __name__ == ""__main__"": + resolve()" +p03331,s020765875,Accepted,"n = int(input()) +li = [] +for a in range(1, n): + b = n - a + a_sum = sum([int(x) for x in str(a)]) + b_sum = sum([int(y) for y in str(b)]) + total_sum = a_sum + b_sum + li.append(total_sum) +print(min(li))" +p03419,s379387709,Accepted,"n, m=map(int, input().split()) + +if n==1 and m==1: + print(1) +elif n==1 and m!=1: + print(m-2) +elif n!=1 and m==1: + print(n-2) +else: + ans = (m-2)*(n-2) + print(ans)" +p02688,s360726408,Accepted,"n,k=map(int,input().split());s=set(range(1,-~n)) +for _ in range(k): + input();s-=set(map(int,input().split())) +print(len(s))" +p03592,s928018048,Accepted,"N,M,K=map(int,input().split()) + +for i in range(N+1): + for j in range(M+1): + if i==0 or j==0: + x=N*j+M*i + if x==K: + print(""Yes"") + exit() + x=N*j+M*i-(i*j)-i*j + #print(str(i)+"" ""+str(j)) + #print(x) + if x==K: + print(""Yes"") + exit() +print(""No"")" +p02787,s487093292,Accepted,"# -*- coding: utf-8 -*- +H, N = map(int, input().split(' ')) +nums = [float('inf') for _ in range(H+1)] +nums[0] = 0 + +for _ in range(N): + a, b = map(int, input().split(' ')) + for i in range(H + 1): + j = min(H, i+a) + nums[j] = min(nums[j], nums[i] + b) + +print(nums[H])" +p03073,s792432661,Accepted,"S = input() +N = len(S) + +ans1 = """".join([""1"" if i%2 == 0 else ""0"" for i in range(N)]) +ans2 = """".join([""0"" if i%2 == 0 else ""1"" for i in range(N)]) + +print(min(bin(int(S, 2)^int(ans1, 2)).count(""1""), bin(int(S, 2)^int(ans2, 2)).count(""1"")))" +p03126,s189725700,Accepted,"N, M = map(int, input().split()) +ans = set(range(1, M+1)) +for i in range(N): + K, *A = map(int, input().split()) + ans = ans & set(A) +print(len(ans))" +p02689,s322782570,Wrong Answer,"N, M = (int(x) for x in input().split()) +H = [int(x) for x in input().split()] + +high = set() +low = set() +lonely = set() + +for i in range(M): + i1, i2 = [int(x) for x in input().split()] + if H[i1 - 1] != H[i2 - 1]: + high.add(i2) + low.add(i1) + lonely.add(i1) + lonely.add(i2) + +result = len((high - low)) + (N - len(lonely))" +p02848,s841745615,Accepted,"import sys +import string +N = int(input()) +S = input() +s = list(S) +array = string.ascii_uppercase + +for I in s: + if array.index(I) + N <= 25: + print(array[array.index(I) + N],end='') + else: + print(array[(array.index(I) + N) - 26],end='')" +p02818,s905437245,Wrong Answer,"#スペース区切りの整数の入力 +A, B ,K = map(int, input().split()) + +if(K>A): + nokori = K - A + ans = B - nokori + print(""0"",ans) +else: + nokori = A - K + print(nokori,B)" +p03548,s318205153,Accepted,"x, y, z = map(int, input().split()) +print((x - z) // (z + y))" +p03001,s073019917,Wrong Answer,"W,H,x,y=map(int,input().split()) + +a=[] +b=[] +judge=0 + +a.append(min(x,W-x)*H) +a.append(min(y,H-y)*W) +b.append(max(x,W-x)*H) +b.append(max(y,H-y)*W) + +if max(a) in a and b: + judge=1 + +print(max(a),judge)" +p03137,s406640004,Wrong Answer,"def main(): + # n = int(input()) + n, m = map(int, input().split()) + x = list(map(int, input().split())) + # s = input() + # h = [int(input()) for _ in range(n)] + + x.sort() + + subs = [] + + for i in range(1, m): + subs.append(abs(x[i]-x[i-1])) + + subs.sort() + print(sum(subs[0:m-n])) + + +if __name__ == '__main__': + main() +" +p03377,s092484883,Wrong Answer,"A, B, X = map(int, input().split()) + +if X <= A + B - 1 and X >= A: + print(""Yes"") +else: + print(""No"")" +p02994,s598297947,Accepted,"N,L = map(int,input().split()) +R = L+N-1 +if L <= 0 <= R: + print(sum(range(L,R+1))) +elif L > 0: + print(sum(range(L+1,R+1))) +else: + print(sum(range(L,R))) +" +p02909,s883822689,Accepted,"S=input() + +weather={""Sunny"":""Cloudy"",""Rainy"":""Sunny"",""Cloudy"":""Rainy""} + +print(weather[S])" +p03817,s728797255,Accepted,"x = int(input()) +ans = x//11*2 + (x%11+5)//6 + +print(ans)" +p03632,s041628861,Accepted,"import sys +input = sys.stdin.readline().strip +a,b,c,d=map(int,input().split()) +if bb: + print('Alice') +elif aM: + up=1 + A[i]=M + else: + up=0 + break + if up==1: break +print(ans)" +p02777,s710829185,Accepted,"S, T = input().split() +A,B = map(int,input().split()) +U = input() +if U == S: + A -= 1 + print(A,B) +else: + B -= 1 + print(A,B)" +p02754,s619615894,Accepted,"N, A, B = map(int, input().split()) +a = N // (A + B) +b = N % (A + B) +if b >= A: + print(a*A + A) +else: + print(a*A + b) +" +p03785,s225335810,Accepted,"N, C, K = map(int, input().split()) +T = [] +for i in range(N): + t = int(input()) + T.append(t) +T.sort() + +cnt = 0 +res = 1 +time = T[0] +for i in range(N-1): + cnt += 1 + if cnt == C or time + K < T[i+1]: + res += 1 + cnt = 0 + time = T[i+1] +print(res)" +p03556,s962743052,Accepted,"N = int(input()) +print(int(N**0.5)**2)" +p03673,s689346962,Accepted,"n = int(input()) +al = list(map(int, input().split())) + +left = [] +right = [] + +for i in range(n): + if i % 2 == 0: + right.append(al[i]) + else: + left.append(al[i]) + +if n % 2 == 0: + ans = left[::-1] + right +else: + ans = right[::-1] + left + +print(*ans, sep=' ') +" +p02801,s675001095,Accepted,print(chr(ord(input())+1)) +p03637,s804119602,Wrong Answer,"N = int(input()) +*a, = map(int, input().split()) +two, four, no = 0, 0, 0 +for i in range(N): + if a[i] % 4 == 0: + four += 1 + elif a[i] % 2 == 0: + two += 1 + else: + no += 1 + +ok = four == no or (four+two) == N +ok = ok and ((four+no) == N and abs(four-no) <= 1) +if ok: + print(""Yes"") +else: + print(""No"") +" +p03779,s444896171,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + X = int(readline()) + + for i in range(X + 1): + if i * (i + 1) // 2 >= X: + ans = i + break + + print(ans) + return + + +if __name__ == '__main__': + main() +" +p02971,s384282394,Accepted,"N=int(input()) +A=[int(input()) for i in range(N)] +maximum=max(A) +maximum2=sorted(A)[-2] +for a in A: + if a!=maximum: + print(maximum) + else: + print(maximum2) +" +p02783,s889562848,Accepted,"s=list(map(int,input().split())) +a=s[0]//s[1] +if s[0]%s[1]==0: + print(int(a)) +else: + print(int(a+1)) + " +p03163,s716154594,Wrong Answer,"n, w = map(int, input().split()) +wts = [] + +for i in range(n): + wts.append(list(map(int, input().split()))) + +wts.sort() +dp = [[0]*(w+1) for i in range(n)] +dp[0][wts[0][0]] = wts[0][1] + +for i in range(1, n): + for j in range(1+w): + if j >= wts[i][0]: + dp[i][j] = max(dp[i-1][j], wts[i][1]+dp[i-1][j-wts[i][0]]) + else: + dp[i][j] += dp[i-1][j] + +print(dp[-1][-1])" +p02995,s124421156,Accepted,"import sys +import os +import fractions + +MOD = 10 ** 9 + 7 + + +def lcm(x, y): + return (x * y) // fractions.gcd(x, y) + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + A, B, C, D = list(map(int, sys.stdin.readline().split())) + E = B - A + 1 + + ret = 0 + ret += B // C + ret += B // D + ret -= (A - 1) // C + ret -= (A - 1) // D + ret -= B // lcm(C, D) + ret += (A-1) // lcm(C, D) + print(E - ret) + + +if __name__ == '__main__': + main() +" +p02952,s512403318,Accepted,"import math +n = int(input()) +ans = 0 +for i in range(1,n+1): + if int(math.log10(i)) % 2 == 0: + ans += 1 +print(ans)" +p02854,s900089489,Accepted,"import numpy as np + +N = int(input()) +A = list(map(int, input().split())) + +r = sum(A) +l = 0 + +ans = np.inf +for ai in A: + l += ai + r -= ai + ans = min(np.abs(r-l), ans) + +print(ans)" +p03351,s646625426,Accepted,"def iim():return map(int,input().split()) + +a,b,c,d = iim() + +if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d): + print('Yes') +else: + print('No')" +p03457,s701015673,Wrong Answer,"import sys +input = sys.stdin.readline +n=int(input()) + +t1,x1,y1=0,0,0 +flg=True +for i in range(n): + t2,x2,y2=map(int,input().split()) + l=abs(x2-x1)+abs(y2-y1) + print(l,t2-t1) + if l<=(t2-t1) and (t2-t1-l-1)%2==0: + t1,x1,y1=t2,x2,y2 + else: + flg=False + break +print(""Yes"" if flg else ""No"") +" +p02742,s120876045,Accepted,"H,W = map(int,input().split()) +if H == 1 or W == 1: print(1) +elif H * W % 2 == 1: print((H * W + 1)//2) +else: print(H * W // 2) +" +p03264,s510411615,Accepted,"k = int(input()) + +print((k//2) ** 2 if k % 2 == 0 else ((k//2)+1) * (k//2)) +" +p02911,s241728069,Accepted,"N, K, Q = map(int, input().split()) +A = [int(input()) for i in range(Q)] +P = [0] * N +for i in range(Q): + P[A[i] - 1] += 1 +for i in range(N): + if (K - (Q - P[i]) <= 0): print('No') + else: print('Yes') +" +p03607,s811688614,Wrong Answer,"N = int(input()) +A = [int(input()) for _ in range(N)] +A.sort() +ans = 0 +a = A[0] +n = 0 +for i in range(N): + if a == A[i]: + n += 1 + else: + if n % 2 == 1: + ans += 1 + n = 1 + a = A[i] + #print(A[i],""1"",n,n%2,ans) +if A[-1] == A[-2] and n % 2 == 1: + ans += 1 +print(ans)" +p02577,s052641011,Accepted,"N = input() +if sum(map(int, list(N))) % 9 == 0: + print(""Yes"") +else: + print(""No"") +" +p03327,s472192913,Accepted,"n = int(input()) +if n<1000: + print(""ABC"") +else: + print(""ABD"") +" +p02629,s878237478,Accepted,"n = int(input()) + +alpha = 'abcdefghijklmnopqrstuvwxyz' + +out = '' +while n != 0: + out = alpha[(n % 26) - 1] + out + n = int((n-1) // 26) +print(out)" +p03693,s791089862,Wrong Answer,"S_list = list(map(int,input().split())) + +r, g, b = S_list[0], S_list[1], S_list[2] +if (100 * r + 10 * g + b) % 4 == 0 : + result = ""Yes"" +else: + result = ""No"" +print(result) +" +p03814,s921564122,Accepted,"s = input() +a = s.index('A') +z = s[::-1].index('Z') +print(len(s)-a-z)" +p04043,s233840121,Accepted,"a = list(map(int, input().split())) +a.sort() +if a == [5, 5, 7]: + print(""YES"") +else: + print(""NO"") +" +p03264,s812866328,Wrong Answer,"a=int(input()) +print((a-1)*a)" +p03309,s375224978,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = [(A[i]-(i+1)) for i in range(N)] + +if N == 1: + print(0) + exit() +B = sorted(B, reverse=True) +cs = B[:] +for i in range(N-1): + cs[i+1] += cs[i] + +ans = float('inf') +tmp = 0 +for b in B: + tmp += abs(b) +ans = min(ans, tmp) + +for i in range(1, N): + b = B[i] + left = b*(i)-cs[i-1] + right = -1*(b*(N-i-1)-(cs[-1]-cs[i])) + ans = min(ans, abs(left)+abs(right)) +print(ans)" +p03286,s265433843,Accepted,"n=int(input()) +s='' +if n==0: + print(0) + exit() +while n!=0: + m=n%2 + s+=str(m) + n=(n-m)//-2 +print(int(s[::-1])) +" +p02660,s436127553,Accepted,"from collections import defaultdict +n = int(input()) + +d = defaultdict(int) + +i = 2 +while i * i <= n: + while n % i == 0: + d[i] += 1 + n /= i + i += 1 +if n != 1: + d[n] += 1 + +ans = 0 +for v in d.values(): + # x * (x + 1) // 2 <= vとなる最大のx + x = 0 + while (x + 1) * (x + 2) // 2 <= v: + x += 1 + ans += x +print(ans) +" +p03252,s574612503,Accepted,"import sys +from collections import Counter + + +def main(): + s = input() + t = input() + s_count = [0]*26 + t_count = [0]*26 + for i in range(ord(""a""), ord(""z"")+1): + s_count[i-97] = s.count(chr(i)) + t_count[i-97] = t.count(chr(i)) + s_count.sort() + t_count.sort() + if s_count == t_count: + print(""Yes"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main() +" +p02983,s877323556,Accepted,"L,R = map(int,input().split()) +if R-L+1 >= 2019: + print(0) + exit() +R %= 2019 +L %= 2019 +if R <= L: + print(0) + exit() +ans = 2020 +for i in range(L,R): + for j in range(i+1,R+1): + ans = min(ans,(i*j)%2019) +print(ans)" +p02779,s244274143,Accepted,"N=int(input()) +A=list(map(int,input().split())) +if len(A)!=len(list(set(A))): + print(""NO"") +else: + print(""YES"")" +p02742,s911563127,Wrong Answer,"h, w = map(int, input().split()) +print(h*w//2 if h*w%2==0 else h*w//2+1)" +p02987,s224833275,Accepted,"S = list(input()) +S.sort() +if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]: + print(""Yes"") +else: + print(""No"") +" +p03696,s263879771,Accepted,"n = int(input()) +data = [c for c in input()] +stack = [] +ans = '' +for c in data: + if c == '(': + stack.append(c) + ans += '(' + else: + if len(stack) == 0 or stack.pop() != '(': + ans = '(' + ans + c + else: + ans += ')' +ans += ')'*len(stack) + +print(ans)" +p03282,s526963983,Wrong Answer,"S = list(map(int, input())) +K = int(input()) +#num = [pow(S[i], 10**12) for i in range(len(S))] +if len(S) == 1: + print(S[0]) + exit() +if S[0] == 1: + print(S[1]) +else: + print(S[0])" +p02948,s832150713,Accepted,"from heapq import* +(N,M),*t=[map(int,s.split())for s in open(0)] +q=[0]*10**5 +v=[[]for _ in q] +z=0 +for a,b in t:v[a-1]+=b, +for i in v[:M]: + for j in i:heappush(q,-j) + z-=heappop(q) +print(z)" +p02873,s825136228,Accepted,"from functools import reduce +from fractions import gcd +import math +import bisect +import itertools +import sys +sys.setrecursionlimit(10**7) +input = sys.stdin.readline +INF = float(""inf"") + + +def main(): + S = input() + + N = len(S) + 1 + a = [0] * N + for i in range(N-1): + if S[i] == ""<"": + a[i+1] = max(a[i+1], a[i]+1) + for i in reversed(range(N-1)): + if S[i] == "">"": + a[i] = max(a[i], a[i+1]+1) + + print(sum(a)) + + +if __name__ == '__main__': + main()" +p02744,s176671193,Wrong Answer,"import copy +n = int(input()) + +def dfs(str_list, now): + str_list.append(chr(now)) + if len(str_list) == n: + print(''.join(str_list)) + else: + chr_a = ord('a') + for c in range(chr_a, now + 2, 1): + str_list_cp = copy.deepcopy(str_list) + dfs(str_list_cp, c) + +dfs([], ord('a'))" +p02642,s791778003,Accepted,"# D - Not Divisible +from collections import deque +N = int(input()) +A = list(map(int,input().split())) +A.sort() +A = deque(A) +B = [0]*(10**6+1) +ans = 0 +for _ in range(N): + x = A.popleft() + if B[x]==0: + ans += 1 + B[x] = 2 + tmp = 2*x + while tmp<=10**6: + B[tmp] = 1 + tmp += x + elif B[x]==2: + B[x] = 1 + ans -= 1 +print(ans)" +p03475,s510776271,Accepted,"N = int(input()) +CSF = [list(map(int, input().split())) for i in range(N - 1)] +ans = [] +for i in range(N - 1): + temp = 0 + for j in range(i, N - 1): + c, s, f = CSF[j][0], CSF[j][1], CSF[j][2] + if temp <= s: + temp += s - temp + temp += temp % f + else: + temp += (f - ((temp - s) % f)) % f + temp += c + ans.append(temp) +for i in range(N - 1): + print(ans[i]) +print(0) +" +p03860,s655971044,Accepted,"a, b, c = input().split() +print(a[0]+b[0]+c[0])" +p02775,s056849286,Accepted,"S = input()[::-1] +l = len(S) +dp = [[0]*2 for _ in range(l+1)] +for i in range(l): + dp[i+1][0]=min(dp[i][0]+int(S[i]),dp[i][1]+int(S[i])+1) + if i!=0: + dp[i+1][1]=min(dp[i][0]+10-int(S[i]),dp[i][1]+10-(int(S[i])+1)) + else: + dp[i+1][1]=dp[i][0]+10-int(S[i]) +print(min(dp[-1][0],dp[-1][1]+1))" +p03319,s104780919,Accepted,"N,K=map(int,input().split()) +if((N-K)%(K-1)==0): + print((N-K)//(K-1)+1) +else: + print((N-K)//(K-1)+2)" +p02622,s319833474,Accepted,"S = str(input()) +T = str(input()) + +count = 0 +for i in range(len(S)): + if S[i] != T[i]: + count += 1 +print(count)" +p03814,s805136742,Accepted,"m = input() + +A = m.index(""A"") +Z = m.rfind(""Z"") + +print(Z-A+1)" +p02777,s908759222,Accepted,"s, t = input().split() +a, b = map(int, input().split()) +u = input() +if u == s: + print(a - 1, b) +else: + print(a, b-1)" +p02713,s726123883,Accepted,"import itertools +import math +K = [i for i in range(1, int(input()) + 1)] +numbers = itertools.combinations_with_replacement(K, 3) + +sum_gcd = 0 +for i in numbers: + a = math.gcd(i[0], i[1]) + b = math.gcd(a, i[2]) + + if i[0] != i[1] != i[2]: + sum_gcd += b * 6 + elif i[0] == i[1] == i[2]: + sum_gcd += b + else: + sum_gcd += b * 3 + +print(sum_gcd)" +p02555,s723918388,Wrong Answer,"s=int(input()) +INF=10**9 + 7 + +dp=[0]*(s+1) +dp[0]=1 + +for i in range(1,s+1): #敷居の数 + for j in range(0,(i-3)+1): + dp[i]+=dp[j] + dp[i]%=INF + print(dp) + +print(dp[-1])" +p03434,s653718230,Accepted,"def main(): + target_num = input() + target_list = list(map(int, input().split())) + + target_list.sort(reverse=True) + + result_a = 0 + result_b = 0 + a_flg = True + for target in target_list: + if a_flg: + result_a += int(target) + a_flg = False + else: + result_b += int(target) + a_flg = True + + print(result_a - result_b) + + +if __name__ == '__main__': + main() +" +p03221,s148347518,Accepted,"n,m=map(int,input().split()) +PY=[list(map(int,input().split())) for _ in range(m)] + +ypi=[[y,p,i] for i,(p,y) in enumerate(PY)] #順番iはp,yより前に来る +ypi.sort() + +from collections import defaultdict + +d=defaultdict(int) +ans=[0]*m + +for y,p,i in ypi: + d[p]+=1 + ans[i]=str(p).zfill(6)+str(d[p]).zfill(6) + +print(*ans,sep=""\n"")" +p02754,s332186327,Accepted,"n,a,b = input().split() +n,a,b = [int(n), int(a), int(b)] +num = n // (a + b) +ber = n % (a + b) +ans = a * num + +if ber > a: + ans += a +else: + ans += ber + +print(ans)" +p02615,s785644508,Wrong Answer,"def main(): + import sys + def input(): return sys.stdin.readline().rstrip() + n = int(input()) + a = list(map(int, input().split())) + a = sorted(a)[::-1] + if n %2== 0: + print(a[0]+sum(a[1:n//2])) + else: + print(a[0]+sum(a[1:n//2+1])*2) + + + +if __name__ == '__main__': + main()" +p02664,s691537692,Accepted,"t = input() +t = [s for s in t] +for i in range(len(t)): + if t[i]=='?': + t[i] = 'D' +ans = ''.join(t) +print(ans)" +p03035,s493425284,Accepted,"A, B= map(int,input().split()) + +if A <6: + print(0) +elif A>12: + print(B) +else: + print(int(B/2))" +p03150,s903228605,Accepted,"s=input() +if ""keyence""==s:exit(print(""YES"")) +for i in range(10): + for j in range(i,len(s)): + if s[:i]+s[j:]==""keyence"":exit(print(""YES"")) +print(""NO"") +" +p03437,s125946348,Accepted,"X,Y = map(int, input().split()) + +if X%Y == 0: + print(""-1"") + +else: + print(X) + " +p02705,s836641964,Accepted,"r=int(input()) +pi=3.14159265 +print(r*2*pi)" +p03623,s625939160,Accepted,"#!/usr/bin/env python3 + +x, a, b = map(int, input().split()) + +if abs(x-a) < abs(x-b): + print(""A"") +else: + print(""B"")" +p03286,s432159605,Accepted,"N = int(input()) +ans = [] if N != 0 else [0] +while N: + ans.append(-(N % -2)) + N = -(N // 2) +print("""".join(map(str, ans[::-1]))) +" +p02947,s368956865,Accepted,"from collections import Counter + +n = int(input()) +l = list("""") +for i in range(n): + s = ''.join(sorted(input())) + l.append(s) +c = Counter(l) +c = c.most_common() +ans = 0 +for i in range(len(c)): + x = c[i][1] - 1 + while x > 0: + ans += x + x -= 1 +print(ans)" +p02631,s159173580,Accepted,"n = int(input()) +a = list(map(int,input().split())) +an = [0 for i in range(30)] +ans = [] +for i in a: + c = bin(i) + d = len(c)-1 + count = 0 + while c[d] != 'b': + if c[d] == '1': + an[count] += 1 + an[count] %= 2 + d-=1 + count+=1 +tmp = 0 +for i in range(len(an)): + if an[i] == 1: + tmp += 2**i +for i in a: + ans.append(i ^ tmp) +print(*ans)" +p03324,s784275365,Wrong Answer,"d,n = map(int,input().split()) + +print(n*100**d)" +p03612,s186145435,Accepted,"def main(): + n = int(input()) + p = [int(pn) for pn in input().split()] + ans = 0 + is_changed = False + for i in range(n): + if is_changed: + is_changed = False + elif p[i] == i + 1: + is_changed = True + ans += 1 + print(ans) + + +if __name__ == '__main__': + main() +" +p02951,s823481002,Accepted,"a, b, c = map(int, input().split()) +print(c - (a - b)) if (c - (a - b)) > 0 else print(0) " +p03293,s989302666,Accepted,"s = input() +t = input() + +for i in range(len(s)): + ss = s[i:] + s[:i] + if ss == t: + print('Yes') + exit(0) +print('No')" +p03387,s745240838,Wrong Answer,"a,b,c = map(int,input().split()) + +pa=a%2 +pb=b%2 +pc=c%2 + +cnt = 0 + +if not(pa==pb and pb==pc): + cnt = 1 + +ans = cnt + (3*max(max(a,b),c)-(a+b+c))/2 +print(int(ans))" +p02832,s376950034,Accepted,"N = int(input()) +a = list(map(int, input().split())) + +sx = 1 +delcnt = 0 +for i in range(N): + if a[i] == sx: + sx = sx + 1 + else: + delcnt = delcnt + 1 + +if sx > 1: + print(delcnt) +else: + print(-1) +" +p02953,s148981238,Accepted,"from collections import Counter,defaultdict,deque +from heapq import heappop,heappush,heapify +from bisect import bisect_left,bisect_right +import sys,math,itertools,fractions,pprint +sys.setrecursionlimit(10**8) +mod = 10**9+7 +INF = float('inf') +def inp(): return int(sys.stdin.readline()) +def inpl(): return list(map(int, sys.stdin.readline().split())) + +n = inp() +a = inpl() +a[0] -= 1 +for i in range(1,n): + if a[i] > a[i-1]: + a[i] -= 1 + elif a[i] < a[i-1]: + print('No') + break +else: + print('Yes') " +p02778,s898037419,Accepted,"print(""x""*len(input())) +" +p03612,s484413568,Wrong Answer,"N = int(input()) +p = list(map(int, input().split())) +li = range(1, N+1) +count = 0 +for i in range(len(p) - 1): + if p[i] == li[i]: + p[i], p[i + 1] = p[i + 1], p[i] + count += 1 +print(count)" +p03838,s280961751,Accepted,"x,y=map(int,input().split()) +if 0<=x= 13: + print(b) +elif a >= 6: + print(b // 2) +else: + print(0) +" +p02687,s728352425,Wrong Answer,"s=input() +if s==""ARC"": + print(""ABC"") +else: + print(""ABC"")" +p03637,s264249061,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +cnt = 0 +two = 0 +for i in a: + if i % 4 == 0: + cnt += 1 + elif i % 4 == 2: + two += 1 +if n // 2 <= cnt: + print(""Yes"") +elif two >= 2 and (n - (two - 1)) // 2 <= cnt: + print(""Yes"") +else: + print(""No"") +" +p02725,s787988926,Accepted,"a = list(map(int,input().split())) +A = list(map(int,input().split())) + +K = a[0] +N = a[1] + +A_nplus1 = K + A[0] +A.append(A_nplus1) + +max = -1 +max_id = -1 + +for i in range(0,N): + if A[i+1]-A[i] > max: + max = A[i+1] - A[i] +print(K-max)" +p03693,s396237376,Wrong Answer," + +lst = list(input().split()) +a = """".join(lst) +print(""YES"" if int(a) % 4 == 0 else ""No"")" +p02773,s988785131,Accepted,"n=int(input()) +l=[input() for _ in range(n)] +from collections import Counter as co +d=co(l) +k=max(d.values()) +x=[] +for i,j in d.items(): + if j==k: + x.append(i) +x.sort() +for i in x: + print(i)" +p02742,s545688754,Wrong Answer,"import numpy as np +import fractions + +a,b=map(int, input().split()) +if(a%2): + print(a*b//2+1) +else: + print(a*b//2)" +p02793,s437408113,Wrong Answer,"n = int(input()) +nums = [int(x) for x in input().split("" "")] +def gcd(a, b): + if b == 0: + return a + else: return gcd(b, a%b) + +lcm = 1 +for i in nums: + lcm = (lcm * i // gcd(lcm, i)) % (1000000007*1000000007) + +res = 0 +for i in nums: + res += (lcm // i) % 1000000007 +print(res % 1000000007) +" +p02583,s384408814,Wrong Answer,"N = input() +lst = list(map(int,input().split())) +cnt = 0 +lst = sorted(lst) +for i in range(len(lst)): + for j in range(len(lst)): + for k in range(len(lst)): + if lst[i]+lst[j] > lst[k]: + if lst[k] != lst[j] and lst[j] != lst[i]: + cnt += 1 +print(cnt)" +p03681,s189353581,Wrong Answer,"N, M = map(int, input().split()) +if abs(N - M) > 2: + print(0) + quit() +MOD = 10 ** 9 + 7 +fact = [1] * (max(N, M) + 1) +f = 1 +for i in range(1, max(N, M) + 1): + f = f * i % MOD + fact[i] = f +print(((N == M) + 1) * fact[N] * fact[M] % MOD)" +p02963,s486702513,Wrong Answer,"S = int(input()) + +x1 = 10 ** 9 +y1 = 1 +x2 = S % (10 ** 9) +y2 = S // (10 ** 9) +x3 = 0 +y3 = 0 + + +print(x1, y1, x2, y2, x3, y3)" +p03986,s523672601,Accepted,"x = input() +cnt = 0 +for x_ in x: + if x_ == 'T' and cnt: + cnt -= 1 + elif x_ == 'S': + cnt += 1 +print(2 * cnt) +" +p02935,s819429318,Accepted,"N=int(input()) +ans=0 +v=list(map(int,input().split())) + +v.sort(reverse=True) + +for i in range(N): + ans+=v[i]/(2**(i+1)) + +ans+=v[N-1]/(2**(i+1)) + +print(ans) +" +p02602,s783174607,Wrong Answer,"a = list(map(int,input().split())) +b = list(map(int,input().split())) +for v in range(a[1]-a[0]): + c=list(map(numpy.prod.b[0+v:a[0]+v])) +for m in range(a[1]-a[0]): + if c[m+1]>c[m]: + print(""Yes"") + else: + print(""No"")" +p03162,s108563400,Accepted,"def main(): + n = int(input()) + dp = [0, 0, 0] + + for activities in [list(map(int, input().split())) for _ in range(n)]: + new_dp = [0, 0, 0] + + for i in range(3): + offset = dp[i] + for j in range(3): + if i == j: continue + + new_dp[j] = max(new_dp[j], offset + activities[j]) + + dp = new_dp + + print(max(dp)) + +if __name__ == ""__main__"": + main()" +p02790,s486346181,Accepted,"MM = input().split() +a = int(MM[0]) +b = int(MM[1]) +list1 = [str(a)*b,str(b)*a] +list1.sort() +print(list1[0])" +p03126,s879594411,Accepted,"import numpy as np + +N, M = map(int, input().split()) +A = [] +for i in range(N): + A.append([int(i) for i in input().split()]) +for i in range(N): + del A[i][0] + +cnt = 0 +for i in A[0]: + flg = True + for j in range(1,N): + if not i in A[j]: + flg = False + break + if flg: + cnt +=1 +print(cnt)" +p03289,s457957173,Accepted,"def resolve(): + s = input() + if s[0] != 'A': + print('WA') + return + cnt = False + for i in s[2:-1]: + if i == 'C': + cnt += 1 + if cnt != 1: + print('WA') + return + for i in s: + if i == 'A' or i == 'C': + continue + if i.isupper(): + print('WA') + return + print('AC') +resolve()" +p02970,s644344441,Wrong Answer,"def golden_apple(n, d): + + ans = -(-n//((d+1*2)+1)) + + return ans + +def main(): + n, d = map(int, input().split()) + print(golden_apple(n, d)) + +if __name__ == '__main__': + main() +" +p02916,s689283477,Accepted,"n = int(input()) +lia = list(map(int, input().split())) +lib = list(map(int, input().split())) +lic = list(map(int, input().split())) + +sati = 0 +j = lia[0] + +for i in lia: + sati += lib[i-1] + if j == i-1: + sati += lic[j-1] + j = i + +print(sati) +" +p02701,s195394878,Wrong Answer,"import sys +input = sys.stdin.readline +for tt in range(1): + n = int(input()) + s = set() + for i in range(n): + if i==n-1: + s.add(input().lower()) + else: + s.add(input().lower()[:-1]) + print(len(s)) + " +p02899,s089812681,Accepted,"N = int(input()) +keys = list(map(int, input().split())) + +values = [None] * N +for i in range(N): + values[i] = i + 1 + +dic = {key : val for key, val in zip(keys, values)} +for i in dic.values(): + print(i, end="" "")" +p03836,s587567755,Accepted,"sx, sy, tx, ty = map(int,input().split()) +dx = tx - sx +dy = ty - sy +print(""D"" + ""R""*(dx+1) + ""U""*(dy+1) + ""L"" + ""D""*(dy)+ ""L""*(dx) + ""U"" * dy + ""R""*dx + ""U""+""L""*(dx+1)+""D""*(dy+1) +""R"") + +" +p03289,s555045710,Accepted,"S = list(input()) +if S[0] != 'A': + print('WA') + exit() +S[0] = 'a' +if S.count('C') != 1: + print('WA') + exit() +i = S.index('C') +if i == 1 or i == len(S)-1: + print('WA') + exit() +S[S.index('C')] = 'c' +if ''.join(S) == ''.join(S).lower(): + print('AC') +else: + print('WA')" +p02802,s215141613,Accepted,"N, M = map(int, input().split()) + +ac = 0 +wa = dict() + +done = dict() + +for i in range(M): + p, S = input().split() + if p in done: + continue + if S == ""AC"": + ac+= 1 + done[p] = True + else: + if p not in wa: + wa[p] = 0 + wa[p] += 1 + +_wa = 0 +for x in wa: + if x in done: + _wa += wa[x] + +print(ac, _wa)" +p03012,s188870773,Accepted,"n = int(input()) +lst = list(map(int, input().split())) +res = 10 ** 10 +for i in range(1, n): + res = min(res, abs(sum(lst[:i]) - sum(lst[i:]))) +print(res)" +p02787,s656535177,Accepted,"H, N = map(int, input().split()) + +inf = float('inf') +dp = [inf] * (H + 1) +dp[0] = 0 +for _ in range(N): + A, B = map(int, input().split()) + for i in range(H): + t1 = i + A + if t1 > H: + t1 = H + t2 = dp[i] + B + if t2 < dp[t1]: + dp[t1] = t2 +print(dp[H]) +" +p02988,s818642931,Wrong Answer,"n = int(input()) +p = list(map(int, input().split())) +cnt = 0 +for i in range(1, n-3+2): + print(i, p[i]) + if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]): + cnt += 1 +print(cnt)" +p03565,s169393150,Accepted,"import re +s=str(input()) +s = s.replace('?', '.') +t=str(input()) +for i in range(len(s)-len(t),-1,-1): + if re.match(s[i:i+len(t)],t): + s=s.replace(""."",""a"") + print(s[:i]+t+s[i+len(t):]) + exit() +else: + print(""UNRESTORABLE"")" +p03284,s324140648,Accepted,"n,m=map(int,input().split()) +if n % m ==0: + print(0) +else: + print(1)" +p02572,s888475161,Wrong Answer,"N = int(input()) +a = list(map(int, input().split())) +result = 0 +import numpy as np +num = np.array(a) +for i, a in enumerate(num): + sum = np.sum(a*num[(i+1):]) + result += sum +if result >= (10**9 + 7): + print(result % (10 ** 9 +7)) +else: + print(result)" +p02659,s635814719,Wrong Answer,"import math +#from decimal import * +a,b = map(float, input().split()) +int(a) +b = b*100 +int(b) +#b_i = float(b - math.floor(b)) +#print(b_i) +ans = int(a*b) +#Decimal(ans) +#ans_i = math.floor(a*b_i) +# ans = math.floor(Decimal(a)*Decimal(b)) +print(int(ans//100)) +" +p03163,s482542500,Accepted,"N,W = map(int, input().split()) + +import numpy as np +dp = np.zeros(W+1, dtype=int) + +for n in range(N): + w,v = map(int, input().split()) + dp[w:] = np.maximum(dp[w:], dp[:-w]+v) + + +print(dp[-1])" +p02677,s685784486,Accepted,"import math +p=math.pi +a,b,h,m=map(int,input().split()) +j=(b*math.cos(p*m/30),b*math.sin(p*m/30)) +t=(a*math.cos((h/6+m/360)*p),a*math.sin((h/6+m/360)*p)) +print(((j[0]-t[0])**2+(j[1]-t[1])**2)**(0.5))" +p03328,s705504149,Accepted,"a,b= map(int, input().split()) +print(int((b-a)*(b-a+1)/2-b))" +p02744,s591373633,Accepted,"from itertools import groupby + +n = int(input()) +r = 'a', +for _ in range(n - 1): + r = [s + c for s in r for c, _ in groupby(sorted(s) + [chr(ord(max(s)) + 1)])] +print(*r, sep='\n') +" +p03556,s964152576,Accepted,"def multiple(n): + a = [] + for i in range(1,int(n**.5)+1): + a.append(i*i) + return a +n = int(input()) +a = multiple(n) +ans = 10**18 +for i in a: + if n-i < 0: + continue + ans = min(ans,abs(n-i)) +print(n-ans)" +p02714,s860842766,Wrong Answer,"n = int(input()) +s = input() + +ans = 0 +for i in range(n): + for j in range(i + 2, n): + for k in range(j + 2, n): + if len(set([s[i], s[j], s[k]])) == 3 and abs(i-j) != abs(j-k): + ans += 1 + +print(ans) +" +p02772,s705035953,Accepted,"n = int(input()) +list = input().split() +flg=True +for i in list : + i = int(i) + if i%2==0 and not(i%3==0 or i%5==0): + flg=False + +if flg: + print(""APPROVED"") +else: + print(""DENIED"")" +p02631,s654854552,Wrong Answer,"N=int(input()) +a_list=list(map(int,input().split())) +a_list.sort(reverse=True) +c_list=[None]*N + +c_list[0]=2**(len(bin(a_list[0])[2:])-1) +b=a_list[0] + +for i,a in enumerate(a_list[1:]): + c_list[1+i]=b^a^c_list[i] + b=a + +ans="" "".join(list(map(str,c_list))) +print(ans)" +p03043,s375879283,Wrong Answer,"import math + +N, K = map(int, input().split()) + +ans = 0 +for i in range(1, N+1): + if i >= K: + ans += 1/N + else: + n = math.ceil( math.log2( 10/i )) + p = 1/N * (0.5**n) + ans += p + +print(ans)" +p02675,s566389284,Wrong Answer,"N=input()[-1:] + +if N==""3"": + print(""bon"") +elif N in {0,1,6,8}: + print(""pon"") +else: + print(""hon"")" +p02767,s303847833,Accepted,"N=int(input()) +xlist=list(map(int,input().split())) + +xmin=min(xlist) +xmax=max(xlist) + +min_answer=10**9 +for i in range(xmin,xmax+1): + answer=0 + for x in xlist: + answer+=(x-i)**2 + + min_answer=min(answer,min_answer) + +print(min_answer)" +p03241,s729923502,Wrong Answer,"import sys + +def solve(): + input = sys.stdin.readline + N, M = map(int, input().split()) + maxGCD = 1 + for gcd in range(2, M): + if gcd * gcd > M: break + else: + if M % gcd == 0: + if M // gcd >= N: maxGCD = gcd + print(maxGCD) + + return 0 + +if __name__ == ""__main__"": + solve()" +p02594,s027790568,Wrong Answer,"K = int(input()) +x = 7 % K + +for count in range(1, K + 1): + if x == 0: + print(count) + break + x = (x * 10 + 7) % K + +else: print(-1) +" +p03380,s503804559,Wrong Answer,"n = int(input()) +arr = [int(a) for a in input().split()] + +i = max(arr) +j = min(arr, key=lambda a: min(abs(i//2-a), abs((i+1)//2-a))) + +print(i, j) +" +p02701,s396947955,Accepted,"N=int(input()) +s=[input() for i in range(N)] +r=set(s) +print(len(r))" +p02756,s167589809,Accepted,"import collections +s = collections.deque(list(input())) +q = int(input()) +cnt = 0 +for i in range(q): + fc = input().split() + if fc[0] == '1': + cnt += 1 + else: + if cnt == 1: + fc[1] = '1' if fc[1] == '2' else '2' + if fc[1] == '1': + s.appendleft(fc[2]) + else: + s.append(fc[2]) + cnt %= 2 +if cnt == 1: + s.reverse() +print(*s, sep='') +" +p03145,s962711137,Accepted,"c, a, b = map(int, input().split()) +print(int(min(a, b, c) * (a + b + c - min(a, b, c) - max(a, b, c)) / 2))" +p02577,s039003215,Wrong Answer,"import sys +N = int(input()) + +ss = list(str(N)) + + +s = list(map(int, ss)) + +if(N%2 == 0): + print('No') + sys.exit(0) + +if(N%5 == 0): + print('No') + sys.exit(0) + +if(N%7 == 0): + print('No') + sys.exit(0) + +re = sum(s) + +# re = 0 +# for s in ss: +# re += int(s) +if(re%9 == 0): +# if(N%9 == 0): + print('Yes') + + +" +p02675,s045830043,Wrong Answer,"N = int(input()) +a = 0 + +if N>=100: + a = N % 100 + if a == 2|4|5|7|9: + print(""hon"") + elif a == 0|1|6|8: + print(""pon"") + else: + print (""bon"")" +p03838,s827990027,Wrong Answer,"x, y = map(int, input().split()) + +ans = 10**18 + +if y - x >= 0: + ans = min(ans, y-x) + +x *= -1 + +if y - x >= 0: + ans = min(ans, y-x) + +x *= -1 +y *= -1 + +if y - x >= 0: + ans = min(ans, y-x) + +x *= -1 + +if y - x >= 0: + ans = min(ans, y-x) + +print(ans)" +p04033,s530104040,Wrong Answer,"import sys +a,b = map(int,input().split()) +c = 0 +if a < 0 and b < 0: + if a-b % 2 == 0: + print(""Positive"") +elif a < 0 and b >= 0: + if a%2 == 0: + print(""Positive"") +elif a < 0 and b >= 0: + if b % 2 == 0: + print(""Positive"") +elif (a+b) == 0: + print(""Zero"") +elif (a+b) > 0: + print(""Positive"") +else: + print(""Negative"")" +p02832,s831876793,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +k = 1 +ans = 0 + +if 1 not in A: + print(-1) + exit() + +for a in A: + if a == k: + k += 1 + else: + ans += 1 + +print(ans)" +p03681,s356265693,Accepted,"N, M = map(int, input().split()) +ans = 1 +MOD = 10 ** 9 + 7 + +if abs(N - M) >= 2: + print(0) +else: + for i in range(1, N + 1): + ans *= (i % MOD) + ans %= MOD + for i in range(1, M + 1): + ans *= (i % MOD) + ans %= MOD + if (N + M) % 2 == 0: + ans *= 2 + + print(ans % MOD)" +p02642,s642245223,Wrong Answer,"n = int(input()) +a = sorted(list(map(int, input().split()))) + +res = 0 +for i in range(n): + for j in range(i): + if a[j] * 2 > a[i]: + break + if a[i] % a[j] == 0: + res += 1 + break + +print(n - res)" +p02718,s899810397,Wrong Answer,"import math +import sys + +n, m = map(int, input().split()) +#print(n) +#print(m) + +a = input().split() +l_si_i = [int(b) for b in a] +#print(l_si_i) + +#print(max(l_si_i)) +#print(sum(l_si_i)) + +border = math.floor(sum(l_si_i) / (4 * m)) +#print(border) + +check = 0 +for i in range(n): + c = l_si_i[i] + if c > border: + check += 1 + + if check >= m: + print(""Yes"") + sys.exit() + +print(""No"")" +p02708,s489207788,Wrong Answer,"mod=10**9+7 +n,k=map(int,input().split()) +ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2) +ans=int(ans%mod) +print(ans)" +p02681,s946938862,Accepted,"s = str(input()) +t = str(input()) + +if(t.startswith(s)): + print(""Yes"") +else: + print(""No"")" +p02829,s028839124,Accepted,"a, b = [int(input()) for _ in range(2)] +l = list([1,2,3]) +l.remove(a) +l.remove(b) +print(l[0])" +p02693,s901167791,Accepted,"k=int(input()) +a,b=map(int,input().split()) +c=0 +for i in range(a,b+1): + if i%k==0: + c=1 + break +if c==1: + print('OK') +else:print('NG')" +p02730,s820668886,Accepted,"# print('input >>') + +S = input() + +N = len(S) + +def is_kaibun(S): + for i in range(len(S)): + if S[i] != S[-i-1]: + return False + return True + +if is_kaibun(S) and is_kaibun(S[:(N-1)//2]) and is_kaibun(S[(N+3)//2-1:N]): + print('Yes') +else: + print('No') + +# print('-----output-----') + +" +p03994,s168644901,Accepted,"s = input() +ints = [ord(i) - ord('a') for i in s] +K = int(input()) +n = len(s) +i = 0 +while i < n: + if ints[i] != 0 and 25 - ints[i] + 1 <= K: + K -= 25 - ints[i] + 1 + ints[i] = 0 + i += 1 + +K %= 26 +ints[-1] = (ints[-1] + K) % 26 +s_ = '' +for i in ints: + s_ += chr(i + ord('a')) + +print(s_) +" +p02576,s946510386,Accepted,"n,x,t= map(int,input().split()) #標準入力 + +if(n%x==0): + num=n//x +else: + num=n//x+1 + +print(num*t) #焼くセット数*時間を計算して出力(())" +p03417,s017392386,Accepted,"n, m = map(int, input().split()) +if n >= 2: + if m >= 2: + print((n-2) * (m-2)) + else: + print((n-2) * m) +else: + if m >= 2: + print(n * (m-2)) + else: + print(n * m) " +p02880,s444512065,Wrong Answer,"N=int(input()) +for i in range(1,10): + if (N/i).is_integer==True and (N/i)<10: + print(""Yes"") +print(""No"")" +p02678,s460887470,Accepted,"from collections import deque +N,M=map(int,input().split()) +C=[[] for i in range(N+1)] +for i in range(M): + A,B=sorted(list(map(int,input().split()))) + C[A].append(B) + C[B].append(A) + +d=[-1]*(N+1) +d[0]=0 +d[1]=0 + +queue=deque([1]) +while queue: + now = queue.popleft() + for i in C[now]: + if d[i]!=-1:continue + d[i]=now + queue.append(i) + +if d.count(0)>2:print('No');exit +print('Yes') +for i in range(2,N+1): + print(d[i])" +p02761,s292655563,Wrong Answer,"N,M=map(int,input().split()) +sc=[list(map(int,input().split()))for _ in [0]*M] + +ans=['1']+['0']*(N-1) +count=[0]*N +for s,c in sc: + if count[s-1]==1 and ans[s-1]!=str(c): + ans='-1' + break + else: + ans[s-1]=str(c) + count[s-1]=1 + +if N>=2 and ans[0]=='0': + ans='-1' + +if M==0: + ans='0' + +print(''.join(ans))" +p03038,s195350302,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +b = [] +for i in range(M): + b.append(list(map(int, input().split()))) +ans = 0 +A.sort() +b.sort(key=lambda x: x[1], reverse=True) +j = 0 +for i in range(M): + if j >= N or b[i][1] <= A[j]: + break + while j < N and b[i][0] and b[i][1] > A[j]: + ans += b[i][1] + b[i][0] -= 1 + j += 1 +if j >= N: + print(ans) +else: + print(ans + sum(A[j:]))" +p02571,s854158725,Accepted,"s = input() +t = input() +n = len(s) +m = len(t) +ans = m +for i in range(n-m+1): + x = m + for j in range(m): + if s[i+j] == t[j]: + x -= 1 + ans = min(ans,x) +print(ans)" +p02766,s412887973,Accepted,"N, K = map(int,input().split()) + +counter = 1 +while N >= K: + N = N/K + counter = counter + 1 + +print(counter)" +p03481,s897943819,Accepted,"X, Y = map(int, input().split()) +ans = 0 + +while X <= Y: + X *= 2 + ans += 1 + +print(ans) +" +p02665,s055459303,Accepted,"n = int(input()) +a = list(map(int, input().split())) +s = [0]*(n+2) +for i in range(n, -1, -1): s[i] = s[i+1]+a[i] + +def solve(): + cur = 1 + res = 0 + for i in range(n+1): + if cur < a[i]: return -1 + res += cur + cur -= a[i] + if cur > s[i+1]: return -1 + cur = min(cur*2, s[i+1]) + return res + +print(solve())" +p03264,s264384153,Accepted,"K = int(input()) +num_even = K // 2 +num_odd = K - num_even +print(num_even * num_odd)" +p02933,s861187550,Accepted,"a=int(input()) +s=input() + +if a>=3200: + print(s) +else: + print('red')" +p02843,s588215956,Accepted,"def main(): + X = int(input()) + for i in range(1000): + if 100*i <= X <= 105*i: + print(1) + return + print(0) + +if __name__ == ""__main__"": + main() +" +p03632,s073644984,Accepted,"a, b, c, d = map(int, input().split()) + +if b < c or d < a: + print(0) +else: + print(min(b, d) - max(a, c))" +p03944,s444307240,Accepted,"w,h,n=map(int,input().split()) + +x_mx=w +x_mn=0 +y_mx=h +y_mn=0 +for i in range(n): + x,y,a=map(int,input().split()) + if a==1: + x_mn=max(x_mn,x) + elif a==2: + x_mx=min(x_mx,x) + elif a==3: + y_mn=max(y_mn,y) + else: + y_mx=min(y_mx,y) + +ans=(x_mx-x_mn)*(y_mx-y_mn) +if x_mx-x_mn<=0 or y_mx-y_mn<=0: + ans=0 +print(max(ans,0))" +p03852,s146489093,Accepted,"import sys +import math +import bisect + +def main(): + if input() in 'aeiou': + print('vowel') + else: + print('consonant') + +if __name__ == ""__main__"": + main() +" +p03286,s592794964,Accepted,"N=int(input()) +# 1011: -9 +# 101 1 + 4 =5 +# 10: -2 +# 1 + +def calc(x): + ans="""" + + while True: + + if x%2==0: + ans=""0""+ans + else: + ans=""1""+ans + x-=1 + if x==0: + break + + x = x//(-2) + return ans + +a=calc(N) + +print(a) " +p02811,s221191933,Accepted,"k, x = list(map(int, input().split())) + +if 500*k >= x: + print('Yes') +else: + print('No')" +p03220,s699816194,Accepted,"n=int(input()) +t,a=[int(i) for i in input().split()] + +h=[int(i) for i in input().split()] + +min=1000000 +ans=0 +for i in range(n): + temp=t-0.006*h[i] + if min>abs(a-temp): + min=abs(a-temp) + ans=i+1 + +print(ans)" +p02959,s981846313,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +kill,surplus = 0,0 + +for i in range(n): + tmp = min(a[i],surplus) + kill += tmp + a[i] -= tmp + if b[i] > a[i]: + kill += a[i] + surplus = b[i]-a[i] + else: + kill += b[i] + surplus = 0 +tmp = min(a[n],surplus) +kill += tmp +print(kill) " +p02618,s189926265,Accepted,"for i in range(365): + print(1)" +p03011,s657919543,Accepted,"a,b,c=map(int,input().split()) +l = sorted([a,b,c]) +print(l[0]+l[1])" +p03711,s122857736,Wrong Answer,"x,y=map(int,input().split()) +a=[1,3,5,7,8,10,12] +count=0 +if x==a: + if y==a: + count+=1 + else: + count+=0 +if x!=a and x!=2: + if y!=a and y!=2: + count+=1 + else: + count+=0 +if x==2: + if y==2: + count+=1 + else: + count+=0 +if count!=0: + print('Yes') +else: + print('No')" +p02778,s746784014,Accepted,"S, a = input(), """" +for x in range(len(S)): + a += ""x"" +print(a)" +p03017,s237820305,Accepted,"n, a, b, c, d = map(int, input().split()) + +s = input() + +if s.find('##',a,c) < 0 and s.find('##',b,d) < 0: + if c=0: + print('Yes') + else : + print('No') +else : + print('No')" +p02547,s206397129,Accepted,"N = int(input()) + +x = 0 +for i in range(N): + a, b = map(int, input().split()) + if a == b: + x += 1 + else: + x = 0 + + if x >= 3: + print(""Yes"") + break +else: + print(""No"") " +p03672,s798098869,Accepted,"S = input() + +deletes = -1 +while len(S) + deletes > 0: + # 削る + test_s = S[:deletes] + + # 判定 + if len(test_s) % 2 == 0: + l = test_s[:len(test_s) // 2] + r = test_s[len(test_s) // 2:] + + if l == r: + break + + deletes -= 1 + +# print(deletes, test_s, l, r) +print(len(test_s)) +" +p03495,s750477126,Accepted,"from collections import Counter + +N, K = map(int, input().split(' ')) +balls = tuple(map(int, input().split(' '))) + +counter = Counter(balls) +counts = sorted(counter.values(), reverse=True) + +print(sum(counts[K:])) +" +p03221,s487436220,Wrong Answer,"n, m = [int(x) for x in input().split(' ')] + +cities = list() +for i in range(m): + pi, pm = [int(x) for x in input().split(' ')] + cities.append((pi, pm)) + +p = [0] * (n+1) +for city in sorted(cities, key=lambda city: city[1]): # sort by year + p[city[0]] += 1 # city birth order + print('{:06d}{:06d}'.format(city[0], p[city[0]])) +" +p02861,s932802055,Accepted,"import math +def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) +def ism():return map(str,input().split()) +def isl():return list(map(str,input().split())) + +n = ii() +cd = [] +for i in range(n): + cd.append(iil()) + +dist = 0 +for i in range(n): + for j in range(i,n): + dist += math.factorial(n-1)*2*((cd[i][0]-cd[j][0])**2+(cd[i][1]-cd[j][1])**2)**0.5 +print(dist/math.factorial(n))" +p02873,s533214690,Accepted,"s=input() +sl=len(s) + +l=[0 for i in range(sl+1)] +for i in range(sl): + if s[i]=='<': + l[i+1]=max(l[i]+1, l[i+1]) + +for i in range(sl-1,-1,-1): # reversed(range(sl)) + if s[i]=='>': + l[i]=max(l[i+1]+1, l[i]) + +print(sum(l))" +p02922,s791979832,Accepted,"import math +a,b=map(int,input().split()) +print(math.ceil((b-1)/(a-1))) +" +p03371,s170570887,Accepted,"a,b,c,x,y = map(int,input().split()) +ans = 0 + +if c*2 <= a+b: + m = min(x,y) + ans += m*c*2 + x -= m + y -= m + if 0 < x and c*x*2 < a*x: + ans += (c*x*2) + elif 0 < y and c*y*2 < b*y: + ans += (c*y*2) + else: + ans += (a*x)+(b*y) +else: + ans = (a*x)+(b*y) + +print(ans)" +p03379,s488318814,Wrong Answer,"from copy import deepcopy + +N = int(input()) +X = list(map(int,input().split())) +Y = deepcopy(X) +Y.sort() +med1 = Y[N//2-1] +med2 = Y[N//2] +##print(""med1:"",med1,""med2"",med2) +for i in range(N): + if X[i] == med2: + print(med1) + else: + print(med2)" +p02554,s915669343,Accepted,"n = int(input()) +m = 10**9+7 +a = 10**n - 9**n - 9**n + 8**n +print(a % m) +" +p03795,s526536087,Accepted,"N = int(input()) + +print(N * 800 - (N // 15 * 200))" +p03043,s649344512,Accepted,"#!/usr/bin/env python3 +import math + + +def main(): + n, k = map(int, input().split()) + p = 0 + for i in range(1, n + 1): + head_num = math.ceil(math.log(k / i, 2.0)) + head_num = max(head_num, 0) + p += 1 / n * ((0.5) ** head_num) + print(p) + + +if __name__ == '__main__': + main() +" +p02780,s070552266,Wrong Answer,"from decimal import Decimal +n, k = map(int, input().split()) +p = list(map(int, input().split())) + +num_li = [0]*n +ans = 0 +num = 0 + +for i in range(n): + num_li[i] = ((Decimal(p[i])*(Decimal(p[i])+1))/2)/Decimal(p[i]) + +num = sum(num_li[:k]) + +for j in range(n-k): + num = num-num_li[j]+num_li[j+k] + ans = max(num,ans) + +print('{:.10f}'.format(ans))" +p02797,s539240969,Wrong Answer,"n= 100 +k= 80 +s= 1000 +su = [] +for i in range(n): + su.append(s) + +for i in range(n-k): + su[n-i-1] = s+1 + +print(*su)" +p02854,s310796517,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +result = 2020202020 +num_left = 0 +num_right = sum(a) + +for i in range(n): + num_left += a[i] + num_right -= a[i] + result = min(result, abs(num_left - num_right)) +print(result)" +p03261,s862084517,Accepted,"N = int(input()) + +words = set() + +flag = True +for i in range(N): + word = input() + if i == 0: + words.add(word) + prev_word = word + else : + if prev_word[-1] != word[0]: + flag = False + else : + words.add(word) + prev_word = word + +if flag: + if len(words) == N : + print('Yes') + else : + print('No') +else : + print('No')" +p02676,s141989705,Accepted,"def mp(): return map(int, input().split()) +def lmp(): return list(map(int, input().split())) + +k = int(input()) +s = input() +if len(s) <= k: + print(s) +else: + print(s[:k]+""..."") +" +p03285,s091526835,Accepted,"n = int(input()) +flag = 0 +def dfs(val): + global flag + if val == n: + flag = 1 + return + if val>n: + return + if val<0: + return + dfs(val+4) + dfs(val+7) +dfs(0) +if flag == 1: + print(""Yes"") +else: + print(""No"")" +p03095,s741320502,Wrong Answer,"from collections import Counter +n = int(input()) +s = input() +mod = 1000000007 +ans = 1 +cnt = Counter(s) +for v in cnt.values(): ans *= (v+1) +ans -= 1 +print(ans)" +p02775,s542936097,Accepted,"n = str(input().rstrip()) + +ans = 0 + +a = list(map(int, list(n))) +a = a[::-1] +a.append(0) +for i in range(len(a) - 1): + c = a[i] + if c < 5: + ans += c + else: + if c == 5 and a[i+1] < 5: + ans += 5 + else: + a[i+1] += 1 + ans += 10 - c +ans += a[-1] + +print(ans) + +" +p02987,s510043025,Accepted,"x,y,z,w = input() + +l = [] +l.append(x) +l.append(y) +l.append(z) +l.append(w) +new_l = sorted(l) + +if new_l[0] == new_l[1] and new_l[1] != new_l[2] and new_l[2] == new_l[3]: + print(""Yes"") +else: + print(""No"")" +p03486,s840378549,Accepted,"s = sorted(input()) +t = sorted(input()) +t_reverse = t[::-1] +if s < t_reverse: + print('Yes') +else: + print('No')" +p03852,s838068914,Accepted,"aiueo = ['a', 'i', 'u', 'e', 'o'] + +if input() in aiueo: + print('vowel') +else: + print('consonant') +" +p03659,s506959798,Accepted,"n = int(input()) +a = list(map(int, input().split())) +l = [] +x = 0 +s = sum(a) +for i in range(n-1): + x+=a[i] + l.append(abs(x*2-s)) +print(min(l))" +p03001,s766753930,Accepted,"W, H, x, y = map(int, input().split()) + +z = 0 +if x == W / 2 and y == H / 2: + z = 1 +print(W * H / 2, z)" +p03696,s574118395,Accepted,"import sys +def I(): return int(sys.stdin.readline().rstrip()) +def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし + +N = I() +S = LS2() + +a,b = 0,0 +left = [] +for i in range(N): + if S[i] == '(': + a += 1 + else: + b += 1 + if a < b: + a,b = 0,0 + left.append('(') + +ANS = left + S + [')']*(a-b) + +print(''.join(ANS))" +p02989,s871563372,Accepted,"n = int(input()) +p = list(map(int, input().split())) +nn = int(n/2) +p.sort() +ans = p[nn] - p[nn-1] + +print(ans)" +p03433,s254719684,Wrong Answer,"N = int(input()) +A = int(input()) + +if N%500 <= A: + print('Yse') +else: + print('No')" +p03241,s777782845,Accepted,"N, M = map(int, input().split()) +divisors = sorted(sum((list({n, M // n}) for n in range(1, int(M ** 0.5) + 1) if not M % n), []), reverse=True) + +for d in divisors: + if M // d >= N: + print(d) + break +" +p03103,s942750384,Accepted,"from operator import itemgetter + +n, m = map(int, input().split()) +ab = [list(map(int, input().split())) for i in range(n)] +ab.sort() +#print(ab) +i = 0 +ans = 0 +while m >0: + if ab[i][1]<=m: + m -= ab[i][1] + ans += ab[i][0]*ab[i][1] + else: + ans += ab[i][0]*m + m = 0 + i+=1 +print(ans)" +p04030,s104608586,Accepted,"s=input() +ans=[] +for i in range(len(s)): + if s[i]=='0': + ans.append('0') + elif s[i]=='1': + ans.append('1') + else: + if ans: + ans.pop() +print(''.join(ans))" +p03131,s188093726,Accepted,"k, a, b = map(int, input().split()) + +max_change = max(0, (k - (a - 1)) // 2) +print(max(k+1, 1+k-max_change*2 + (b-a)*max_change))" +p02801,s217346017,Accepted,"c = str(input()) +al = 'abcdefghijklmnopqrstuvwxyz' +for i in range(len(al)): + if c == al[i]: + print(al[i+1]) +" +p02553,s777289342,Accepted,"a, b, c, d = map(int, input().split()) + +n = [a*c, a*d, b*c, b*d] +print(max(n))" +p02791,s810168747,Accepted,"n = int(input()) +row = list(map(int, input().split())) +m = row[0] +count = 0 +for i in range(n): + if row[i] <= m: + m = row[i] + count += 1 +print(count)" +p03486,s337934918,Accepted,"s = [x for x in input()] +t = [x for x in input()] +s.sort() +t.sort(reverse=True) +s, t = """".join(s), """".join(t) +ans = ""No"" +m = min(len(s), len(t)) +for i in range(m): + if s[i] < t[i]: + ans = ""Yes"" + break +if ans == ""No"" and s[:m] == t[:m] and len(s) < len(t): ans = ""Yes"" +print(ans) +" +p02731,s757841368,Accepted,"L = int(input()) + +# 普通に立方体が一番大きい +print(pow(L/3,3)) +" +p03109,s018279553,Accepted,"S = input() +print(""Heisei"" if S <= ""2019/04/30"" else ""TBD"")" +p02760,s307595984,Accepted,"A=[list(map(int,input().split())) for _ in range(3)] +N=int(input()) +b=[int(input()) for _ in range(N)] +for i in range(3): + if set(A[i]) <= set(b): + print(""Yes"") + exit() + if set([A[0][i], A[1][i], A[2][i]]) <= set(b): + print(""Yes"") + exit() +if set([A[0][0], A[1][1], A[2][2]]) <= set(b) or set([A[0][2], A[1][1], A[2][0]]) <= set(b): + print(""Yes"") + exit() +print(""No"") +" +p03274,s182209588,Wrong Answer,"N,K = map(int,input().split()) +x = sorted(list(int(i) for i in input().split())) +ans = 10**5 +for i in range(N-K+1): + left =x[i] + right =x[i+K-1] + p1 = abs(left) + abs(right-left) + p2 = abs(right) + abs(right-left) + p = min(p1,p2) + ans = min(ans,p) + +print(ans)" +p03252,s135491489,Accepted,"from collections import Counter + +s = input() +t = input() + +a = Counter(s) +b = Counter(t) + +c = list(a.values()) +d = list(b.values()) + +print('Yes') if c == d else print('No')" +p03434,s460006675,Accepted,"N = int(input()) +a = list(map(int, input().split())) +a.sort(reverse=True) +alice = 0 +bob = 0 +for i in range(N): + if i % 2 != 0: + alice += a[i] + continue + bob += a[i] +print(bob - alice) +" +p03474,s098649846,Accepted,"a,b=map(int,input().split()) +s=input().split(""-"") +print(""Yes"" if len(s)==2 and len(s[0])==a and len(s[1])==b else ""No"")" +p02789,s876274050,Accepted,"n,m=map(int,input().split()) +if n==m: + print('Yes') +else: + print('No')" +p03286,s526153968,Accepted,"N = int(input()) + +N = -N + +if N == 0: + print(0) + exit() + +t = [] +while N != 0: + s = N % -2 + if s == 0: + t.append(0) + else: + t.append(1) + + N //= -2 + +t = list(reversed(t)) +print(''.join(map(str, t))) +" +p03286,s351346994,Accepted,"n = int(input()) +s = """" +while n != 0: + r = n % (-2) + if r < 0: + r += 2 + s += str(r) + n = int((n - r) / (-2)) +if s != """": + print(s[::-1]) +else: + print(0)" +p03284,s847019986,Accepted,"n,k = map(int,input().split()) + +if n % k == 0: + print(0) +else: + print(1)" +p03038,s369235895,Accepted,"def main() -> None: + N, M = map(int, input().split()) + cards = [(x, 1) for x in map(int, input().split())] + for _ in range(M): + b, c = map(int, input().split()) + cards.append((c, b)) + cards.sort(reverse=True) + res, ans_sum = N, 0 + for x, num in cards: + if res <= num: + ans_sum += res * x + break + ans_sum += num * x + res -= num + print(ans_sum) + + +if __name__ == '__main__': + main() +" +p03076,s598473477,Accepted,"import math +A = [int(input()) for i in range(5)] +Aa = [i for i in A if i % 10 == 0] +Ab = [i for i in A if not i % 10 == 0] +Ab = sorted(Ab, key=lambda x : (x) % 10, reverse=True) +#print(Aa, Ab) + +total = 0 +for i in range(len(Aa)): + total += math.ceil(Aa[i] / 10) * 10 + #print(total) +for i in range(len(Ab)): + if i +1 == len(Ab): + total += Ab[i] + else: + total += math.ceil(Ab[i] / 10) * 10 + #print(total) + +print(total) +" +p03632,s032490651,Wrong Answer,"a, b, c, d = map(int, input().split()) + +r = max(0, min((a + b),(c + d)) - c) +print(r)" +p03377,s130837271,Accepted,"a,b,x=map(int, input().split()) +if a <= x and x <= a+b: + print('YES') +else: + print('NO')" +p02918,s805061405,Wrong Answer,"n,k = map(int,input().split()) +s = input() +edge,inside,cnt,ix = 0,0,0,0 +if s[0]=='R' or s[-1]=='R': + edge += 1 +temp = '' +#print(ix) +s += 'L' +for i in range(n+1): + if i!=n: + if temp=='R' and s[i]=='L': + inside += 1 + elif temp==s[i]: + cnt += 1 + temp = s[i] +#print(inside,cnt,edge) +if inside>=k: + print(k*2+cnt) +else: + print(inside*2+edge+cnt)" +p03693,s588025433,Accepted,"a,b,c = map(int,input().split()) + +if (10*b+c)%4 == 0: + print(""YES"") +else: + print(""NO"")" +p02879,s604470131,Accepted,"a, b = map(int, input().split()) + +if a<=9 and b<=9: + print(a*b) +else: + print(-1) +" +p02602,s634575462,Wrong Answer,"import numpy as np + +# = int(input()) +# = str(input()) +N, K = map(int, input().split()) +A = list(map(int, input().split())) +# = [int(input()) for i in range(N)] +# = [list(map(int, input().split())) for i in range(N)] + +first = np.asarray(A[:K]) +score = np.prod(first) + +for i in range(K, N): + nextscore = score * A[i] //A[i-K] + if nextscore <= score: + print(""No"") + else: + print(""Yes"") + score = nextscore +" +p02594,s187880894,Wrong Answer,"#https://atcoder.jp/contests/abc174/tasks/abc174_a + +N= [] +N= int(input("" "")) + +if N>=30: + print(""YES"") +else: + print(""NO"")" +p02923,s115615503,Wrong Answer,"N = int(input()) +H = list(map(int,input().split())) + +cnt = 0 +ans = 0 +for i in range(N-1): + if H[i] >= H[i+1]: + cnt += 1 + ans =max(cnt,ans) + else: + cnt = 0 + +print(cnt)" +p03836,s136933613,Accepted,"import sys + + +def input(): return sys.stdin.readline().strip() + + +def resolve(): + s1, s2, t1, t2 = map(int, input().split()) + l = [] + yoko = t1 - s1 + tate = t2 - s2 + a,c,f,h='R','L','L','R' + b,d,e,g='U','D','D','U' + l.append(a*yoko+b*tate+c*yoko+d*tate) + l.append(e+a*(yoko+1)+b*(tate+1)+f) + l.append(g+c*(yoko+1)+d*(tate+1)+h) + print(''.join(l)) +resolve()" +p02880,s307167600,Accepted,"N = int(input()) +for i in range(1,10): + for j in range(1,10): + ij = i * j + if(N == i*j): + print(""Yes"") + exit(0) +print(""No"")" +p02924,s299526564,Wrong Answer,"n = int(input()) +ans = (n-1)*n/2 + +print(int(ans)) +" +p03657,s768732334,Wrong Answer,"A,B = map(int,input().split()) + +if A + B != 0 and (A + B) % 3 == 0: + print(""Yes"") +else: + print(""No"")" +p03241,s288520780,Wrong Answer,"import math +N, M = map(int,input().split()) +b = 0 +P = [1] +for k in range(2,math.floor(math.sqrt(M))+1): + if M % k == 0: + P.append(k) + P.append(M//k) +P = sorted(P) +for e in P: + if e >= N: + print(M//e) + exit(0) +" +p03160,s816731145,Wrong Answer,"import sys +n = int(sys.stdin.readline().strip('\n')) +h = list(map(int, sys.stdin.readline().strip('\n').split())) +dp = [float('inf') for _ in range(n)] +dp[0] = 0 +for i in range(n-2): + # 配るdp + if i+1<=n-1: dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1])) + if i+2<=n-1: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2])) +print(dp[n-1])" +p02756,s092530313,Wrong Answer,"S=input() +Q=int(input()) +l=list(input().split() for i in range(Q)) +for j in l: + if j[0]==""1"": + S=S[::-1] + else: + if j[1]==""1"": + S=S+j[2] + else: + S=j[2]+S + +print(S) + " +p02665,s704674785,Accepted,"N = int(input()) +A = tuple(map(int, input().split())) +limit = sum(A) +alive = 1 +total = 0 +for a in A: + alive -= a + limit -= a + if alive < 0: + print(-1) + break + total += alive + a + alive = min(alive * 2, limit) +else: + print(total)" +p02732,s253899467,Accepted,"import collections + +n = int(input()) + +a = list(map(int, input().split())) + +c = collections.Counter(a) +total = 0 +for i in c: + total += c[i]*(c[i]-1)//2 + + +for i in range(n): + target = c[a[i]] + print(total - target*(target-1)//2 + (target-1)*(target-2)//2) + + + +" +p03345,s806110504,Wrong Answer,"A,B,C,K = map(int,input().split()) +for i in range(min(K, 100000)): + A,B,C = B+C,C+A,A+B + if A - B > 10**18: + print(""Unfair"") + exit() +print(A-B)" +p03069,s787902039,Accepted,"n=int(input()) +s=input() +b=s.count('#') +w=s.count('.') +B=0 +ans=w +for i in range(n): + if s[i]=='#': + B+=1 + W=n-(i+1)-(b-B) + ans=min(ans,B+W) +print(ans) +" +p02922,s080584996,Wrong Answer,"import math +a,b = map(int,input().split()) +i = 0 +while i < math.log(b,a): + i += 1 +print(i) +" +p03241,s662652468,Wrong Answer,"#!/usr/bin/env python3 + +n, m = list(map(int, input().split())) + +ans = 1 +num = int(m**0.5)+1 + +for i in range(1, num): + if m % i != 0: + continue + j = m//i + # if i >= n: + # ans = max(ans, j) + if j >= n: + ans = max(ans, i) +print(ans) +" +p03206,s912050824,Accepted,"d = int(input()) + +if d == 25: + print('Christmas') +elif d == 24: + print('Christmas Eve') +elif d == 23: + print('Christmas Eve Eve') +else: + print('Christmas Eve Eve Eve')" +p03623,s523610842,Wrong Answer,"x, a, b = map(int, input().split()) +print(['B', 'A'][abs(x-a)> abs(x-b)])" +p04045,s783581065,Wrong Answer,"N, K = [int(x) for x in input().split()] +D = input().split() + +for payment in range(N, 10000): + if all(char not in D for char in str(payment)): + print(payment) + break" +p03592,s160562503,Accepted,"n, m, k = map(int, input().split()) +s = set() +for i in range(n + 1): + s.add(i * m) +for i in range(m + 1): + s.add(i * n) +for i in range(1, n): + for j in range(1, m): + s.add(i * j + (n - i) * (m - j)) +if k in s: + print(""Yes"") +else: + print(""No"")" +p03592,s943251879,Wrong Answer,"import sys + +if __name__ == ""__main__"": + N, M, K = [int(x) for x in input().split("" "")] + for x in range(0, N + 1): + for y in range(x, M + 1): + if x * M + (y - x) * N == K: + print(""Yes"") + sys.exit(0) + print(""No"") +" +p02675,s842647754,Wrong Answer,"a=input() +if(int(a) > 0): + s=str(a) + if(s[-1] in ('2','4','5','7','9')): + print('hon') + elif(s[-1] in ('0','1','6','8')): + print('pon') + elif(s[-1] == '3'): + print('bonn')" +p02572,s067219465,Accepted,"n = int(input()) +a = list(map(int,input().split())) +sum_a = sum(a) +result = 0 +for i in range(n): + result += a[i] * (sum_a - a[i]) +print((result)//2 %(10**9+7))" +p02842,s459378104,Accepted,"n = int(input()) + +for x in range(1,n+1): + if n==int(x*1.08): + print(x) + exit() +print("":("")" +p02706,s154896807,Accepted,"#高橋君の夏休みは N 日間です。 +#夏休みの宿題が M 個出されており +#i 番目の宿題をやるには Ai 日間かかります。 +#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-1' を出力 + +N,M =map(int,input().split()) +A =list(map(int,input().split())) + +if sum(A) > N: + print(-1) +else: + print(N-sum(A))" +p02917,s389159031,Accepted,"N = int(input()) +B = [int(i) for i in input().split("" "")] +B.append(10**5+1) +Sum = B[0] + +for i in range(N-1): + Sum += B[i] + if B[i+1]0: + X-=K-1 + ans+=1 +print(ans) +" +p02767,s581935889,Accepted,"N=int(input()) +X=list(map(int,input().split())) +ans=float('inf') +for i in range(1,100): + cnt=0 + for j in range(N): + cnt+=(X[j]-i)**2 + if ans>cnt: + ans=cnt +print(ans)" +p03126,s484511987,Accepted,"N, M = map(int, input().split()) +ans = [0]*M + +for _ in range(N): + K, *A = map(int, input().split()) + for x in A: + ans[x-1] += 1 + +print(sum([1 for i in ans if i == N]))" +p02838,s642533259,Accepted,"s=[0 for i in range(60)] +def totwo(x): + return [int(x&(2**i)>0) for i in range(60)] + +n=int(input()) +a=list(map(lambda x:totwo(int(x)),input().split())) + +d=[a[0][i] for i in range(60)] +for i in range(1,n): + for j in range(60): + if a[i][j]: + s[j]+=i-d[j] + else: + s[j]+=d[j] + d[j]+=a[i][j] + +ss=0 +r=1 +mod=10**9+7 +for i in range(60): + ss=(ss+r*s[i])%mod + r=(r*2)%mod +print(ss) + +" +p03997,s549018392,Accepted,"# -*- coding: utf-8 -*- + +a = int(input()) +b = int(input()) +h = int(input()) + +print(int((a + b) * h / 2))" +p02780,s985487232,Accepted,"n,k = map(int, input().split()) +l = list(map(int, input().split())) + +# 期待値:マス目の総和/マス目の数, マス目の最大値+最小値[1]/2 +l = [(i+1)/2 for i in l] # 期待値に変換 + +# 累積和を取得 +from itertools import accumulate +cum = [0] + list(accumulate(l)) + +# 差分を考慮しつつ k個の和をリストする → 最大値が ans +sum_k = [] +for j in range(n-k+1): + sum_k.append(cum[k+j] - cum[j]) + +print(max(sum_k)) +" +p03821,s209334793,Accepted,"N = int(input()) +AB = [list(map(int, input().split())) for _ in range(N)] + +ans = 0 +for i in range(-1, -N - 1, -1): + a, b = AB[i] + m = (a + ans) % b + if m != 0: + ans += b - m + +print(ans)" +p03285,s167481716,Wrong Answer,"n=int(input()) +for i in range(1,26): + for j in range(1,26): + if n == 4*i+7*j: + print('Yes') + exit(0) +print('No')" +p02982,s058866424,Wrong Answer,"n,d = map(int, input().split()) +x = [list(map(int, input().split())) for _ in range(n)] + +cnt=0 +for i in range(n): + for j in range(i+1,n): + sum=0 + for k in range(d): + sum += (x[i][k]-x[j][k])**2 + route = sum**0.5 + if route.is_integer: + cnt += 1 + +print(cnt)" +p04043,s825361148,Wrong Answer,"tupni = [int(idx) for idx in input().split("" "")] +if tupni.sort() == [5,5,7]: + print(""YES"") +else: + print(""NO"") +" +p03679,s608620519,Wrong Answer,"x, a, b = map(int,input().split()) + +if x > abs(b - a): + print(""safe"") +elif x < abs(b - a): + print(""dangerous"") +else: + print(""delicious"")" +p03821,s204620111,Accepted,"n,*i=map(int,open(0).read().split()) +p=0 +for l in range(n): + a,b=i[-2-2*l:2*n-2*l] + g=b-(a+p)%b if (a+p)%b!=0 else 0 + p+=g +print(p)" +p03481,s401680308,Accepted,"x, y = map(int, input().split()) +mul = x +ans = 1 +for i in range(10 ** 18): + if mul*2 > y: + break + else: + mul *= 2 + ans += 1 +print(ans) +" +p02647,s516336016,Wrong Answer,"import numpy as np +n, k = map(int, input().split()) +array = list(map(int, input().split())) +array = np.array(array) +Array = np.array([0]*n) +print(array) +print(Array) +def plusone(n): + return n + 1 + +for j in range(k): + for i in range(n): + ai = array[i] + Array[max(i-ai, 0):min(i+ai+1,n+1)] = Array[max(i-ai, 0):min(i+ai+1,n+1)] + 1 + if j == k - 1: + answer = Array + array = Array + Array = np.array([0]*n) + +print(' '.join(map(str, answer))) + +" +p03721,s147836146,Accepted,"import sys +input = sys.stdin.readline +n,k = map(int,input().split()) +inf = 10**10 +parent = [inf]*n +q = {} +for i in range(n): + a,b = map(int,input().split()) + if a not in q.keys(): + parent[i] = a + q[a] = 0 + q[a] += b +parent.sort() +cnt = 0 +for p in parent: + cnt += q[p] + if cnt >= k: + print(p) + break +" +p03487,s308181854,Accepted,"import collections + +N = int(input()) +numbers = [int(i) for i in input().split()] + +c = collections.Counter(numbers) + +output = 0 + +for k, v in c.items(): + if k > v: + output += v + elif v > k: + diff = v - k + output += diff + +print(output)" +p02796,s991584677,Accepted,"n=int(input()) +X=[] +for i in range(n): + x,l=[int(_) for _ in input().split()] + X+=[(x-l,x+l)] +X.sort(key=lambda x:x[0]) +ans=n +tmp=X[0][1] +for i in range(1,n): + if tmp>X[i][0]: + ans-=1 + tmp=min(tmp,X[i][1]) + else: + tmp=X[i][1] +print(ans)" +p02771,s239149961,Accepted,"A = list(map(int, input().split())) +B = set(A) +if len(B) == 2: + print('Yes') +else: + print('No')" +p02971,s786499707,Accepted,"n = int(input()) +l = [] +for _ in range(n): + a = int(input()) + l.append(a) + +l2 = l +l2 = sorted(l2) +l2.reverse() +max = max(l) + + +ans = [] +if l2[1] == max: + for i in range(n): + print(max) +else: + for j in l: + if j != max: + print(max) + else: + print(l2[1])" +p03371,s479108781,Wrong Answer,"A, B, C, X, Y = map(int, input().split()) +faceAB = (A + B) / 2 +if faceAB <= C: + print(X * A + Y * B) +elif 2 * C <= A and 2 * C <= B: + print(2 * C * max(X, Y)) +else: + if X <= Y: + print(2 * C * min(X, Y) + ((Y - X) * B)) + else: + print(2 * C * min(X, Y) + ((X - Y) * A)) +" +p02607,s870816622,Wrong Answer,"n = int(input()) +lst = list(map(int, input().split())) + +c = 0 +for i in range(n): + if i % 2 == 1 and lst[i] % 2 == 1: + c += 1 +print(c)" +p02766,s075951630,Accepted,"N, K=map(int,input().split()) + +n=N +count=0 + +while n>0: + n=int(n/K) + count+=1 + +print(count)" +p02665,s941135246,Wrong Answer,"import sys +import numpy as np +def Ii():return int(sys.stdin.buffer.readline()) +def Mi():return map(int,sys.stdin.buffer.readline().split()) +def Li():return list(map(int,sys.stdin.buffer.readline().split())) + +n = Ii() +a = Li() +b = [0]*(n+1) +bm = [0]*(n+1) +b[0] = 1 +bm[-1] = a[-1] +for i in range(1,n+1): + bm[-1-i] = bm[-i]+a[-i-1] + b[i] = (b[i-1]-a[i-1])*2 +b = np.array(b) +bm = np.array(bm) +c = np.amin([[b],[bm]], axis=0) + +if np.any(c == 0): + print(-1) +else: + print(np.sum(c))" +p02714,s898619433,Wrong Answer,"# D - RGB Triplets +from collections import defaultdict +from functools import reduce +from operator import mul + + +def main(): + _, S = open(0).read().split() + indices, doubled_indices = defaultdict(list), defaultdict(set) + for i, c in enumerate(S): + indices[c].append(i) + doubled_indices[c].add(2 * i) + + cnt = reduce(mul, [len(i) for i in indices.values()]) + for x, y, z in (""RGB"", ""RBG"", ""BGR""): + cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y]) + print(cnt) + + +if __name__ == ""__main__"": + main() +" +p03000,s444192145,Accepted,"n, x = map(int, input().split()) +l = list(map(int, input().split())) +count = 0 +d = 0 +for i in range(1, n+1): + d += l[i-1] + if d <= x: + count += 1 + else: + break +print(count+1)" +p03543,s503136453,Accepted,"n = input() +print('Yes' if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] else 'No')" +p02765,s604509978,Accepted," +data = list(map(int, input().split())) +k = data[0] +r = data[1] + +if k >= 10: + print(r) +else: + inner_rate = r + (100*(10-k)) + print(inner_rate)" +p02910,s370802739,Accepted,"import sys + +S = input() + +def check(): + for i in range(len(S)) : + if i%2!=0 and S[i]==""R"" : + print(""No"") + sys.exit(0) + elif i%2==0 and S[i]==""L"" : + print(""No"") + sys.exit(0) +check() +print(""Yes"") +sys.exit(0)" +p02916,s346261105,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) +ret = sum(b) +for i in range(n-1): + if a[i] != n: + ret += c[a[i]-1] +print(ret)" +p03011,s162486162,Accepted,"pqr = list(map(int, input().split())) +pqr = sorted(pqr) +print(pqr[0] + pqr[1])" +p02730,s465269317,Wrong Answer,"s = input() +n = len(s) +mid = n//2 + +ans = 'No' + +if s[:mid] == s[mid+1:]: + q = s[:mid] + q_mid = len(q)//2 + + t = s[mid+1:] + t_mid = len(t)//2 + + if q[:q_mid] == q[q_mid+1:] and t[:t_mid] == t[t_mid+1:]: + ans = 'Yes' + +print(ans) + " +p03639,s759652208,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +n1 = 0 +n2 = 0 +n4 = 0 + +for ai in a: + if ai % 2 == 0: + if ai % 4 == 0: + n4 += 1 + else: + n2 += 1 + else: + n1 += 1 + +if n1 > n4: + if (n4 >= 1) and (n1 == (n4 + 1)) and n2 == 0: + print(""Yes"") + else: + print(""No"") +else: + print(""Yes"")" +p02678,s791638679,Accepted,"n, m = map(int, input().split()) +g = [[] for _ in range(n)] + +for _ in range(m): + a, b = map(int, input().split()) + a -= 1; b-=1; + g[a].append(b) + g[b].append(a) + +dist = [-1]*n +dist[0] = 0 +prev = [-1]*n + +que = [0] +pos = 0 +while pos < len(que) : + v = que[pos]; pos += 1; + for w in g[v]: + if dist[w] == -1 : + dist[w] = dist[v] + 1 + prev[w] = v; + que.append(w) + +if -1 in dist : + print(""No""); +else : + print(""Yes""); + for i in range(1,n): + print(prev[i]+1); + +" +p02623,s641527347,Accepted,"n, m, k = list(map(int, input().split())) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +a_time = [0] +b_time = [0] + +for i in range(n): + a_time.append(a_time[-1] + a[i]) +for j in range(m): + b_time.append(b_time[-1] + b[j]) + +j = m +cnt = 0 + +for i in range(n+1): + if a_time[i] > k: + continue + + while j > 0 and a_time[i] + b_time[j] > k: + j -= 1 + cnt = max(cnt, i + j) + +print(cnt) +" +p02641,s919988010,Accepted,"x,n = map(int,input().split()) +if n == 0: + print(x) + exit() +nums = list(map(int,input().split())) +cnt =0 +while True: + if x-cnt not in nums: + print(x-cnt) + break + if x+cnt not in nums: + print(x+cnt) + break + cnt +=1 +" +p02917,s678314233,Accepted,"n = int(input()) +b = list(map(int, input().split())) +maxa = [0] * n +maxa[0], maxa[n - 1] = b[0], b[n - 2] +for i in range(1, n - 1): + maxa[i] = min(b[i - 1], b[i]) +print(sum(maxa))" +p02723,s698198348,Wrong Answer,"answer = input() + +count = 0 +list = [] +for i in answer: + list.append(i) + +if len(answer) != 6: + print(False) + +elif list[2] == list[3] and list[4] == list[5]: + print(True) + +else: + print(False) +" +p03262,s006349636,Wrong Answer,"def gcd(a, b): + if b == 0: + return a + else: + return gcd(b, a % b) + + +def main(): + n, s = map(int, input().split()) + xs = sorted(list(map(int, input().split()))) + + for i, x in enumerate(xs): + if i == 0: + ans = x-s + else: + ans = gcd(ans, x-s) + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03261,s062733232,Wrong Answer,"N = int(input()) +W=[] +ss=True +for i in range (N): + W.append(input()) + + +for t in range (N): + if W[t-1][-1]==W[t][0]: + ss=True + else: + ss=False +if len(W)!=N: + ss=False + +if ss==False: + print(""No"") +else: + print(""Yes"") +" +p02684,s839433517,Accepted,"n,k = map(int, input().split()) +a = list(map(int,input().split())) +ans = 1 +c = [1] +d = [0]*(n+5) +d[1] = 1 +for j in range(1,2*n): + i = a[c[-1]-1] + if d[i] == 1: + g = i + break + # if i in set(c): + # g = i + # break + d[i] = 1 + c.append(i) +s = c.index(g) +r = len(c)-s +if k <=s: + print(c[k]) +else: + b = (k-s)%r + print(c[s+b])" +p03760,s723445856,Accepted,"o=input() +e=input() +s="""" +for i in range(len(o)+len(e)): + if i%2==0: + s+=o[i//2] + else: + s+=e[i//2] +print(s)" +p03548,s962727061,Wrong Answer,"import sys +input = sys.stdin.readline +X, Y, Z = [int(x) for x in input().split()] +ans = 1 +X -= Y +ans += (X // (Y + Z)) +print(ans)" +p02813,s675347212,Accepted,"import itertools +import sys +input = sys.stdin.readline + +n = int(input()) +p = tuple(map(int,input().split())) +q = tuple(map(int,input().split())) + +s = list(range(1,n+1)) +s_list = list(itertools.permutations(s)) +print (abs(s_list.index(p) - s_list.index(q)))" +p02756,s943619382,Wrong Answer,"s = input() +q = int(input()) +inv = 1 +for i in range(q): + t = input() + if t[0] == '1': + inv *= -1 #s = s[::-1] + else: + _, f, c = map(str, t.split()) + if f =='1' and inv == 1: + s = c+s + else: + s = s+c + +print(s[::inv])" +p02912,s102599361,Accepted,"import heapq + +N, M = map(int, input().split()) +A = list(map(int, input().split())) +A = list(map(lambda x: x * (-1), A)) +heapq.heapify(A) + +for _ in range(M): + tmp = heapq.heappop(A) * (-1) + tmp //= 2 + heapq.heappush(A, tmp * (-1)) + +print(-sum(A)) +" +p03286,s282336692,Accepted,"import math +import sys +n=int(input()) +ans=[] +syo=n +if n==0: + print(0) + sys.exit(0) +while syo!=0: + zan=syo%-2 + if zan==-1: + zan=1 + ans.insert(0,zan) + syo=math.ceil(syo/-2) +for i in range(len(ans)): + print(ans[i],end="""")" +p03681,s613228322,Accepted,"from math import factorial +N,M=map(int,input().split()) +ans=0 +if abs(N-M)>1: + ans=0 +else: + if N==M: + a=N + b=M + ans=factorial(a)*factorial(b)*2 + else: + a=max(N,M) + b=min(N,M) + ans=factorial(a)*factorial(b) +print(ans%(10**9+7))" +p03485,s198067296,Accepted,"import sys +import math +import itertools +import collections +import heapq +import re +import numpy as np + +rr = lambda: sys.stdin.readline().rstrip() +rs = lambda: sys.stdin.readline().split() +ri = lambda: int(sys.stdin.readline()) +rm = lambda: map(int, sys.stdin.readline().split()) +rl = lambda: list(map(int, sys.stdin.readline().split())) +inf = float('inf') +mod = 10**9 + 7 + + +a, b = rm() +print(math.ceil((a+b)/2)) + + + + + + + + +" +p03013,s917116345,Accepted,"N,M = map(int,input().split()) +A = set([int(input()) for i in range(M)]) +MOD = 10**9+7 + + + +dp = [0]*(N+1) +dp[0] = 1 +for i in range(N): + if i+1 not in A: + dp[i+1] += dp[i] + dp[i+1] %= MOD + if i+2 <= N and i+2 not in A: + dp[i+2] += dp[i] + dp[i+2] %= MOD +print(dp[-1]%MOD) +" +p02628,s171713323,Accepted,"n,k=[int(x) for x in input().split("" "")] +l=[int(x) for x in input().split("" "")] +l.sort() +s=0 +for i in range(k): + s=s+l[i] +print(s) +" +p04044,s416005931,Accepted,"n,l=map(int,input().split()) +li=[] +while n>0: + a=input() + li.append(a) + n-=1 +kk=sorted(li) +moji='' +for x in kk: + moji+=x +print(moji)" +p02641,s265847487,Wrong Answer,"import sys + +x, n = map(int, input().split()) + +if n == 0: + print(x) + sys.exit() + +if n == 1: + print(abs(x - int(input()))) + sys.exit() + +p = list(map(int, input().split())) + +p.sort() +min = [100, 100] + +for i in range(101): + if i in p: + continue + hoge = abs(x - i) + if min[0] > hoge: + min[0] = hoge + min[1] = i + +print(min[1])" +p02688,s821565899,Wrong Answer,"n,k = map(int,input().split()) + +d = [] +a = [] + +for _ in range(k): + d.append(int(input())) + a.append(list(map(int,input().split()))) + +ans = [1] * n +for i in range(k): + for ai in range(d[i]): + if ans[ai] == 1: + ans[ai] = 0 + + +print(sum(ans))" +p03611,s008940285,Accepted,"#!/usr/bin/env python3 +input() +(*a, ) = map(int, input().split()) +d = (-1, 0, 1) +ans = [0] * (10**5 + 1) +for i in a: + for j in d: + if 0 <= i + j <= 10**5: + ans[i + j] += 1 +print(max(ans)) +" +p02951,s468865822,Accepted,"A, B , C = map(int, input().split()) +x = A - B +if (x <= C): + print(C - x) +else: + print(0) + " +p03479,s287284133,Wrong Answer,"a,b=input().split() +a=int(a) +b=int(b) +c=b/a +i=1 +x=0 +while i<=c: + i=2*i + x=x+1 +print(x)" +p03720,s562425885,Wrong Answer,"N, M = map(int, input().split()) + +pairs = [] +for i in range(M): + pairs.append(list(map(int, input().split()))) + +for i in range(1,N+1): + s = set([]) + for pair in pairs: + if i in pair: + s |= set(pair) + print(len(s)-1)" +p02570,s855423496,Wrong Answer,"d,t,s=map(int,input().split()) +if d//s<=t: + print(""Yes"") +else: + print(""No"")" +p02947,s430322735,Accepted,"n = int(input()) +lst = [] +pair = 0 +for i in range(n): + st = ''.join(sorted(list(input()))) + lst.append(st) +lst = sorted(lst) +lst += ['end'] +pre = '' +tmp_cnt = 0 +cnt = 0 +for i in lst: + if i == pre: + tmp_cnt += 1 + else: + cnt += sum([j for j in range(tmp_cnt + 1)]) + tmp_cnt = 0 + pre = i +print (cnt)" +p02900,s446422015,Accepted,"def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + +A,B = map(int,input().split()) +A = prime_factorize(A) +B = prime_factorize(B) +C = [] +for i in A: + if i in B: + C += i, +print(1+len(set(C)))" +p02627,s846102571,Wrong Answer,"a = input() +print('A' if a.islower() else 'a')" +p02556,s181555642,Wrong Answer,"import sys +input = sys.stdin.readline +N = int(input()) +mn = 10 ** 10 +mx = 0 +for _ in range(N): + x, y = map(int, input().split()) + mn = min(mn, x + y) + mx = max(mx, x + y) +print(abs(mx - mn))" +p02963,s962262688,Accepted,"S = int(input()) + +# (X1, Y1) は原点 +# (X2, Y2) = (10 ** 9, 1) +# S = 10 ** 9 * Y3 - X3 + +Y3 = (S + 10 ** 9 - 1) // (10 ** 9) +X3 = Y3 * (10 ** 9) - S + +print(0, 0, 10 ** 9, 1, X3, Y3)" +p03815,s641136050,Accepted,"x = int(input()) +count = 0 + +if 6 < x <= 11: + print(2) +elif x <= 6: + print(1) +else: + initcount = x // 11 + if initcount: + count += initcount*2 + x -= initcount * 11 + mod = x % 11 + if 6 < mod <= 11: + count += 2 + elif 0 < mod <= 6: + count += 1 + else: + pass + print(count)" +p02793,s208732427,Accepted,"import fractions +from functools import reduce + + +def MinB(x, y): + return (x * y) // fractions.gcd(x, y) + +def MinB_list(numbers): + return reduce(MinB, numbers, 1) + +N = int(input()) +AList = list(map(int, input().split())) + +tmp = MinB_list(AList) +result = 0 +for i in range(0, N): + result += tmp // AList[i] + +print(result % (10 ** 9 + 7))" +p03852,s131478345,Wrong Answer,"c=raw_input().split() +if c==""a,e,i,o,u"": + print ""vowel"" +else: + print ""consonant""" +p03679,s561361667,Accepted,"x,a,b = map(int,input().split()) +if a >= b: + print(""delicious"") +elif a+x >= b: + print(""safe"") +else: + print(""dangerous"")" +p02547,s082742625,Accepted,"N = int(input()) +D = [list(map(int, input().split())) for _ in range(N)] + +for i in range(2, N): + if D[i - 2][0] == D[i - 2][1] and D[i - 1][0] == D[i - 1][1] and D[i][0] == D[i][1]: + print('Yes') + exit() + +print('No')" +p04029,s127274205,Wrong Answer,"N=int(input()) +ans=0 + +for i in range(0,N+1): + ans+=1 +print(ans) +" +p02973,s567135415,Accepted,"import bisect +import sys +input = sys.stdin.readline +N = int(input()) +A = [int(input()) for _ in range(N)] + +dp = [float('inf')]*(N+1) +for a in A[::-1]: + idx = bisect.bisect_right(dp, a) + dp[idx] = a + +ans = 0 +for n in dp: + if n != float('inf'): + ans += 1 +print(ans)" +p02766,s795394188,Accepted,"n,k = map(int,input().split()) +for i in range(n): + n = n // k + if n == 0: + print(i + 1) + exit()" +p02899,s516460019,Accepted,"N=int(input()) +A=list(map(int,input().split())) +Alist=[] +for i in range(N): + Alist.append((A[i],i+1)) +Alist=sorted(Alist,key=lambda x: x[0]) +for i in range(N): + print(Alist[i][1],end="" "") + " +p02924,s169435356,Accepted,"n = int(input()) +print(n*(n-1)//2)" +p02753,s647432740,Accepted,"N = input() + +if ""BBB"" == N or ""AAA""==N: + print(""No"") + +else: + print(""Yes"")" +p03910,s015716368,Wrong Answer,"n = int(input()) + +ans = 0 +f = 0 +for i in range(1,n+1): + ans += i + if ans-i+1 >= n: + c = i + f = c-1 + if ans >= n: + c = i + break + +for i in range(1,c+1): + if i == f: + pass + else: + print(i)" +p02796,s214581107,Accepted,"N = int(input()) + +robots = [] + +# ロボットを設定する +for _ in range(N): + x, l = map(int, input().split()) + robots.append([x-l, x+l]) + +# 手の届く最大値でソートする +robots = sorted(robots, key=lambda x: x[1]) + +# Maxが小さいもの優先で選択する +pos = robots[0][1] +cnt = 1 +for i in range(1, len(robots)): + robo = robots[i] + if robo[0] >= pos: + pos = robo[1] + cnt += 1 + +print(cnt)" +p03943,s780156334,Wrong Answer,"a = list(map(int,input().split())) +if sum(a) % 2 == 0: + print(""Yes"") +else: + print(""No"") + +" +p04005,s848558031,Wrong Answer,"a, b, c = map(int, input().split()) + +ans = 0 if a*b*c%2 == 0 else int(a*b*c/max(a, b, c)) +print(ans)" +p02706,s785558993,Wrong Answer,"import sys + +n, m = map(int, sys.stdin.readline().split()) + +line = sys.stdin.readline().split() +nums = list(map(int, line)) + +print(n - sum(nums)) +" +p03386,s430331401,Accepted,"a, b, k = map(int, input().split()) + +ans = [] +for i in range(a, min(b, a + k)): + if i in ans: + continue + else: + ans.append(i) +for i in range(max(a, b - k + 1), b + 1): + if i in ans: + continue + else: + ans.append(i) + +for i in range(len(ans)): + print(ans[i])" +p03150,s842869284,Accepted,"import sys +s = input() +l = len(s) +k = 'keyence' # len(k)==7 +if l < 7: + print('NO') + sys.exit() +diff = l - 7 +flag = False +for i,kk in enumerate(k): + #print(s[:i+1],k[:i+1],s[i+diff+1:],k[i+1:]) + if s[:i+1] == k[:i+1] and s[i+diff+1:] == k[i+1:]: + flag = True +if flag: + print('YES') +else: + print('NO')" +p02951,s106518770,Accepted,"water1_limit, water1, water2 = map(int, input().split()) + +in_water2 = water2 - (water1_limit - water1) +in_water2 = max(0, in_water2) +print(in_water2) +" +p03324,s404184201,Wrong Answer,"d, n = map(int,input().split()) + +i = 0 +count = 0 + +while not count == n: + i += 1 + if i % 100 == 0: + continue + else: + count += 1 + +print(i)" +p03835,s950123903,Accepted,"k, s = list(map(int, input().split(' '))) + +count = 0 + +for i in range(k + 1): + for j in range(k + 1): + if 0 <= s - (i + j) <= k: + count += 1 +print(count) +" +p03434,s069076626,Accepted,"N = int(input()) +A = list(map(int, input().split())) +A = sorted(A, reverse=True) + +a, b = 0, 0 +for i in range(N): + if i % 2 == 0: + a += A.pop(0) + else: + b += A.pop(0) + +print(a-b)" +p02946,s883660784,Wrong Answer,"K,X=map(int,input().split()) +a=[] +for i in range(0,K): + a.append(X-i) +for i in range(1,K): + a.append(X+i) +s=a.sort() +print(s)" +p02711,s655512632,Accepted,"N = input() +if '7' in N: + print('Yes') +else: + print('No')" +p04019,s690394283,Accepted,"S = input() +if 'N' in S and 'W' in S and 'S' in S and 'E' in S: + print('Yes') +elif 'N' in S and 'S' in S and not 'W' in S and not 'E' in S: + print('Yes') +elif 'E' in S and 'W' in S and not 'N' in S and not 'S' in S: + print('Yes') +else: + print('No')" +p03067,s480228012,Accepted,"import bisect,collections,copy,heapq,itertools,math,string +import sys +def S(): return sys.stdin.readline().rstrip() +def M(): return map(int,sys.stdin.readline().rstrip().split()) +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +def LS(): return list(sys.stdin.readline().rstrip().split()) +a, b, c = M() +l = [a, b, c] +l.sort() +if l[1] == c: + print('Yes') +else: + print('No')" +p02811,s610987694,Accepted,"def main(): + K,X=map(int,input().split()) + if K*500 >= X: + print(""Yes"") + else: + print(""No"") +if __name__ == '__main__': + main() +" +p02691,s443477542,Accepted,"n = int(input()) +A = list(map(int, input().split())) +A_j = {} +for i, a in enumerate(A): + if A_j.get(i - a): + A_j[i - a] += 1 + else: + A_j[i - a] = 1 + +r = 0 +for i, a in enumerate(A): + t = A_j.get(a + i) + if t: + r += t + +print(r) +" +p03419,s211176308,Accepted,"N,M=map(int,input().split()) + +if N==1 and M==1: + print(1) +elif N==1: + print(M-2) +elif M==1: + print(N-2) +else: + print((N-2)*(M-2))" +p02813,s674831293,Accepted,"from itertools import permutations +def resolve(): + N = int(input()) + P = tuple(map(int, input().split())) + Q = tuple(map(int, input().split())) + + ls = list(permutations(range(1, N+1))) + ans = abs(ls.index(P) - ls.index(Q)) + print(ans) + return + +resolve()" +p03264,s101265391,Accepted,"k=int(input()) +if k%2==0: + print((k//2)**2) +else: + print((k//2)*(k//2+1))" +p02847,s449316675,Accepted,"S = input() + +if S == 'SUN': + print(7) +elif S == 'MON': + print(6) +elif S == 'TUE': + print(5) +elif S == 'WED': + print(4) +elif S == 'THU': + print(3) +elif S == 'FRI': + print(2) +elif S == 'SAT': + print(1)" +p03211,s079910344,Accepted,"s = input() + +dif = [] + +for i in range(len(s)-2): + x = int(s[i:i+3]) + dif.append(abs(753-x)) +print(min(dif))" +p02675,s888640922,Accepted,"N = int(input()) +ans = ""hon"" +a = N % 10 +if a in [0, 1, 6, 8]: + ans = ""pon"" +if a == 3: + ans = ""bon"" + +print(ans)" +p02578,s854571497,Accepted,"N = int(input()) +N_List = list(map(int,input().split())) +ct = 0 +for i in range(1,N): + if N_List[i] < N_List[i-1]: + ct += N_List[i-1] - N_List[i] + N_List[i] = N_List[i-1] + + +print(ct)" +p02777,s199685293,Accepted,"S,T = list(map(str,input().split())) +A,B = list(map(int,input().split())) +u = input() + +if u == S: + print(str(A-1) + "" "" +str(B)) +else: + print(str(A) + "" "" +str(B-1))" +p02832,s520676555,Accepted,"n = int(input()) +l = list(input().split()) + +target_num = 1 +for i in range(n): + if target_num == int(l[i]): + target_num += 1 + else: + target_num = target_num + +if target_num == 1: + print(""-1"") +else: + print(n - target_num +1) +" +p02818,s718463635,Accepted,"a,b,k = map(int,input().split()) + +if a>=k: + a-=k + print(a,b) +else: + k -=a + a =0 + b =max(0,b-k) + print(a,b) " +p03556,s414711958,Accepted,"N=int(input()) +n=int(N**0.5) +print(n**2)" +p02597,s846735176,Accepted,"n=int(input()) +c=input() +c1=c.count(""R"") +c2=c[:c1].count(""W"") +print(c2)" +p02622,s894530600,Accepted,"s=input() +t=input() +ans=0 +for i in range(len(s)): + if s[i] != t[i]: + ans+=1 +print(ans) +" +p02946,s453030555,Wrong Answer,"X,K = map(int, input().split()) +max = X + K +min = X - K + 1 +for i in range(min,max): + print(i,end="" "")" +p02766,s180056343,Accepted,"import sys +input = sys.stdin.readline + + +def main(): + N, K = map(int, input().split()) + answer = 1 + while N >= K: + N //= K + answer += 1 + print(answer) + + +if __name__ == '__main__': + main() +" +p03565,s535868158,Accepted,"def match(s,t): + for i in range(m): + if s[i]==t[i] or s[i]=='?': + continue + return False + return True +s = list(input()) +t = list(input()) +n = len(s) +m = len(t) +i = n-m +found = False +while i >= 0: + if match(s[i:i+m],t): + found = True + for j in range(i,i+m): + s[j] = t[j-i] + break + i-=1 +if found: + for i in s: + if i=='?': + print('a',end='') + else: + print(i,end='') + print() +else: + print(""UNRESTORABLE"")" +p02832,s197548313,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +ans=-1 +temp=1 +for i in range(n): + if a[i]==temp: + temp=temp+1 + elif ans==-1: + ans=ans+2 + else: + ans=ans+1 +print(ans)" +p02548,s257161358,Accepted,"N = int(input()) +ans = 0 + +for n in range(1,N): + ans+=(N-1)//n + +print(ans)" +p03013,s085819032,Accepted,"MOD = 10**9+7 + +n, m = map(int,input().split()) + +A = [0]*(n+1) +for i in range(m): + a = int(input()) + A[a] = 1 + +dp = [0]*(n+1) +dp[0] = 1 +if not A[1]: + dp[1] = 1 + +for i in range(2,n+1): + if A[i]: + continue + dp[i] = (dp[i-1]+dp[i-2])%MOD + +print(dp[n])" +p03017,s044033312,Accepted,"N,A,B,C,D = map(int,input().split()) +A -= 1 +B -= 1 +C -= 1 +D -= 1 +S = input() +if C < D or C < B: + if '##' in S[A:C+1] or '##' in S[B:D+1]: + print('No') + else: + print('Yes') +else: + if '##' in S[A:C+1]: + print('No') + else: + if '...' not in S[B-1:D+2]: + print('No') + else: + print('Yes')" +p02700,s380871994,Accepted,"a, b, c, d = map(int, input().split()) +while a > 0 and c > 0: + c -= b + a -= d +if c <= 0: + print('Yes') +else: + print('No')" +p02773,s470722693,Accepted," +n = int(input()) + +s = [] +for i in range(n): + s.append( input()) + +x = set(s) + +dic = {} +for i in x: + dic[i] = 0 + + +for i in s: + dic[i] +=1 + +max_dic = max(dic.values()) + +ans = [] +for i in x: + if dic[i] == max_dic: + ans.append(i) + + +for i in sorted(ans): + print(i) + + +" +p02917,s329824073,Accepted,"n = int(input()) +b = list(map(int,input().split())) +a = [10**6]*n + +for i in range(n-1): + a[i] = min(a[i],b[i]) + a[i+1] = b[i] + +print(sum(a))" +p02714,s899063276,Accepted,"n = int(input()) + +str = input() + +r = str.count('R') +g = str.count('G') +b = str.count('B') +sum = r * g * b +for i in range(n-2): + for j in range(i+1, n-1): + k = 2 * j - i + if k < n: + if str[i] != str[j] and str[i] != str[k] and str[j] != str[k] : + sum -= 1 + +print(sum)" +p02594,s126447135,Wrong Answer,"t = int(input()) + +if t > 30: + print(""Yes"") +else: + print(""No"")" +p03699,s892178436,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + N = int(input()) + s = [0] * N + for i in range(N): + s[i] = int(input()) + + s.sort() + ans = sum(s) + if ans % 10 == 0: + for i in range(N): + if s[i] % 10 != 0: + ans -= s[i] + break + if i == N - 1: + ans = 0 + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03994,s252374124,Accepted,"s = input() +K = int(input()) +alh = [chr(i) for i in range(97, 97 + 26)] +ans = """" +d = {} +for n,i in enumerate(alh): + d[i] = (26-n)%26 +for i in s[:-1]: + if K >= d[i]: + K -=d[i] + ans += ""a"" + else: + ans += i +ans += chr(97+(ord(s[-1])+K-97)%26) +print(ans)" +p02922,s319288269,Wrong Answer,"A, B = map(int, input().split()) + +kuti = 0 +i = 0 +while kuti < B: + kuti = A * i - 1 + i += 1 +print(i-1) +" +p02577,s804104246,Accepted,"if int(input())%9 == 0: + print('Yes') +else: + print('No')" +p03427,s114323275,Accepted,"# import sys +r = input() +# print(r) +ans = sum(list(map(int, r))) + +if r[0] == 1: + print(max(ans, (len(r)-1)*9)) +else: + print(max(ans, int(r[0])-1+(len(r)-1)*9)) +" +p02792,s423508388,Accepted,"import sys + +def main(): + N = int(input()) + + arr = [[0] * 10 for i in range(10)] + for x in range(1, N+1): + s = str(x) + arr[int(s[0])][int(s[-1])] += 1 + + ans = 0 + for y in range(1,10): + for z in range(1,10): + ans += arr[y][z] * arr[z][y] + + print(ans) + +main()" +p03449,s590677843,Accepted,"N = int(input()) +table = [[int(i) for i in input().split()] for m in range(2)] +get_candies = [] +for i in range(0,N): + get_candies.append(sum(table[0][:i+1]) + sum(table[1][i:])) +print(max(get_candies))" +p03760,s163063598,Wrong Answer,"o=str(input()) +e=str(input()) +ans=[] +if len(o)==len(e): + for i in range(len(o)): + ans.append(o[i]+e[i]) + print(ans,end='') +else: + for i in range(len(e)): + ans.append(o[i]+e[i]) + ans.append(o[len(o)-1]) + print(ans,end='') + " +p02659,s080342201,Accepted,"A, B = map(str, input().split()) + +A = int(A) +B1, B2 = map(int, B.split('.')) +ans = (A * B1) + int(A * B2 // 100) + +print(ans)" +p02598,s336750301,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +def is_ok(L): + count = 0 + for a in A: + count += a // L + if a % L == 0: + count -= 1 + return count <= K + +ng = 0 +ok = max(A) +while abs(ok - ng) > 1: + mid = (ok + ng) // 2 + if is_ok(mid): + ok = mid + else: + ng = mid +print(ok) +" +p03136,s270877282,Accepted,"def nyu(): + N = int(input()) + L = list(map(int,input().split())) + L.sort() + + return N,L + +def check(N,L): + sum =0 + + for n in range(N-1): + sum += L[n] + if sum > L[N-1]: + print(""Yes"") + else: + print(""No"") + + + + +N,L =nyu() +check(N,L) + + + + + +" +p03137,s892704540,Accepted,"def nyu(): + N, M = map(int, input().split()) + X = list(map(int,input().split())) + X.sort() + return N,M,X + + +def kansu(N,M,X): + + x_abs = [X[m+1] -X[m] for m in range(M-1)] +# print(x_abs) + + + x_abs.sort() + + koma_max = 0 + for m in range(M-N): + koma_max += x_abs[m] + + print(koma_max) + + +N,M,X = nyu() +#print(X) + +if M == 1: + print(0) +else: + kansu(N,M,X) + +#print(S) + +" +p02958,s546535606,Accepted,"n = int(input()) +p = list(map(int, input().split())) +p_sort = sorted(p) +non_0 = 0 + +for i in range(n): + diff = p[i] - p_sort[i] + if diff != 0: + non_0 += 1 + if non_0 >2: + print('NO') + exit() + +print('YES')" +p02820,s819939202,Wrong Answer,"n,k = map(int,input().split()) +li = list(map(int,input().split())) +t = list(input()) +ans = [] +for i in t: + if i == 'r': + ans.append(li[2]) + elif i == 's': + ans.append(li[0]) + else: + ans.append(li[1]) +for i in range(len(ans)): + if k <= i and ans[i]==ans[i-k]: + ans[i] =0 +print(sum(ans)) +" +p02744,s957164578,Accepted,"N = int(input()) +ans_list = [""a""] +alphabet = [chr(ord(""a"") + i) for i in range(N)] + +for i in range(N - 1): + ans_list = [ ans + x for ans in ans_list for x in alphabet[:len(set(ans)) + 1]] + +for ans in ans_list: + print(ans) +" +p02621,s047615151,Accepted,"#!/usr/bin/env python3 +import sys + + +def II(): return int(sys.stdin.readline()) + + +def MI(): return map(int, sys.stdin.readline().split()) + + +def LI(): return list(map(int, sys.stdin.readline().split())) + + +def main(): + N = II() + print(N + N**2 + N**3) + + +main() +" +p02622,s341235148,Accepted,"S = input() +T = input() + +ans = 0 + +for i in range(len(S)): + ans += S[i] != T[i] + +print(ans)" +p03086,s853027064,Wrong Answer,"a = list(input()) +ans = [] +count = 0 +for i in a: + + if i == 'A': + count +=1 + elif i == 'C': + count+=1 + elif i == 'G': + count+=1 + elif i == 'T': + count+=1 + else: + ans.append(count) + count = 0 +if len(ans) == 0: + ans.append(count) +print(max(ans))" +p03672,s942430774,Accepted,"S = input() +ans = 0 +for i in range(2,len(S),2): + if S[:i // 2] == S[i // 2:i]: ans = i +print(ans) " +p02933,s564917834,Accepted,"a=int(input()) +s=input() +if a>=3200: + print(s) +else: + print('red')" +p02552,s010917625,Accepted,"bin = [1,0] +print(bin[int(input())])" +p03274,s207366892,Accepted,"import sys +input = sys.stdin.readline + +X = [] +K = 0 +def fullsearch(): + for l, r in zip(X, X[K-1:]): + distance = abs(r - l) + yield distance + abs(r) + yield distance + abs(l) + +def main(): + global X, K + _, K = map(int, input().split()) + X = list(map(int, input().split())) + + print(min(fullsearch())) + +main()" +p02831,s472413847,Wrong Answer,"A,B=map(int,input().split()) +x=min(A,B) +y=max(A,B) +check=1 +##x<=y +#####while break############## +if y%x==0: + print(y) +#print(root) +else: + root=round((x**(1/2))) + for i in range(2,root): + if x%i==0 and y%i==0: + x/=i + y/=i + check*=i + i=2 + root=round((x**(1/2))) + print(int(check*x*y)) + + " +p03407,s729753980,Wrong Answer,"a,b,c=map(int,input().split()) +if a+b > c: + print(""Yes"") +else: + print(""No"")" +p02933,s235389852,Wrong Answer,"a=int(input()) +s=input() +if a>=3200: + print(s) +else: + print('Yes')" +p03821,s725602696,Accepted,"n = int(input()) +ab = [] +for _ in range(n): ab.append([int(x) for x in input().split()]) +c = 0 +for a, b in ab[::-1]: + if b == 1 or (a + c) % b == 0: continue + else: c += b - (a + c) % b +print(c)" +p03862,s476399628,Accepted,"N, x = map(int, input().split()) +a = list(map(int, input().split())) + +y = min(a[0], x) +ans = a[0]-y +for i in range(1, N): + z = a[i] + w = max(y+z-x, 0) + y = z-w + ans += w + +print(ans)" +p03437,s819063335,Wrong Answer,"X, Y = map(int, input().split()) +if Y % X == 0 or X % Y == 0: + ans = -1 +else: + ans = X +if ans > 10**18: + ans = -1 +if X == 1 and Y != 1: + ans = Y + 1 +print(ans)" +p03681,s502391522,Accepted,"def factorial(n, mod=10**9+7): + a = 1 + for i in range(1,n+1): + a = a * i % mod + return a + +N, M = map(int, input().split()) +MOD = 10**9 + 7 +if N < M: + N, M = M, N + +if N > M + 1: + ans = 0 +elif N == M + 1: + ans = (factorial(N) * factorial(M)) % MOD +else: + ans = (2 * factorial(N) ** 2) % MOD + +print(ans)" +p03359,s041259544,Accepted,"a,b = map(int, input().split()) +print(a if b>=a else a-1)" +p02720,s151544574,Accepted,"def function(n): + string = str(n) + for i in range(len(string) - 1): + error = int(string[i]) - int(string[i + 1]) + if error > 1: + return i + 1, error + elif error < -1: + return i, abs(error) + return -1, 0 + +k = int(input()) +ans = [] +n = 1 +while len(ans) < k: + m, error = function(n) + if m == -1: + ans.append(n) + n += 1 + else: + n = n + (error - 1) * (10 ** (len(str(n)) - m - 1)) - n % (10 ** (len(str(n)) - m - 1)) +print(ans[-1])" +p02607,s140376300,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +cnt = 0 +for i in range(N - 1): + if (i + 1) % 2 == 1 and a[i + 1] % 2 ==1: + cnt += 1 + else: + cnt += 0 +print(str(cnt))" +p02897,s775783399,Accepted,"n=int(input()) +print(((n+1)//2)/n)" +p02553,s663344524,Wrong Answer,"a, b, c, d = [int(e) for e in input().split("" "")] +if((0 <= a or 0 <= c) and (0 <= b and 0 <= d)): + #print(""A"") + print(b * d) +elif((a < 0 and b < 0) and (0 <= c and 0 <= d)): + #print(""B"") + print(b * c) +elif((c < 0 and d < 0) and (0 <= a and 0 <= b)): + #print(""C"") + print(d * a) +elif(a < 0 and b < 0 and c < 0 and d < 0): + #print(""D"") + print(a * d) +elif((a < 0 and 0 <= b) and (c < 0 and 0 <= d)): + print(max((a * c), (b * d)))" +p02584,s504493974,Wrong Answer,"import sys +X, K, D = map(int,input().split()) +cnt = 0 +a = X +b = 999999999 +tmp = 0 +if X >= K*D: + if K % 2 == 0: + print(X - K*D) + else: + print(X - K*D + D) + sys.exit() +if K % 2 == 0: + tmp = int(X/D) + #print(tmp) + if tmp% 2 == 0: + a = X - D*tmp + else: + a = X - D*tmp + D + b = a - D*2 +else: + tmp = int(X/D) + #print(tmp) + if tmp% 2 == 1: + a = X - D*tmp + else: + a = X - D*tmp + D + b = a - D*2 +print(min(abs(a),abs(b)))" +p03136,s912755083,Wrong Answer,"n = int(input()) +l = list(map(int, input().split())) +l.sort() +cnt = 0 +for i in l[:n - 1]: + cnt += 1 + #print(i) +if cnt > l[n - 1]: + print(""Yes"") +else: + print(""No"") + " +p03827,s265161050,Wrong Answer,"N = int(input()) +S = input() +x = 0 + +for i in S: + if i == ""I"": + x += 1 + elif i == ""D"": + x -= 1 +print(x)" +p03043,s317260003,Wrong Answer,"nums = input().split() +N = int(nums[0]) +K = int(nums[1]) +totalProb = 0 + +for i in range(N): + x = i + 1 + tempProb = 1/N + + while x < K: + tempProb = tempProb / 2 + x = x * 2 + print(tempProb) + + totalProb += tempProb + +if N > K: + totalProb += (N - K + 1) * 1/N + +print(totalProb) + + +" +p03680,s960467483,Accepted,"def main(): + N, *A = map(int, open(0).read().split()) + count = 0 + cur = 1 + while count < N: + count += 1 + cur = A[cur - 1] + if cur == 2: + print(count) + return + print(-1) + +if __name__ == '__main__': + main() +" +p03637,s643418344,Wrong Answer,"N=int(input()) +a=list(map(int,input().split())) +l=[0]*N +for i in range(N): + if a[i]%4: + if a[i]%2:l[i]=1 + else:l[i]=2 + else:l[i]=4 +print('Yes'if(l.count(1)+(1 if l.count(2)else 0))//2<=l.count(4)else'No')" +p03011,s635271567,Wrong Answer,"a, b, c = map(int, input().split()) +d = a + b +f = a + c +g = b + c +if d < f and d < g : + print(d) +elif f < d and f < g : + print(f) +elif g < f and g< d : + print(d) +elif d == f: + print(d) +elif f == g: + print(f) +elif g == d: + print(g)" +p03438,s375164576,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +diff=sum(b)-sum(a) + +onesum=0 +twosum=0 +for i in range(n): + if(a[i]>b[i]): + onesum+=a[i]-b[i] + elif(a[i]= N: + break + dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j])) + +print(dp[-1])" +p03607,s250280694,Accepted,"N = int(input()) +a = [input() for _ in range(N)] +a = sorted(a) +#print(a) +c = 0 +ans = 0 +for i in range(N): + c += 1 + if i == N-1: + if c % 2 == 1: + ans += 1 + elif a[i] != a[i+1]: + #print(a[i]) + if c % 2 == 1: + ans += 1 + c = 0 + +print(ans) +" +p02621,s039120576,Accepted,"a = int(input()) +print(a + a*a + a*a*a)" +p02570,s707097479,Accepted,"D,T,S = map(int,input().split()) +x = D / S +if x <= T: + print(""Yes"") +else: + print(""No"")" +p04031,s170440995,Accepted,"n=int(input()) +a=list(map(int,input().split())) +s=sum(a) +s//=n +cost=0 +for i in a: + cost+=(i-s)*(i-s) +ans=cost +s+=1 +cost=0 +for i in a: + cost+=(i-s)*(i-s) +ans=min(ans,cost) +print(ans) +" +p02554,s869559144,Accepted,"n=int(input()) +a=10**n-2*9**n+8**n +print(a%(10**9+7)) +" +p02603,s390576465,Accepted,"N=int(input()) +A=list(map(int,input().split())) + +m=1000 +n=0 +flag=0 +for i in range(N-1): + if flag==1: + m += n*A[i] + n = 0 + flag = 0 + + if A[i+1]>A[i]: + buy = m//A[i] + n += buy + m -= buy*A[i] + flag=1 + +if flag == 1: + m += n*A[-1] + n = 0 + flag = 0 + +print(m)" +p03719,s564194472,Accepted,"a,b,c = (int(x) for x in input().split()) +if a <= c <= b: + print ('Yes') +else: + print ('No') +" +p02813,s746136445,Accepted,"import itertools +N = int(input()) +P = list(map(int,input().split())) +Q = list(map(int,input().split())) + +n_list = [] +for i in range(N): + n_list.append(i+1) + +Per = list(itertools.permutations(n_list)) +for i in range(len(Per)): + tmp = list(Per[i]) + judge1,judge2 = 1,1 + for j in range(len(tmp)): + if(tmp[j] != P[j]): + judge1 = 0 + if(tmp[j] != Q[j]): + judge2 = 0 + + if(judge1 == 1): a = i+1 + if(judge2 == 1): b = i+1 + +print(abs(a-b))" +p03760,s597093246,Accepted,"O = list(input()) +E = list(input()) +ans = list() +LEN = len(O)+len(E) +for i in range(LEN): + if i%2==0: + ans.append(O[0]) + del O[0] + else: + ans.append(E[0]) + del E[0] +result = """".join(ans) +print(result)" +p03544,s849181806,Accepted,"N=int(input()) +N=N+1 +L1 = 2 +L2 = 1 +if N==1:print(L1) +if N==2:print(L2) +if N>2: + N=N-2 + for i in range(N): + L=L1+L2 + L1 = L2 + L2 = L + print(L)" +p03001,s306187897,Accepted,"W, H ,x ,y = map(int,input().split()) + +S = W * H /2 + +if x *2 ==W and y*2 == H: + print(S,1) +else: + print(S,0)" +p03328,s803559197,Accepted,"import sys +a,b = map(int,input().split()) +l = [(n*(n+1))//2 for n in range(1,1000)] +for i in range(len(l)-1): + if l[i+1]-l[i] == b - a: + print(l[i]-a) + sys.exit()" +p02596,s079586039,Accepted,"k = int(input()) + +def func(k): + number = 7 % k + for i in range(k): + if number == 0: + return i+1 + number = (10 *number + 7) % k + return -1 + +if k % 2 == 0 or k % 5 == 0: + print(-1) +else: + print(func(k)) +" +p03105,s876980604,Accepted,"a,b,c = map(int, input().split()) +if c <= b//a: + print(c) +else: + print(b//a)" +p02576,s458992888,Accepted,"import sys + +sys.setrecursionlimit(10 ** 8) +ini = lambda: int(sys.stdin.readline()) +inl = lambda: [int(x) for x in sys.stdin.readline().split()] +ins = lambda: sys.stdin.readline().rstrip() +debug = lambda *a, **kw: print(""\033[33m"", *a, ""\033[0m"", **dict(file=sys.stderr, **kw)) + + +def solve(): + n, x, t = inl() + + return t * ((n + x - 1) // x) + + +print(solve()) +" +p03696,s442676113,Accepted,"N = int(input()) +S = input() + +left_num = 0 +right_num = 0 + +for i in range(N): + if S[i] == '(': + right_num += 1 + else: + if right_num > 0: + right_num -= 1 + else: + left_num += 1 + +ans = '('*left_num + S + ')'*right_num +print(ans) +" +p03095,s502618697,Wrong Answer,"n=int(input()) +s=input() +d=dict(zip([chr(97+i) for i in range(26)],[0]*26)) +for i in s: + d[i]+=1 +ans=1 +for i in d.values(): + ans*=i+1 +print(ans-1)" +p02687,s284705287,Accepted,"s = input() +if(s=='ABC'): + print('ARC') +else: + print('ABC')" +p03778,s946091090,Accepted,"w,a,b = map(int, input().split()) +if a+w <= b: + print(max(b-(a+w),0)) +else: + print(max(a-(b+w),0))" +p03962,s230669333,Accepted,"a = list((input().split())) +a = set(a) +a = len(a) + +print(a) +" +p03360,s475897417,Accepted,"abclist=list(map(int,input().split())) +abclist.sort() + +K=int(input()) +for i in range(K): + abclist[2]*=2 + +print(sum(abclist))" +p02548,s265140701,Accepted,"n=int(input()) +ans=0 +for a in range(1, n): + ans+=(n - 1)//a +print(ans)" +p03219,s280855156,Wrong Answer,"x,y=map(int,input().split());print(x+y/2)" +p02939,s440850475,Accepted,"S = str(input()) +K = 0 +last,now = '','' +for i in range(len(S)): + now += S[i] + if i > 0 and now == last: + continue + else: + K += 1 + last = now + now = '' + +print(K)" +p03208,s530577839,Wrong Answer,"import sys +from collections import defaultdict + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline + +n,k = map(int, input().split()) +h = [] +d = defaultdict(int) +cnt = [] +for i in range(n): + x = int(input()) + h.append(x) + d[x] += 1 + +for i in d.items(): + if i[1] >= k: + print(0) + exit() + +sh = sorted(h) +print(sh[k - 1] - sh[0]) +" +p03220,s083604266,Wrong Answer,"def main(): + n = int(input()) + t, a = map(int, input().split()) + h = list(map(int, input().split())) + + ht= list(map(lambda x:abs(a - t - x * 0.006), h)) + print(ht) + print(ht.index(min(ht))+1) + + +if __name__ == '__main__': + main() +" +p03323,s021823585,Accepted,"a,b = map(int, input().split()) + +if a<=8 and b<=8: + print('Yay!') +else: + print(':(')" +p02987,s188508190,Wrong Answer,"S = input() + +if S[0]==S[1]: + if S[2]==S[3]: + print(""Yes"") + else: + print(""No"") +elif S[0]==S[2]: + if S[1]==S[3]: + print(""Yes"") + else: + print(""No"") +elif S[1]==S[2]: + if S[0]==S[3]: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p03795,s036773007,Accepted,"n = int(input()) +print(n*800 - 200*(n//15))" +p02989,s362683791,Wrong Answer,"#入力:[n1,n2,...nk](int:整数配列) +def input_array(): + return list(map(int,input().split())) + +n=int(input()) +d=input_array() +d.sort() +MAX=d[-1] + +count=0 +for k in range(MAX): + down=0 #Kより下 + up=0 + for j in d: + if j < k: + down+=1 + else: + up+=1 + if down==up: + count+=1 +print(count)" +p03061,s994443232,Accepted,"import fractions +from functools import reduce +n = int(input()) +a = list(map(int,input().split())) +left = [0] * (n + 1) +right = [0] * (n + 1) +for i in range(n): + left[i + 1] = (fractions.gcd(left[i],a[i])) + right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i])) +ans = 0 +for i in range(n): + ans = max(ans,fractions.gcd(left[i],right[i + 1])) +print(ans)" +p02912,s201559108,Accepted,"import heapq + +N,M = map(int,input().split()) +A = list(map(lambda x: int(x)*(-1), input().split())) +heapq.heapify(A) + +while M != 0: + nim = heapq.heappop(A) + heapq.heappush(A,-(-nim//2)) + M -= 1 + +print(-sum(A))" +p02988,s720278053,Accepted," +n=int(input()) +p=[int(x) for x in input().split()] +cnt=0 +for i in range(n-2): + if p[i]p[i+1]>p[i+2]: + cnt+=1 +print(cnt) + + + + + +" +p02582,s571489128,Accepted,"n = input() + +rcount = 0 +m = 0 +for i in n: + if i == ""R"": + rcount += 1 + else: + rcount = 0 + + if m <= rcount: + m = rcount +print(m)" +p03720,s509386923,Wrong Answer,"from collections import defaultdict +n, m = map(int, input().split()) +ans = defaultdict(int) +for q in range(m): + ab = list(map(int, input().split())) + ans[ab[0]] += 1 + ans[ab[1]] += 1 +for _, v in sorted(ans.items()): + print(v)" +p03565,s011773498,Accepted,"S=input() +T=input() +L,M=len(S),len(T) +a=-1 +for i in range(L-M,-1,-1): + if sum([1 for j in range(M) if S[i+j]=='?' or S[i+j]==T[j]])==M: + a=i + break +print('UNRESTORABLE' if a<0 else ''.join([T[i-a] if a<=i= a * b / 2: + print(90 - (math.atan(a / 2 / (b - (x / a ** 2))))*180/p) + else: + tate = (2 * x / a / b) + print(90 - (math.atan((tate / b)))*180/p) +" +p02789,s962580737,Accepted,"N, M= input().split() + +if N == M: + print(""Yes"") +else: + print(""No"") +" +p02779,s699298783,Accepted,"N=int(input()) +A=set(map(int,input().split())) +print('YNEOS'[N!=len(A)::2])" +p03000,s301539516,Accepted,"N,X = (int(x) for x in input().split()) +L = [int(x) for x in input().split()] +s = 0 +i = 0 +while (s <= X): + if i >= N: + print(N+1) + quit() + else: + s = s + L[i] + i = i + 1 +print(i)" +p02792,s274213218,Accepted,"n = int(input()) +cnt = 0 +memo = [[0] * 10 for i in range(10)] +for i in range(1, n + 1): + memo[int(str(i)[0])][int(str(i)[-1])] += 1 +for i in range(10): + for j in range(10): + cnt += memo[i][j] * memo[j][i] +print(cnt)" +p03474,s971928502,Accepted,"def instr(): + s = input() + return(list(s[:len(s)])) +# For taking space seperated integer variable inputs. + + +def invr(): + return(map(int, input().split())) + + +a, b = invr() +s = instr() + +check = ""1234567890-"" +res = ""Yes"" + +n = len(s) +if n != a+b+1: + res = ""No"" +if s[a] != ""-"": + res = ""No"" +for i in range(n): + if s[i] not in check: + res = ""No"" + break + if i != a and s[i] == ""-"": + res = ""No"" + break +print(res) +" +p02829,s840228731,Accepted,print(6-int(input())-int(input())) +p02909,s671432843,Wrong Answer,""""""" +author : halo2halo +date : 9, Jan, 2020 +"""""" + +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +W = ['Sunny', 'Cloudy', 'Rainy'] +A = readline().decode('utf8').rstrip() + + +print(W[(W.count(A)+1)%3]) +" +p02873,s530546044,Wrong Answer,"s=input() +n=len(s) +ans=[0]*(n+1) +m=0 +for i in range(1,n+1): + if s[i-1]=='<': + ans[i]=ans[i-1]+1 + else: + ans[i]=ans[i-1]-1 + m=min(m,ans[i]) +print(sum(ans)-m*n) + +" +p03821,s150147404,Accepted,"N = int(input()) +pair = [[] for i in range(N)] + +for _ in range(N): + pair[_] = list(map(int,input().split())) + a = pair[_][0] + b = pair[_][1] + +ans = 0 +diff = 0 + +for i in range(N - 1,-1,-1): + A = pair[i][0] + a = pair[i][0] + ans + b = pair[i][1] + diff = b - a + b * (a // b) + + if a % b != 0: + ans += diff + +print(ans)" +p02859,s247521649,Wrong Answer,"if __name__ == ""__main__"": + r = int(input()) + + # 半径1の面積 = 1 * 1 * pi + # 半径rの面積 = r * r * pi + # 半径 r の円の面積が半径 1 の円の面積の何倍になるか = (r*r*pi)/(1*1*pi) = r * r + + print(r*r*2)" +p02687,s171892447,Wrong Answer,"#!/usr/bin/env python3 + +from sys import stdin + + +def main(): + S = stdin.readline() + if S == 'ABC': + print('ARC') + else: + print('ABC') + + +if __name__ == ""__main__"": + main() +" +p03607,s145326513,Wrong Answer,"N = int(input()) +A = [int(input()) for i in range(N)] + +A.sort() + +odd = 0 +count = 1 +a = A[0] +for i in A[1:]: + print(i,a) + if i == a: + count += 1 + else: + a = i + if count % 2 == 1: + odd += 1 + count = 1 +if count % 2 == 1: + odd += 1 +print(odd)" +p02935,s587096448,Accepted,"n=int(input()) +a=list(map(int,input().split())) +a=sorted(a) +ans=a[0] +for i in range(1,n): + ans=(ans+a[i])/2 +print(ans)" +p02802,s518724194,Accepted,"import numpy as np +N, M =[int(i) for i in input().split()] +isfinish=[0]*N +isfail=[0]*N +for i in range(M): + p, S = input().split() + p=int(p) + if isfinish[p-1]==1: + continue + elif S==""AC"" and isfinish[p-1]==0: + isfinish[p-1] = 1 + elif S==""WA"" and isfinish[p-1]==0: + isfail[p-1] +=1 + +isfinish=np.array(isfinish) +isfail=np.array(isfail) +print(str(sum(isfinish)) + "" ""+ str(sum(isfail[isfinish==1]))) +" +p03986,s675695256,Accepted,"x = str(input()) +n = len(x) +stack = [] +for i in range(n): + if x[i] == 'S': + stack.append('S') + elif len(stack) == 0 or stack[len(stack) - 1] == 'T': + stack.append('T') + else: + stack.pop() +print(len(stack)) +" +p03723,s381715515,Wrong Answer,"a, b, c = map(int, input().split()) + +a_tmp = 0 +b_tmp = 0 +c_tmp = 0 + +flag = 0 +ans = 0 + +if a == b and b == c and c == a: + ans = -1 +else: + while flag == 0: + b_tmp += a/2 + c_tmp += a/2 + + a_tmp += b/2 + c_tmp += b/2 + + a_tmp += c/2 + b_tmp += c/2 + + a = a_tmp + b = b_tmp + c = c_tmp + + ans += 1 + + if a%2 == 1 or b%2 ==1 or c%2 ==1: + flag = 1 +print(ans)" +p02726,s236438409,Accepted,"def main(): + N, X, Y = map(int, input().split()) + ans = [0] * (N - 1) + + dist = 0 + + for i in range(1, N): + for j in range(i + 1, N + 1): + dist = min(j - i, abs(i - X) + abs(j - Y) + 1) + ans[dist - 1] += 1 + + for i in range(N - 1): + print(ans[i]) + +if __name__ == '__main__': + main()" +p02688,s231792924,Wrong Answer,"N, K = map(int, input().split()) +l = [list(map(int, input().split())) for _ in range(2 * K)] + +treated = (list(range(1, N))) + +for i in range(int((K+1)/2)): + tt = list(set(list(range(1, N))) - set(l[2*i+1])) + treated = list(set(treated) & set(tt)) + +print(len(treated))" +p02761,s317743898,Accepted,"n, m = map(int, input().split()) + +sc = [list(map(int, input().split())) for _ in range(m)] + +def solve(): + global n, m, sc + for i in range(1000): + tmp = str(i) + if len(tmp) != n: + continue + check = True + for s, c in sc: + if int(tmp[s-1]) != c: + check = False + if check: + return tmp + return -1 +print(solve())" +p03472,s005600960,Accepted,"# solution + +import io +import sys +import math + +n,h,*l=map(int,open(0).read().split()) + +array=max(l[::2]) + +c=0;f=1 + +for b in sorted(l[1::2])[::-1]: + if b>array: + h-=b + c+=1 + if h<1: + f=0 + break +print(c+(~-h//array+1)*f)" +p02779,s628966083,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +if len(set(A)) == len(A): + print(""YES"") +else: + print(""NO"")" +p02795,s631585031,Wrong Answer,"h=int(input()) +w=int(input()) +n=int(input()) + +s=max(h,w) +a=n//s+1 +print(a)" +p03161,s296405868,Accepted,"def main(): + N,K=map(int,input().split()) + h=list(map(int,input().split())) + ans=[0]*N + for i in range(1,N): + ans[i]= min(abs(h[i]-h[j])+ans[j] for j in range(max(0,i-K),i)) + print(ans[-1]) +main()" +p03524,s042923119,Accepted,"# https://atcoder.jp/contests/cf17-final/submissions/12544627 +# B - Palindrome-phobia +import sys + +sys.setrecursionlimit(10 ** 7) +f_inf = float('inf') +mod = 10 ** 9 + 7 + + +def resolve(): + s = input() + + a = s.count(""a"") + b = s.count(""b"") + c = s.count(""c"") + + print(""YES"" if max(a, b, c) <= min(a, b, c) + 1 else ""NO"") + + +if __name__ == '__main__': + resolve() +" +p02598,s431184820,Accepted,"N,K = map(int,input().split()) +A = list(map(int,input().split())) + +def check(m): + n = 0 + for a in A: + if a%m == 0: + n += a//m - 1 + else: + n += a//m + return n <= K + + +l = 0 +r = 10**9+10 + +while r-l > 1: + m = (r+l) // 2 + if check(m): + r = m + else: + l = m + +print(r) + + +" +p03243,s900121586,Accepted,"import bisect +n = int(input()) +a = [0,111,222,333,444,555,666,777,888,999] +s = bisect.bisect_left(a,n) +print (a[s])" +p02879,s936163476,Accepted,"a,b=map(int,raw_input().split()) +if a < 10 and b < 10: + print a*b +else: + print ""-1"" " +p02732,s815263397,Accepted,"import math +import collections + + +def nc2(n): + if n <= 1: + return 0 + return math.factorial(n)//(2*math.factorial(n-2)) + + +n = int(input()) +a = list(map(int, input().split())) + +cnt = collections.Counter(a) +each_ans = {} +for key, value in cnt.items(): + t = nc2(value) + each_ans[key] = (t, t-value+1) +all_sum = sum(value[0] for _, value in each_ans.items()) +ans = {} +for key in cnt.keys(): + ans[key] = all_sum - each_ans[key][0] + each_ans[key][1] +for i in a: + print(ans[i]) +" +p03386,s017826980,Accepted,"A,B,K = map(int,input().split()) +c = 0 +S = [] +if B - A <= K: + for i in range(A,B+1): + print(i) + exit() +for i in range(A,B+1): + if c == K: + break + print(i) + S.append(i) + c += 1 +for i in range(B-K+1,B+1): + if i not in S: + print(i) +" +p02881,s480679571,Accepted,"n = int(input()) + +cnt = 0 +for i in range(1, int(n ** 0.5)+1): + if n % i == 0: + cnt = max(cnt, i) + +print(cnt + n//cnt - 2) +" +p02989,s414022554,Wrong Answer,"import bisect +n = int(input()) +li = list(map(int,input().split())) +li.sort() +#print(li) +count = 0 +for i in range(1, max(li)): + index = bisect.bisect_left(li, i) + #print(n,index,n//2) + if index == n//2: + count += 1 +print(count)" +p03472,s215240402,Accepted,"import sys +def input(): return sys.stdin.readline().strip() +def mapint(): return map(int, input().split()) +sys.setrecursionlimit(10**9) + +N, H = mapint() +from heapq import heappop, heappush +Q = [] +for _ in range(N): + a, b = mapint() + heappush(Q, (-a, 'N')) + heappush(Q, (-b, 'L')) + +ans = 0 +while H>0: + v, ty = heappop(Q) + v *= -1 + if ty=='N': + print(ans-(-H//v)) + exit() + H -= v + ans += 1 +print(ans) + + " +p03860,s328111894,Accepted,"s = input() +print('A'+s[8]+'C') +" +p03632,s506984043,Accepted,"A,B,C,D = map(int,input().split()) +ans = max(min(B,D) -max(A,C),0) +print(ans)" +p03998,s198796429,Accepted,"G = {} +l =[""a"",""b"",""c""] +for i in l: + G[i] = list(input()) +s = l[0] +while(True): + if len(G[s]) ==0: + print(s.upper()) + break + s = G[s].pop(0)" +p02838,s326976282,Accepted,"import sys +from collections import defaultdict +from collections import deque +import numpy as np +import heapq +from heapq import heappush, heappop +import itertools + +N = int(input()) +A = np.array(input().split(), np.int64) + +MOD = 10**9 + 7 + +ans = 0 +for i in range(64): + B = (A >> i) & 1 + x = np.count_nonzero(B) + y = N - x + x *= y + + for _ in range(i): + x *= 2 + x %= MOD + + ans += x +ans %= MOD +print(ans) +" +p03345,s550865656,Wrong Answer,"A,B,C,K = map(int,input().split()) + +a = ""Unfair"" + +for i in range(K): + T = B + C + N = A + C + H = A + B + if (T <= 10**18) and (N <= 10**18) and (H <= 10**18): + A = T + B = N + C = H + else: + break +else: + a = A - B + +print(a) +" +p02723,s453743995,Accepted,"INT = lambda: int(input()) +INTM = lambda: map(int,input().split()) +STRM = lambda: map(str,input().split()) +STR = lambda: str(input()) +LIST = lambda: list(map(int,input().split())) +LISTS = lambda: list(map(str,input().split())) +def do(): + s=STR() + if s[2]==s[3] and s[4]==s[5]: + print('Yes') + else: + print('No') +if __name__ == '__main__': + do()" +p03774,s239818440,Accepted,"n,m=map(int,input().split()) +p=[list(map(int,input().split())) for _ in range(n)] +q=[list(map(int,input().split())) for _ in range(m)] +for a,b in p: + l=[] + for c,d in q: + l.append(abs(a-c)+abs(b-d)) + print(l.index(min(l))+1)" +p03693,s446749449,Accepted,"r,g,b=input().split() +print(""YES"" if int(r+g+b)%4==0 else ""NO"") +" +p02689,s588886177,Accepted,"N, M = map(int, input().split()) +h_list = list(map(int, input().split())) + +# 隣接する展望台より低い時点でbad +bad_set = set() +for _ in range(M): + src, dst = map(int, input().split()) + src_h = h_list[src - 1] + dst_h = h_list[dst - 1] + if src_h < dst_h: + bad_set.add(src) + elif dst_h < src_h: + bad_set.add(dst) + else: + bad_set.add(src) + bad_set.add(dst) + +print(N - len(bad_set))" +p02777,s118631059,Wrong Answer,"s,t = (i for i in input().split()) +a,b = (int(i) for i in input().split()) +u = input() + +c = {s:a, t:b} +c[u] -= 1 + +for i in c.values(): print(i,end="" "") +print()" +p02748,s731006305,Wrong Answer,"(A, B, M), aa, bb, *xyc = [list(map(int, s.split())) for s in open(0)] + +ans = min(aa)+min(bb) + +for x, y, c in xyc: + ans = min(ans, aa[x-1]+bb[y-1]-c) + +ans" +p03338,s957752753,Wrong Answer," +n = int(input()) +s = list(input()) +x = [] +y = [] +ans = [] + +for i in range(1,n): + x = s[0:i] + y = s[i:n] + print(x) + print(y) + + for j in range(len(x)): + a = 0 + if y.count(x[j]) >= 1: + a += 1 + ans.append(a) + print(ans) + +print(max(ans)) +" +p03146,s952841372,Wrong Answer,"s=int(input()) +G =[] +while all(i!=s for i in G): + G.append(s) + if s % 2==0: + s == int(s/2) + else: + s == int(3*s+1) +print(len(G)+1)" +p02664,s194630735,Accepted,"t = list(input()) +for i in range(len(t)-1, -1, -1): + if t[i] == '?': + t[i] = 'D' +print(''.join(list(map(str, t))))" +p02744,s849353589,Wrong Answer,"n = int(input()) +p = 'abcdefghijklmnopqrstuvwxyz' + +for i in range(n): + s = '' + for j in range(i+1): + s += p[j] + if n % len(s) == 0: + a = s*(n//len(s)) + print(a) + else: + b = n % len(s) + #print(b) + a = s*(n//len(s)) + s[:b] + print(a)" +p03377,s857905525,Accepted,"a,b,x = map(int, input().split()) +if a <= x <= a+b: + print('YES') +else: + print('NO')" +p02832,s386121946,Accepted,"n = int(input()) +arr = list(map(int, input().split())) + +rem = [] +count = 1 +for i in range(len(arr)): + if count == arr[i]: + rem.append(arr[i]) + count += 1 + +if len(rem) == 0: + print(-1) +else: + print(len(arr) - len(rem)) +" +p02916,s928545254,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) +st = 0 +for i in range(N): + st += B[A[i] - 1] + if i >= 1 and A[i] == A[i - 1] + 1: + st += C[A[i] - 2] +print(st) +" +p02861,s618531183,Accepted,"import itertools +import math +n = int(input()) +points = [] +for i in range(n): + point = list(map(int,input().split())) + points.append(point) +length = 0 +for root in itertools.permutations(points): + # print(root) + for i in range(n-1): + lengthi = math.sqrt((root[i][0]-root[i+1][0])**2+(root[i][1]-root[i+1][1])**2) + # print(lengthi) + length += lengthi + # print(length) + + + +print(length/(math.factorial(n)))" +p03971,s361615151,Accepted,"''' +Created on 2020/08/19 + +@author: harurun +''' +def main(): + import sys + pin=sys.stdin.readline + pout=sys.stdout.write + perr=sys.stderr.write + + N,A,B=map(int,pin().split()) + S=pin()[:-1] + cnt=0 + cn=0 + for i in range(N): + if S[i]==""a"" and cnt dt or dist % 2 != dt % 2: + flag = False + +print(""Yes"" if flag else ""No"") +" +p02766,s388112673,Wrong Answer,"from math import log, ceil + + +def main(): + N, K = map(int, input().split()) + print(ceil(log(N, K))) + + +if __name__ == '__main__': + main() + +" +p02612,s234962382,Accepted,"N = input() +N = int(N) +print(-N%1000)" +p02793,s666163291,Accepted,"N = int(input()) +A = [int(i) for i in input().split()] + +def gcd(a, b): + if b == 0: + return a + return gcd(b, a%b) + +def lcm(a, b): + return a // gcd(a,b) * b + +l = 1 +for i in range(N): + l = lcm(l, A[i]) + +ans = 0 +MOD = int(1e9+7) +for i in range(N): + ans += l // A[i] + +print(ans % MOD)" +p02552,s854932911,Accepted,"x = int(input()) +if x: + print(""0"") +else: + print(""1"")" +p02947,s448494339,Accepted,"import string +import collections + +N = int(input()) +count = 0 + +s = [] + +for i in range(0,N): + s.append(''.join(sorted(input()))) + + +c = collections.Counter(s) +go = c.most_common() + +for i in range(len(go)): + k = go[i][1] + count+=k*(k-1)//2 + +print(count)" +p02793,s609022373,Accepted,"#import math +#from functools import reduce +from fractions import gcd +#from functools import lru_cache + + +#def lcm_base(x, y): +# return (x * y) // gcd(x, y) + +#def lcm(numbers): +# return reduce(lcm_base, numbers, 1) + + +def lcm(a): + x = a[0] + for i in range(1, len(a)): + x = (x * a[i]) // gcd(x, a[i]) + return x + + +n = int(input()) +A = [int(x) for x in input().split()] + +t_lcm = lcm(A) +count = 0 +for i in A: + count += t_lcm//i + +print(count%(10**9+7)) +" +p03457,s198259451,Accepted,"n = int(input()) +prev_t, prev_x, prev_y = 0, 0, 0 +for i in range(n): + t, x, y = list(map(int, input().split())) + if abs(prev_x - x) + abs(prev_y - y) > abs(prev_t - t) or ( + abs(prev_x - x) + abs(prev_y - y) + abs(prev_t - t)) % 2: + print('No') + exit() + prev_t, prev_x, prev_y = t, x, y +print('Yes') +" +p03962,s892713116,Accepted,"se = set(map(int,input().split())) +print(len(se)) +" +p02690,s011518388,Accepted,"x = int(input()) + +a = 1 +b = 0 + +def val(): + global a, b + if pow(a,5) - pow(-b,5) == x: + b = -b + return True + return pow(a,5) - pow(b,5) == x + +while not val(): + if a >= b: + b += 1 + else: + a += 1 + b = 0 +print(a,b) +" +p03487,s484005459,Accepted,"from collections import Counter + +N = input() +A = list(map(int, input().split())) + +counter = Counter(A) + +cnt = 0 +for k, v in counter.items(): + if v < k: + cnt += v + elif v > k: + cnt += v - k + + +print(cnt) +" +p03673,s933511596,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +a_odd = a[0::2] +a_even = a[1::2] + +if N %2 == 0:#Nが偶数なら + print("" "".join(list(map(str,list(reversed(a_even)) + a_odd)))) +else: + print("" "".join(list(map(str,list(reversed(a_odd)) + a_even))))" +p02756,s285126116,Wrong Answer,"s = input() +q = int(input()) + +rev = 0 +head = [] +tail = [] + +for i in range(q): + t = input().split() + if t[0] == ""1"": + rev ^= 1 + else: + if (int(t[1])-1)^rev == 0: + head.append(t[2]) + else: + tail.append(t[2]) + +h = """".join(head) +t = """".join(tail) + +if rev == 0: + print(h[::-1] + s + t) +else: + print(t[::-1] + s + h)" +p02675,s725371008,Wrong Answer,"N = (input()) +X = (N[-1:]) +if X == 2 and X == 4 and X == 5 and X == 7 and X == 9: + print(""hon"") +elif X == 0 and X == 1 and X == 6 and X == 8: + print(""pon"") +else : + print(""bon"")" +p02866,s847437230,Wrong Answer,"n = int(input()) +dl = list(map(int,input().split())) +if dl[0] != 0: + print(0) + exit() +d_dic = dict() +for d in dl: + if d in d_dic: + d_dic[d] += 1 + else: + d_dic[d] = 1 +l = max(d_dic.keys()) +for i in range(l): + if not i in d_dic: + print(0) + exit() +ans = 1 +for i in range(l): + ans *= d_dic[i]**d_dic[i+1] + ans = ans%998244353 +print(ans)" +p03107,s586433664,Wrong Answer,"S=list(input()) +N=len(S) +def main(): + ans=0 + i=0 + while len(S)>0 and i=0 else 0)" +p03624,s752622223,Accepted,"def main(): + S = input() + abc = 'abcdefghijklmnopqrstuvwxyz' + for c in abc: + if c not in S: + print(c) + exit() + print('None') + + +if __name__ == '__main__': + main() +" +p02888,s255649770,Wrong Answer,""""""" +素直に実装するとN**9 +"""""" + +import itertools + +N = int(input()) +L = list(map(int, input().split())) + + +count = 0 +for a in L: + l = L[a:] + comb = list(itertools.combinations(L, 2)) + for b,c in comb: + if abs(b-c) < a < b+c: + count += 1 +print(count) +" +p02946,s632158264,Accepted,"import numpy as np +K, X = map(int, input().split()) + +ans = [str(x) for x in range(X-K+1,X+K)] +ans = "" "".join(ans) +print(ans)" +p03438,s838479441,Accepted,"from sys import stdin +N = int(stdin.readline().rstrip()) +A = [int(x) for x in stdin.readline().rstrip().split()] +B = [int(x) for x in stdin.readline().rstrip().split()] + +cnt1 = 0 +cnt2 = 0 + +for i in range(N): + if A[i] > B[i]: + cnt1 += (A[i] - B[i]) + else: + cnt2 += ((B[i]-A[i])//2) + +if cnt1 <= cnt2: + print(""Yes"") +else: + print(""No"")" +p02700,s738498794,Wrong Answer,"A, B, C, D = map(int, input().split()) +print(""Yes"" if (A+D)//D >= (C+B)//B else ""No"")" +p03469,s466393280,Accepted,"s = str(input()) + +ans = ""2018"" + s[4:] + +print(ans) +" +p03359,s838666264,Wrong Answer,"def main(): + a,b = map(int, input().split()) + print(min(a,b)) + +if __name__ == ""__main__"": + main()" +p02910,s085912105,Wrong Answer,"# coding: utf-8 + +str = input() +table = list(str) +print(table)" +p02951,s427159769,Accepted,"a, b, c = map(int, input().split()) +print(max(0, c - (a - b)))" +p02663,s408013301,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + a, b, c, d, e = list(map(int, readline().split())) + + x = a * 60 + b + y = c * 60 + d + z = y - x + + print(z-e) + + +if __name__ == '__main__': + main() +" +p03633,s371199531,Wrong Answer,"from math import gcd + +N = int(input()) +T = [] + +for _ in range(N): + T.append(int(input())) + +res = 0 +path = 1 + +for i in range(N): + res = gcd(res, T[i]) + path *= T[i] + +print(path//res)" +p02697,s828113144,Accepted,"from math import floor + +N, M = map(int, input().split()) +if N%2 == 1: + for p1 in range(1, M+1): + p2 = M*2+1-p1 + print(p1, p2) +else: + for p1 in range(1, min(M,floor(N/4))+1): + p2 = N-p1+1 + print(p1, p2) + for p1 in range(p1+1, M+1): + p2 = N-p1 + print(p1, p2) +" +p03286,s586810295,Accepted,"n=int(input()) +if n==0: + print(0) + exit() +ans=[] +while n!=0: + n-=1 + ans.append(n%-2) + n//=(-2) +#print(ans) +tmp=[1*(i==0) for i in ans][::-1] +print("""".join(map(str,tmp))) +" +p03705,s930645220,Accepted,"n, a, b = map(int, input().split()) +min_ = (n-1)*a+b +max_ = a+(n-1)*b +if max_ < min_: + print(0) + exit() +print(max_-min_+1) +" +p02731,s741518480,Wrong Answer,"l = int(input()) +a = 0 +for i in range(1, l): + for j in range(1, i + 1): + k = l - i - j + a = max(a, i * j * k) +print(a)" +p03471,s383963596,Accepted,"N, Y = map(int, input().split()) +Y /= 1000 +x = 10 +y = 5 +z = 1 +for i in range(N+1): + for j in range(N+1): + if x*i+y*j+(N-i-j) == Y and i+j <= N: + print(i, j, N-i-j) + exit() +print(-1, -1, -1) +" +p02684,s751651299,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +n = 1 +order = [n] +order_set = set([n]) + +for i in range(1, K + 1): + n = A[n - 1] + if n in order_set: + Li = order.index(n) + Ri = len(order) + idx = Li + (K - Li) % (Ri - Li) + print(order[idx]) + exit() + else: + order.append(n) + order_set.add(n) + continue +print(n) +" +p03778,s812377285,Wrong Answer,"a,b,c=map(int,input().split()) +print(min(abs(a-b),abs(a-c)))" +p02772,s430102582,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +for i in A: + if (i%3==0 or i%5==0) and i%2==0: + print('APPROVED') + else: + print('DENIED')" +p02836,s509442009,Accepted,"s = input() + +ans = 0 +leng = len(s) +half = leng // 2 +for i in range(half): + if s[i] != s[leng-1-i]: + ans += 1 + +print(ans)" +p02645,s945796707,Accepted,"s = input() +print(s[:3])" +p03817,s429815490,Wrong Answer,"x = int(input()) +ans = x//11 * 2 +if 0 < x%11 < 5: ans += 1 +else: ans += 2 +print(ans)" +p02552,s165556201,Accepted,"x = int(input()) +if x == 0: + print('1') +if x == 1: + print('0')" +p02797,s779800634,Accepted,"N, K, S = map(int, input().split()) + +if S > 1: + t = S - 1 +else: + t = S + 1 + +print(*([S] * K + [t] * (N - K))) +" +p02723,s495752686,Wrong Answer,"a = str(input().split()) +s = list(a) +print(s) +if s[4] == s[5] and s[7] == s[6]: + print(""Yes"") +else : + print(""No"")" +p02732,s949204356,Accepted,"N = int(input()) +A = list(map(int, input().split())) +dic1 = {} +dic2 = {} +for i in range(N): + if A[i] in dic1: + dic1[A[i]] += 1 + else: + dic1[A[i]] = 1 +ans = 0 +for v in dic1.values(): + ans += (v*(v-1))//2 +for j in range(N): + w = dic1[A[j]] + v = w-1 + comb = ans -(w*(w-1))//2 + (v*(v-1))//2 + print(comb) +" +p02771,s198886447,Accepted,"A,B,C = map(int,input().split()) + +if A == B and A != C: + print(""Yes"") +elif A == C and A != B: + print(""Yes"") +elif B == C and C != A: + print(""Yes"") +else: + print(""No"")" +p02633,s995584580,Wrong Answer,"k = list(map(int,input().split())) +print(int(360/k[0]))" +p03210,s976217418,Wrong Answer,"X = int(input()) +if X == 7 or 5 or 3: + print('YES') +else: + print('NO') +" +p03861,s637339458,Wrong Answer,"import math + + +a, b, z = [int(w) for w in input().split()] + +l = math.ceil(a/z) +r = b//z + +print(r-l+1) +" +p02582,s619991771,Accepted,"d = input() + +if ""RRR"" in d: + print(""3"") +elif ""RR"" in d: + print(""2"") +elif ""R"" in d: + print(""1"") +else: + print(""0"")" +p03475,s989226409,Wrong Answer,"N = int(input()) +li = [list(map(int, input().split())) for i in range(N - 1)] + +for n in range(N): + if n == N - 1: + print(0) + break + + ans = 0 + for index, i in enumerate(li): + if index < n: + continue + + if ans < i[1]: + ans = i[1] + else: + if ans % i[1] != 0: + ans += i[2] - (ans % i[1]) + + ans += i[0] + print(ans)" +p03862,s336866682,Accepted,"N,X,*A = map(int,open(0).read().split()) +A+=[0] +s = 0 + +for n in range(N): + d=max(0,A[n]+A[n-1]-X) + s+=d + A[n]-=d + +print(s)" +p03721,s605006061,Accepted,"n,k = map(int,input().split()) +lst = [[int(i) for i in input().split()] for i in range(n)] +nlst = sorted(lst,key= lambda x:x[0]) +cnt = 0 + +for i in range(n): + cnt += nlst[i][1] + if cnt >= k: + ans = nlst[i][0] + break + +print(ans)" +p03448,s908441552,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +pattern = 0 + +for i in range(a + 1): + for j in range(b + 1): + for k in range(c + 1): + if i * 500 + j * 100 + k * 50 == x: + pattern += 1 + +print(pattern) +" +p03380,s859636761,Accepted,"N = int(input()) +A = sorted([int(_) for _ in input().split()]) +n = A[-1] + +idx = 0 +maxv = -1 +for i in range(N - 1): + if A[i] == 0: + t = 0 + else: + t = min(n - A[i], A[i]) + if t > maxv: + maxv = t + idx = i +print(n, A[idx]) +" +p03261,s161554240,Accepted,"N = int(input()) +W = [] +for i in range(N): + W.append(input()) +if len(W) != len(set(W)): + print('No') +else: + for i in range(1, N): + if W[i][0] != W[i - 1][-1]: + print('No') + exit() + print('Yes') +" +p03548,s583635635,Wrong Answer,"x,y,z = map(int,input().split()) + +if x%(y+z) ==0: + print((x//(y+z))-1) + + +else: + print(x//(y+z)) +" +p02618,s012662813,Wrong Answer,"d = int(input()) +C = list(map(int,input().split())) +S = [list(map(int,input().split())) for i in range(d)] + +I = sorted(range(26), key = lambda x:C[x]) + +last = 0 +for i in range(d): + print(I[last]) + last = (last + 1)%26 +" +p03137,s145413251,Wrong Answer,"import sys +N, M = map(int, input().split()) +X = list(map(int, input().split())) + +X = sorted(X) + +anslis = [] + + +for i in range(M-1): + ans = abs(X[i+1] - X[i]) + anslis.append(ans) + ans = 0 + +anslis = sorted(anslis) + +print(sum(anslis[0:N+1]))" +p02552,s435045252,Accepted,"x=int(input()) +if(x==0): + print(1) +else: + print(0)" +p02713,s389380317,Wrong Answer,"K=int(input()) +ans=0 +import math +from functools import reduce + +def gcd(*numbers): + return reduce(math.gcd, numbers) + +def gcd_list(numbers): + return reduce(math.gcd, numbers) +for a in range(1,K+1): + for b in range(1,K+1): + for c in range(1,K+1): + #print(a, b, c) + ans+=gcd(a, b, c) +ans" +p03698,s403841897,Accepted,"li = list(input()) +liset = set(li) +if len(liset) == len(li): + print(""yes"") +else: + print(""no"")" +p03767,s927810713,Wrong Answer,"N = int(input()) +lis = sorted(list(map(int, input().split()))) +ans = 0 + +for i in range(N, 0, -1): + ans += lis[i*2] + +print(ans)" +p02633,s849826290,Wrong Answer,"X = int(input()) +print(360/X)" +p03719,s265578940,Accepted,"a,b,c = map(int,input().split()) +if a <= c <= b: + print('Yes') +else: + print('No')" +p03815,s106859526,Accepted,"x = int(input()) +X = x % 11 +N = x // 11 + +ans = 0 +if 1 <= X <= 6: + ans = N*2 + 1 +elif 7 <= X <= 10: + ans = N*2 + 2 +else: + ans = N*2 + +print(ans) +" +p02958,s116246216,Accepted,"def main(): + n=int(input()) + p=list(map(int, input().split())) + c = 0 + for i in range(n): + if p[i] != i+1: + c += 1 + print(""YES"" if c < 3 else ""NO"") + +if __name__ == ""__main__"": + main()" +p02606,s217300996,Accepted,"l,r,d = map(int,input().split(' ')) +ans=0 +for i in range(l,r+1): + if i%d==0: + ans+=1 + +print(ans) +" +p02775,s058385842,Wrong Answer,"s = 0 +for c in input(): + x = int(c) + s += min(x, 10-x+1) + +print(s)" +p02711,s598288366,Accepted,"N=int(input()) +N_str=set(str(N)) +if ""7"" in N_str : + print(""Yes"") +else: + print(""No"")" +p02602,s776228124,Accepted,"n, k = (int(x) for x in input().split()) +A = list(int(x) for x in input().split()) + +for i in range(n - k): + if A[i] >= A[k + i]: + print(""No"") + else: + print(""Yes"") +" +p03105,s632404878,Wrong Answer,"a,b,c = map(int,input().split()) +print(min(c,a//b))" +p02953,s057435505,Wrong Answer,"n=int(input()) +h=list(map(int,input().split())) + +cnt=0 + +for i in range(1,n): + if h[i-1]>h[i]: + cnt+=1 + +if cnt==0: + print('Yes') +if cnt>1: + print('No') +if cnt==1: + for j in range(1,n): + if h[j-1]>h[j]: + if h[j-1]-h[j]==1: + print('Yes') + else: + print('No')" +p03797,s154725889,Accepted,"N = [int(e) for e in input().split()] +if(N[0]*2>=N[1]): + ans = N[1]//2 + print(ans) +else: + ans = N[0] + (N[1] - N[0]*2)//4 + print(ans)" +p02775,s351611489,Accepted,"n = list(map(int, input())) +dp = (0, 1) +for i in n: + dp = (min(dp[0] + i, dp[1] + 10 - i), min(dp[0] + i + 1, dp[1] + 9 - i)) +print(dp[0])" +p03331,s661261830,Accepted,"N = int(input()) +if N%10 ==0: + ans = 10 +else: + NN = list(str(N)) + ans = 0 + for i in NN: + ans += int(i) +print(ans) + " +p03644,s394826092,Accepted,print(2**max((i^(i-1)).bit_length()-1 for i in range(int(input())+1))) +p02629,s436747329,Accepted,"N = int(input()) +import math + +num2alpha = lambda c: chr(c) +tmp_N = N +result = '' +while (tmp_N / 26) > 1.0: + k = int(tmp_N / 26) + res = tmp_N % 26 + if res == 0: + res = 26 + k -= 1 + result += num2alpha(res+64).lower() + tmp_N = k +res = tmp_N % 26 +if res == 0: + res = 26 + k -= 1 +result += num2alpha(res+64).lower() +new_str = ''.join(list(reversed(result))) +print(new_str)" +p02547,s293648401,Accepted,"def main(): + import sys + N=int(sys.stdin.readline()) + count=0 + for i in range(N): + D1,D2=list(map(int,sys.stdin.readline().split())) + if D1==D2: + count+=1 + else: + count=0 + if count==3: + print('Yes') + break + else: + print('No') + +main()" +p03328,s918207639,Wrong Answer,"a,b = map(int,input().split()) +c = b-a +wa = c*(c+1)//2 +print(b-wa)" +p02756,s924902195,Accepted,"from collections import deque + +s = deque((str(input()))) +loop = int(input()) + +rev = 0 +for i in range(loop): + queries = input().split() + if len(queries) == 1: + rev = (rev+1) % 2 + else: + type = int(queries[1]) + c = str(queries[2]) + if (type + rev) % 2 == 1: + s.appendleft(c) + else: + s.append(c) +if rev == 1: + s.reverse() +print("""".join(list(s))) + +" +p03329,s115767223,Wrong Answer,"n = int(input()) + +INF = 10**9 + +dp = [INF] * (n+1) +dp[1] = 1 + +for i in range(1, n): + dp[i+1] = min(dp[i+1], dp[i] +1) + six = 6 + while i + six <= n: + dp[i + six] = min(dp[i+six], dp[i] + 1) + six *= 6 + nine = 9 + while i + nine <= n: + dp[i + nine] = min(dp[i+nine], dp[i] + 1) + nine *= 9 +print(dp[-1])" +p02918,s289315930,Accepted,"N, K = map(int, input().split()) +S = input() + +happy = 0 +for i in range(N-1): + if S[i] == S[i+1]: + happy += 1 + +m = 0 +for i in range(N-1): + if S[i] == 'R' and S[i+1] == 'L': + m += 1 + +if K <= m: + happy += 2*K +else: + if m > 1: + happy += 2*m + if S[0] != S[N-1]: + happy += 1 +print(happy) +" +p03479,s779329539,Accepted,"x,y=map(int,input().split()) +c=0 +while x<=y: + x=x*2 + c+=1 +print(c)" +p02699,s441273636,Accepted,"#!/usr/bin/env python3 + +s,w=map(int,input().split()) +if s<=w: + print('unsafe') +else: + print('safe')" +p03494,s269338985,Accepted,"n = int(input()) +l = [int(i) for i in input().split()] +ans = 0 +b = True +while b: + for i in range(n): + if l[i]%2==0: + l[i]/=2 + else: + b=False + break + if b: + ans+=1 +print(ans)" +p03695,s502678999,Wrong Answer,"n, *A = map(int, open(0).read().split()) +c = [0]*9 +for a in A: + c[min(8, a//400)] += 1 +cmin = max(1, 8-c.count(0)) +cmax = min(8, cmin+c[8]) +print(cmin, cmax)" +p03998,s662964331,Wrong Answer,"a = list(input()) +b = list(input()) +c = list(input()) + +D = {'a':a, 'b':b, 'c':c} +curr = 'a' +while True: + tmp = D[curr] + if tmp == []: + break + curr = tmp.pop() +print(curr.upper()) + + +" +p03860,s849864513,Accepted,"print(""A"" + input()[8:9] + ""C"") +" +p02796,s286902584,Accepted,"n=int(input()) +lr=[] +for i in range(n): + x,l=map(int,input().split()) + lr.append((x-l,x+l)) +lr.sort(key=lambda x: x[1]) +ans=0 +l=-10**18 +r=0 +for i in range(n): + if i==0: + tl,tr=lr[i] + l=tl + r=tr + ans+=1 + continue + tl,tr=lr[i] + if tl>=r: + ans+=1 + r=tr + l=tl +print(ans) + + + +" +p03408,s408966429,Accepted,"n=int(input()) +s=[input() for _ in range(n)] +m=int(input()) +t=[input() for _ in range(m)] +ans=0 +buf=0 +s.sort() +t.sort() +for i in range(n): + buf=0 + for j in range(i,n): + if s[i]==s[j]: + buf+=1 + elif s[i]ans: + ans=buf +print(ans) " +p04044,s269745889,Accepted,"n, l = map(int, input().split()) +S = [str(input()) for i in range(n)] +ans = '' +for s in sorted(S): + ans += s +print(ans)" +p03767,s833415478,Accepted,"N=int(input()) +A=list(map(int, input().split())) +A=sorted(A, reverse=True) +ans=sum(A[1::2][:N]) +print(ans) +#print(A) +#print(A[1::2])" +p03001,s735944495,Wrong Answer,"W,H,X,Y = map(int, input().split()) +C = X/W +D = Y/H +result2 = 0 +result = 0 +if C == 0 and D == 0: + result = W*H*0.5 +elif C == 0: + result = D*W*H +elif D == 0: + result = C*W*H +else: + result = min(C,D)*W*H + +if X != 0 and Y != 0: + if X == Y: + result2 = 1 + +print(result,result2)" +p03351,s543514678,Wrong Answer,"a,b,c,d=map(int,input().split()) +print(""Yes"" if abs(a-b)<=d or abs(c-a)<=d and abs(b-c)<=d else ""No"" ) + +" +p02603,s454840561,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +a.insert(0, a[0]) +a.append(a[-1]) +INF = 10 ** 9 + 7 + +money = 1000 +mi = INF +ma = 0 +for i in range(1, n + 1): + mi = min(mi, a[i]) + ma = max(ma, a[i]) + if a[i - 1] < a[i] >= a[i + 1]: + stock = money // mi + money %= mi + money += stock * ma + mi = a[i] + ma = a[i] + +print(money)" +p03162,s603459170,Wrong Answer,"import numpy as np + +n = int(input()) +ac = [] +for i in range(n): + i = list(map(int,input().split())) + ac.append(i) +ac = np.array(ac) +dp = [0]*n + +cnt = 3 #二個目のfor文で0~2と被らないようにするため +for j in range(n): + tmp = 0 + m = 0 + for k in range(3): + if k != cnt: + if tmp < ac[j][k]: + tmp = ac[j][k] + m = k + cnt = m + dp[j] = tmp + +print(sum(dp))" +p02953,s813140841,Accepted,"n = int(input()) +h = list(map(int,input().split())) +flag = True +for i in range(n-1): + if h[i+1] - h[i] >= 1: + h[i+1] -= 1 + elif h[i+1] -h[i] == 0: + pass + else: + flag = False + break +if flag: + print('Yes') +else: + print('No') +" +p02958,s253546856,Wrong Answer,"# import math +# import statistics +a=int(input()) +#b,c=int(input()),int(input()) +# c=[] +# for i in a: +# c.append(i) +#e1,e2 = map(int,input().split()) +f = list(map(int,input().split())) +#g = [input() for _ in range(a)] + +count=0 +for i in range(a-1): + if f[i]!=f[i+1]-1: + count+=1 +if count==2 or count==0: + print(""YES"") +else: + print(""NO"")" +p02779,s906778308,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +print('YES' if len(a) == len(set(a)) else 'NO')" +p03210,s568446266,Accepted,"a = [7,5,3] +x = int(input()) +if x in a: + print(""YES"") +else: + print(""NO"")" +p03659,s483605761,Wrong Answer,"def solve(n, A): + total = sum(A) + x = A[0] + ret = total + for i in range(1, n - 1): + x += A[i] + y = total - x + if abs(x - y) < ret: + ret = abs(x - y) + return ret + +_n = int(input()) +_A = list(map(int, input().split())) +print(solve(_n, _A)) +" +p03639,s482782628,Accepted,"N = int(input()) +A = list(map(int, input().split())) +num_odd = 0 +num_mul2 = 0 +num_mul4 = 0 +for a in A: + if a % 4 == 0: + num_mul4 += 1 + elif a % 2 == 0: + num_mul2 += 1 + elif a % 2 == 1: + num_odd += 1 + +ans = False +if num_mul2 == 0: + if num_mul4 + 1>= num_odd: + ans = True +else: + if num_mul4 >= num_odd: + ans = True +print('Yes' if ans else 'No') +" +p03555,s171758388,Wrong Answer,"word1 = input() +word2 = input() +up = list(word1) +down = list(word2) + +if word1[0]==word2[2] and word1[1]== word2[1] and word1[2] == word2[0]: + print(""Yes"") +else: + print(""No"") + +" +p03778,s627686054,Accepted,"w, a, b = map(int, input().split()) + +if a < b: + ans = b - (a+w) + if ans <= 0: + print(0) + else: + print(ans) +else: + ans = a - (b+w) + if ans <= 0: + print(0) + else: + print(ans) +" +p02684,s585847266,Wrong Answer,"N, K = map(int, input().split()) +A = list(map(lambda x:int(x) - 1, input().split())) + +already = [False for i in range(N)] +already[0] = True +tel = [0] + +while True: + tmp = A[tel[-1]] + tel.append(tmp) + + if already[tmp]: + tel.pop() + break + + already[tmp] = True + +for i in range(len(tel)): + if tel[i] == tmp: + s = i + break +if K - s >= 0: + ans = (K - s) % (len(tel) - s) + print(tel[ans + s] + 1) +else: + print(tel[K])" +p02796,s149115149,Accepted,"N = int(input()) +R = [] +for _ in range(N): + X, L = map(int, input().split()) + l, r = X-L, X+L + R.append([l, r]) + +R = sorted(R, key=lambda x: x[1]) +tmp = R[0] +ans = [R[0]] +for i in range(1, N): + v = R[i] + if tmp[1] <= v[0]: + ans.append(v) + tmp = v + +print(len(ans))" +p02951,s531422064,Accepted,"A,B,C=map(int, input().split()) +print(max(0,C-(A-B)))" +p03264,s084910968,Accepted,"k = int(input()) + +e = k // 2 +o = k // 2 + k % 2 + +print(e*o)" +p02628,s307665318,Wrong Answer,"n,k = map(int,input().split()) +a = list(map(int,input().split())) +list.sort(a) +sum(a[0:k])" +p03962,s926484412,Wrong Answer,"a,b,c = map(int,input().split()) + +if a == b: + print(2) +elif a == c: + print(2) +elif b == c: + print(2) +elif a == b == c: + print(1) +else: + print(3) + " +p03416,s558186738,Wrong Answer,"#coding:utf-8 +a, b = map(int, input().split()) +count = 0 + +for i in range(a, b+1): + num = str(i) + if int(num[0:2]) == int(num[3:5]): + count += 1 + +print(count)" +p04034,s900754096,Accepted,"N,M = map(int,input().split()) +a = [1]+[0]*(N-1) +b = [1]*N + +for i in range(M): + x,y = map(int,input().split()) + if a[x-1]==1 and b[x-1]==1: + a[x-1]=0 + a[y-1]=1 + elif a[x-1]==1: + a[y-1]=1 + b[x-1]-=1 + b[y-1]+=1 + +print(sum(a))" +p03062,s146097348,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=A[:] +count=0 +zero=0 +for i in range(N): + if(A[i]<0): + count+=1 + elif(A[i]==0): + zero+=1 +for i in range(N): + B[i]=abs(A[i]) +if(zero==0 and count%2==1): + print(sum(B)-2*min(B)) +else: + print(sum(B))" +p02996,s865839807,Accepted,"N = int(input()) +AB = [] +for _ in range(N): + ab = list(map(int, input().split())) + AB.append(ab) + +AB.sort(key=lambda x:x[1]) +sum_t = 0 + +for ab in AB: + sum_t += ab[0] + if sum_t > ab[1]: + print(""No"") + exit() + +print(""Yes"")" +p02676,s143454316,Accepted,"K = int(input()) +S = input() + +if len(S) > K: + print(S[:K] + '...') +else: + print(S)" +p03011,s398239456,Wrong Answer,"n=list(map(int, input().strip().split())) + +lis1=[] +for i in range(0,len(n)): + for a in range(0,len(n)): + if n[i]!=n[a]: + z=(int(n[a])+int(n[i])) + lis1.append(z) + +minscore='9999999999' +for i in range(0,len(lis1)): + if float(minscore)>float(lis1[i]): + minscore=lis1[i] + +print(minscore) + +" +p03126,s497485352,Wrong Answer,"n,m= map(int,input().split()) + +t1=list(map(int,input().split())) +ans=set(t1[1:]) +for _ in range(n-1): + t2=list(map(int,input().split())) + ans &= set(t2[1:]) + +print(ans)" +p03162,s263107303,Wrong Answer,"n = int(input()) +abc = [list(map(int, input().split())) for i in range(n)] +dp = [-1] * n +m = max(abc[0]) +dp[0] = m +x = abc[0].index(m) + +for i in range(1,n): + t = -1 + for j in range(3): + if x == j: + continue + if dp[i] < dp[i-1]+abc[i][j]: + t = j + dp[i] = dp[i-1]+abc[i][j] + x = t +print(dp[-1]) +" +p02659,s099183917,Accepted,"a,b=map(str,input().split()) +a=int(a) +b=100*int(b[0])+10*int(b[2])+1*int(b[3]) #bを100倍した値(整数)に直す +print((a*b)//100)" +p02645,s622884725,Accepted,"S = input() +S = S[:3] +print(S)" +p02743,s486217635,Accepted,"import math +a, b, c = map(int, input().split()) +if c - a - b > 0 and 4*a*b < (c - a - b)**2: + print(""Yes"") +else: + print(""No"")" +p02793,s002058653,Accepted,"N = int(input()); +A = list(map(int,input().split())) + +def lcm(a): + from fractions import gcd + x = a[0] + for i in a: + x = (x * i) // gcd(x, i) + return x + +l = lcm(A) +ans = 0 +for i in A: + ans += l//i + +MOD = 10**9+7 +print(ans%MOD)" +p03220,s822867591,Accepted,"n = int(input()) +T,A = map(int,input().split()) +h = list(map(int,input().split())) +#print(h) +l =[] +for i in range(n): + a = T - h[i]*0.006 + # print(a) + b = abs(a-A) + l.append(b) + #print(l) +c = l.index(min(l)) +print(c+1)" +p02732,s866938754,Accepted,"import sys +input=sys.stdin.readline +N = int(input()) +A = list(map(int,input().split())) +def cmb(n): + if n == 1: + return 0 + else: + return n * (n-1) /2 +mydict = {} +for i in range(N): + a = A[i] + if a in mydict.keys(): + mydict[a] += 1 + else: + mydict[a] = 1 +s = 0 +for i in mydict.values(): + s += cmb(i) +for i in range(N): + a = A[i] + x = mydict[a] - 1 + print(int(s-x))" +p03804,s791594255,Accepted,"n,m=map(int,input().split()) +al=[] +bl=[] +for _ in range(n): + al.append(input()) +for _ in range(m): + bl.append(input()) + +bl_left_top=bl[0][0] + +ans=0 +for i in range(n-m+1): + for j in range(n-m+1): + for k in range(m): + if al[i+k][j:j+m]!=bl[k]: + break + if k==m-1: + ans=1 + if ans==1: + break + +print('Yes') if ans==1 else print('No')" +p03556,s490652968,Accepted,"n = int(input()) +print(int(n ** (1 / 2)) ** 2)" +p03943,s591472051,Wrong Answer,"a, b, c = map(int, input().split()) +total = str((a + b + c) / 2) +if total[-1] == '0': + print('Yes') +else: + print('No')" +p02695,s218738253,Accepted,"import itertools +n, m, q = map(int, input().split()) +abcd = [tuple(map(int, input().split())) for _ in range(q)] +Max = 0 +for A in itertools.combinations_with_replacement(range(1, m + 1), n): + #score = sum([d for a, b, c, d in abcd if C[b - 1] - C[a - 1] == c]) + score = 0 + for ai, bi, ci, di in abcd: + if A[bi - 1] - A[ai - 1] == ci: + score += di + Max = max(Max, score) + #print(C) +print(Max) +" +p02706,s332486483,Accepted,"N,M = map(int,input().split()) +A= list(map(int,input().split())) +D = sum(A) +if N < D: + print(-1) +else: + print(N-D) +" +p03469,s402143096,Accepted,"s = input() +print('2018' + s[4:])" +p04034,s888623350,Wrong Answer,"from sys import stdin + + +def main(): + input = lambda: stdin.readline()[:-1] + N, M = map(int, input().split()) + XY = [tuple(map(int, input().split())) for _ in [0] * M] + + box = [1] * (N + 1) + red = [0] * (N + 1) + box[0], red[1] = 0, 1 + for x, y in XY: + box[x] -= 1 + box[y] += 1 + red[y] = red[x] + if not box[x]: + red[x] = 0 + print(sum(red)) + + +main() +" +p02697,s701959558,Accepted,"from collections import * +n,m = map(int,input().split()) +d = dict() +i,j = 1,n +for y in range(m): + if(n%2 == 0 and i == (m+1)//2+1): + i += 1 + print(i,j) + i += 1 + j -= 1 +" +p03000,s001743333,Wrong Answer,"n,x=[int(x) for x in input().split()] +l=[int(x) for x in input().split()] +d=0 +cnt=0 +for i in range(n): + d=d+l[i] + if d<=x: + cnt+=1 +print(cnt)" +p03416,s926721691,Wrong Answer,"a, b = map(int, input().split()) +c = 0 +while a < b: + if str(a)[:2] == str(a)[3:]: + c += 1 + a += 1 +print(c)" +p03625,s256898779,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +A.sort(reverse=True) + +h = 0 +w = 0 + + +for i in range(N-1): + if A[i] == A[i+1]: + h = A[i] + break + +for i in range(N-1): + if A[i] != h: + if A[i] == A[i+1]: + w = A[i] + print(h*w) + exit() + +print(0) +" +p02731,s542463661,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + l=int(input()) + print((l/3)**3) +resolve()" +p03160,s663315875,Wrong Answer,"dp = [10001 for i in range(100002)] +n = int(input()) +hs = list(map(int, input().split())) + +dp[0] = 0 +for i in range(1, n): + dp[i] = min(dp[i], dp[i-1] + abs(hs[i-1] - hs[i])) + if i > 1 : + dp[i] = min(dp[i], dp[i-2] + abs(hs[i-2] - hs[i])) + +print(dp[n-1])" +p02768,s106282944,Wrong Answer,"def main(): + n,a,b = map(int,input().split()) + MOD = (10**9)+7 + s = pow(2,n,MOD) + u = 1 + bb = 1 + + + for i in range(1,(max(a,b) + 1)): + u*=(n-i+1)%MOD + bb*= i % MOD + if i == a or i == b: + s-=u*pow(bb,MOD-2,MOD) + + + + print(s%MOD) +# + + +if __name__=='__main__': + main() +" +p02661,s738256398,Accepted,"n = int(input()) +a = [0]*n +b = [0]*n +for i in range(n): a[i],b[i] = map(int,input().split()) +a.sort() +b.sort() +if n%2 == 1: + m = n//2 + ans = b[m] - a[m] + 1 +else: + ml = n//2-1 + mr = n//2 + ma = (a[ml] + a[mr])/2 + mb = (b[ml] + b[mr])/2 + ans = int((mb - ma)*2 + 1) +print(ans) " +p02796,s780478319,Accepted,"N = int(input()) +robot = [list(map(int,input().split())) for _ in range(N)] + +L = [[0,0] for _ in range(N)] +for i in range(N): + L[i][0] = robot[i][0]-robot[i][1] + L[i][1] = robot[i][0]+robot[i][1]-1 + +L.sort(key = lambda x:x[1]) + +a = 0 +b = -float('inf') + +for i in range(N): + if b < L[i][0]: + a += 1 + b = L[i][1] + +print(a)" +p02600,s698160112,Accepted,"x = int(input()) +if x <= 599: + print(8) +elif x <= 799: + print(7) +elif x <= 999: + print(6) +elif x <= 1199: + print(5) +elif x <= 1399: + print(4) +elif x <= 1599: + print(3) +elif x <= 1799: + print(2) +else: + print(1) +" +p02687,s360857826,Wrong Answer,"contest = input() + +if contest == ""ABC"": + print(""ARC"") +else: + print(""ARC"")" +p03612,s768766062,Accepted,"n = int(input()) +l = list(map(int,input().split())) +cou = 0 + +for i in range(0,n-1): + if l[i]==i+1: + l[i],l[i+1] = l[i+1], l[i] + cou += 1 +if l[-1]==n: + cou += 1 +print(cou)" +p03041,s670558494,Wrong Answer,"n,K = map(int,input().split()) +p = min(n,K-1) +ans = 0 +chk = [1]*(K-1) +k = K +for i in range(14): + k /= 2 + for i in range(int(k*2-k-0.000000000000000001)): + chk[i] += 1 + if k <= 1: + break + +#print(chk) +for i in range(p): + ans += float(1/(2**chk[i]*n)) + #print(ans) +ans += max(0,(n-K+1)/n) +print(ans)" +p03241,s942151887,Accepted,"N,M = map(int,input().split()) + +#nの約数列挙 +def divisor(n): + ass = [] + for i in range(1,int(n**0.5)+1): + if n%i == 0: + ass.append(i) + if i**2 == n: + continue + ass.append(n//i) + return ass #sortされていない + +div = divisor(M) +ans = 0 +for d in div: + if M//d >= N: + ans = max(ans,d) +print(ans) +" +p02645,s406429541,Wrong Answer,"import random +S = input() +i = len(S) +m = random.randint(0,i-3) +print (S[m],S[m+1],S[m+2])" +p03407,s247762122,Wrong Answer,"a, b, c = list(map(int, input().split())) + +if (a+b) <= c: + print(""Yes"") +else: + print(""No"")" +p04044,s390205173,Accepted,"N, L = map(int, input().split()) +S = [0]*N +for i in range(N): + S[i] = input() + +S.sort() +print(''.join(S)) +" +p02952,s028202760,Wrong Answer,"import math +n=int(input()) +num=math.log(n,10) +if 0<=num<1: + print(n) +elif 1<=num<2: + print(n-90) +elif 2<=num<3: + print(909) +elif 3<=num<4: + print(909) +elif 4<=n<5: + print(n-9090) +else: + print(90909)" +p02556,s094326862,Accepted,"n = int(input()) +l = [[0,0] for _ in range(n)] +for i in range(n): + x,y = map(int,input().split()) + l[i] = [x-y,x+y] +ans = 0 +for i in range(2): + l2 = [l[j][i] for j in range(n)] + ans = max(ans,max(l2)-min(l2)) +print(ans)" +p02917,s533722167,Accepted,"n = int(input()) +b = list(map(int,input().split())) +s = b[0] + b[-1] + +for i in range(1,n-1): + s += min(b[i-1],b[i]) + +print(s)" +p02657,s243104476,Accepted,"A, B= map(int, input().split()) +print(A*B)" +p02727,s650181730,Accepted,"x,y,a,b,c = map(int, input().split()) +p = list(map(int, input().split())) +q = list(map(int, input().split())) +r = list(map(int, input().split())) + +p.sort(reverse=True) +q.sort(reverse=True) +r.sort(reverse=True) + +l = p[:x] +l.extend(q[:y]) +l.extend(r) +l.sort(reverse=True) +ans = sum(l[:x+y]) + +print(ans) +" +p03359,s951588948,Wrong Answer,"a, b = map(int, input().split()) +print(min(a, b)) +" +p03951,s228987490,Wrong Answer,"n = int(input()) +s = input() +t = input() + +ans = s+t +for i in range(n): + if s[i:]==t[:n-i]: + ans = s[:i]+s[i:]+t[n-i:] + +print(len(ans))" +p03657,s644489578,Accepted,"a,b=map(int,input().split()) +if a%3==0 or b%3==0 or (a+b)%3==0: + print('Possible') +else: + print('Impossible')" +p03799,s039206496,Accepted,"N,M = map(int, input().split()) + +def f(x): + if M >= 2*x and N+(M-2*x)//2 >= x: + return True + return False + +l = 0 +r = 10**12 +while r-l > 1: + m = (l+r)//2 + if f(m): + l = m + else: + r = m + +if f(r): + print(r) +else: + print(l)" +p02602,s993500513,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +for i in range(k, n): + if a[i - k] < a[i]: + print(""Yes"") + else: + print(""No"")" +p02583,s766304708,Wrong Answer,"N = int(input()) +L = list(map(int,input().split())) +L.sort() +count = 0 +print(L) +for i in range(N): + for j in range(i,N): + for k in range(j,N): + a = L[i] + b = L[j] + c = L[k] + if(a != b and b != c and c != a): + if (a + b > c and a + c > b and b + c > a): + count += 1 +print(count)" +p03106,s018374535,Accepted,"A, B, K = [int(num) for num in input().split()] +M, m = max(A, B), min(A, B) +yakusu = [] +koyakusu = [] +for i in range(1, m+1): + if m % i == 0: + yakusu.append(i) + else: + continue +for j in yakusu: + if M % j == 0: + koyakusu.append(j) +print(koyakusu[-K]) + + " +p03469,s439198712,Accepted,"S = input() +print(""2018""+S[4:10])" +p03293,s077993612,Accepted,"s = list(input()) +t = list(input()) +for _ in range(len(s)): + if s == t: + print(""Yes"") + quit() + else: + end = s.pop(0) + s.append(end) +print(""No"") +" +p02576,s696281189,Accepted,"#176-A Takoyaki + +takoyaki = input().split() + +totalTime = -(-int(takoyaki[0]) // int(takoyaki[1])) * int(takoyaki[2]) +print(totalTime)" +p03219,s124830906,Accepted,"X, Y = map(int, input().split()) +print(X+Y//2)" +p02753,s434832730,Wrong Answer,"s = input() +res = ""Yes"" if len(set(s)) < 3 else 'No' +print(res)" +p03380,s140073825,Accepted,"# coding: utf-8 +from math import ceil +from bisect import bisect_left +N = int(input()) +A = list(map(int, input().split())) +A.sort() +a = A[-1] +ans = ceil(a / 2) +b = float(""inf"") +for i in range(N): + if abs(b - ans) > abs(A[i] - ans): + b = A[i] +print(a, b) +" +p02759,s852967052,Accepted,"N = int(input()) + +if N % 2 == 0: + print(int(N / 2)) +else: + print(int((N + 1) / 2))" +p02630,s693245613,Accepted,"from collections import defaultdict +N = int(input()) +raw_numbers = list(map(int, input().split())) +numbers = defaultdict(int) + +for num in raw_numbers: + numbers[num] += 1 + +total = sum(raw_numbers) + +Q = int(input()) + +for _ in range(Q): + a, b = list(map(int, input().split())) + taken = numbers[a] + total -= a * numbers[a] + numbers[b] += numbers[a] + total += b * taken + numbers[a] = 0 + print(total)" +p03210,s272458731,Accepted,"import sys +X = int(input()) +if not ( 1 <= X <= 9 ): sys.exit() + +print('YES') if X == 3 or X == 5 or X == 7 else print('NO')" +p03449,s997369929,Accepted,"n = int(input()) +a = [list(map(int, input().split())) for _ in range(2)] +x = sum(a[1])+a[0][0] +ans = x +for i in range(1,n): + x += a[0][i] -a[1][i-1] + if ans < x: ans = x +print(ans)" +p03486,s085982062,Wrong Answer,"n = sorted(input()) +m = sorted(input()) +if nK-1 : + break + price += fruit[i] + +print(price)" +p02854,s455720000,Accepted,"N = int(input()) +A = list(map(int, input().split())) +total = sum(A) +mid = total // 2 +sum_left, sum_left2 = 0, 0 +sep_i = 0 +for i, a in enumerate(A): + sum_left += a + if sum_left >= mid: + sep_i = i + sum_left2 = sum_left - a + break +sum_right, sum_right2 = sum(A[sep_i + 1:]), sum(A[sep_i:]) +print(min(abs(sum_right - sum_left), abs(sum_right2 - sum_left2)))" +p02677,s491176241,Wrong Answer,"import math + +a,b,h,m = map(int, input().split()) +start = 30*h +d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m)) +if int(d)!=90 and int(d)!= 0: + c = math.cos(math.radians(d)) + k = a**2+b**2-2*a*b*c + ans = math.sqrt(k) + print(ans) +elif int(d) == 0: + print(abs(a-b)) +elif int(d) ==90: + k= a**2+b**2 + ans = math.sqrt(k) + print(ans)" +p02694,s186788655,Accepted,"X = int(input()) +cnt = 0 +val = 100 +while True: + val = int(val * 1.01) + cnt += 1 + if X <= val: + break +print(cnt)" +p03075,s146009289,Wrong Answer,"L=[int(input()) for _ in range(5)] +k=int(input()) +for i in range(1,5): + if L[i]-L[i-1]>k: + print("":("") + exit() +print(""Yay!"")" +p04045,s180603882,Wrong Answer,"N, K, *D = open(0).read().split() +*N, = map(int, N) +*D, = map(int, D) +N += [0] + +for i in range(len(N)-1): + while N[i] in D: + N[i] += 1 + + if N[i] > 9: + N[i] %= 10 + N[i+1] += 1 + +if N[i] > 0: + while N[i] in D: + N[i] += 1 + i += 1 + +print(''.join([str(j) for j in N[:i][::-1]])) +" +p03059,s237248847,Accepted,"a, b, t = [int(i) for i in input().split()] +print(t//a*b)" +p02602,s230387401,Wrong Answer,"import numpy as np + +N, K = map(int, input().split()) +scores = list(map(int, input().split())) + +tot = np.prod(scores[0:K]) +past = tot +for i in range(N-K): + tot = np.prod(scores[i+1:i+K+1]) + if tot > past: + print(""Yes"") + else: + print(""No"") + past = tot" +p02831,s459082092,Accepted,"a,b=map(int,input().split()) +def gcd(a,b): + while b!=0: + a,b=b,a%b + return a +print(a*b // gcd(a,b))" +p03013,s862055862,Wrong Answer,"N,M = [int(x) for x in input().split()] +a = [] +mod = 10**9 + 7 +DP = [0]*(N+1) +for i in range(M): + aa = int(input()) + DP[aa] = -1 +DP[0] = 1 +if not 1 in a: + DP[1] = 1 +for i in range(2,N+1): + if DP[i] != -1: + DP[i] = max(0,DP[i-1]) + max(0,DP[i-2]) +ans = DP[N] % mod +print(ans)" +p03711,s749045467,Accepted,"a,b=map(int,input().split()) +n=[1,3,5,7,8,10,12] +m=[4,6,9,11] +if a in n and b in n:print(""Yes"") +elif a in m and b in m:print(""Yes"") +else:print(""No"")" +p03695,s952140299,Accepted,"n = int(input()) +rates = set() +over = 0 +people = list(map(int, input().split())) +for rate in people: + if rate // 400 >= 8: + over += 1 + else: + rates.add(rate // 400) +print(max(1, len(rates)), len(rates) + over)" +p03071,s001116464,Accepted,"def main(): + #n = int(input()) + #s = input() + #s = input().split() + a,b = list(map(int,input().split())) + #c = [input().split() if i in range(n)] + ans = 0 + + for i in range(2): + if a >= b: + ans += a + a -= 1 + else: + ans += b + b -= 1 + print(ans) + +if __name__ == '__main__': + main()" +p02548,s033884305,Accepted,"def funcion_a(n): + count = 0 + i = 2 + while i*i <= n: + count += 1 + j = i + 1 + while i*j <= n: + count += 2 + j += 1 + i += 1 + return count + +n = int(input()) +answer = funcion_a(n-1) + (n-2)*2 + 1 +print(answer) + + + " +p02765,s792529698,Accepted,"n, r = list(map(int,input().split())) +if n >= 10: + print(r) +else: + temp = 100 * (10 -n) + print(r + temp)" +p02583,s725053817,Accepted,"n = int(input()) +l = list(map(int,input().split())) + +cnt =0 +for i in range(n-2): + for j in range(i,n-1): + for k in range(j,n): + li = [l[i],l[j],l[k]] + if len(set(li))==3 and max(li)*2 0 and i > 0 and q > 0: + total = 10000*i + 5000*q + 1000*c + if total == Y: + res = True + a = i + b = q + d = c + +if res: + print('{} {} {}'.format(a, b, d)) +else: + print('-1 -1 -1')" +p03000,s758459854,Wrong Answer,"n,x=map(int,input().split()) +s=list(map(int,input().split())) +b,c=0,0 +while b<=x and len(s)>0: + c+=1 + b+=s[0] + del s[0] +print(c) +" +p03407,s705278034,Accepted,"a,b,c = map(int,input().split()) +# print(a,b,c) + +if c <= a + b: + print('Yes') +else: + print('No') +" +p03387,s472861677,Wrong Answer,"z=list(map(int,input().split())) +list.sort(z, reverse=True) +c=z[0] +b=z[1] +a=z[2] +x=0 + +if ((c-b)%2==0 and (c-a)%2==0): + x+= (c-b)//2+(c-a)//2 +elif (((c-b)%2==0 and (c-a)%2==1) or ((c-b)%2==1 and (c-a)%2==0)): + x+= (c-b)//2 + (c-1)//2 +2 +else: + x+=(c-b)//2 + (c-a)//2 + 1 +print(x)" +p02694,s206365864,Accepted,"x = int(input()) +cur = 100 +ans = 0 +while(cur < x): + cur = cur * 101//100 + ans += 1 +print(ans)" +p02657,s997238573,Accepted,"a, b = list(map(int ,input().split())) +print(a*b)" +p03252,s975709832,Accepted,"s = input() +t = input() + +def f(x): + dic = {} + for c in x: + if c in dic: + dic[c] += 1 + else: + dic[c] = 1 + return dic + +d1 = f(s) +d2 = f(t) +l1 = [i for i in d1.values()] +l2 = [i for i in d2.values()] +l1.sort() +l2.sort() + +if l1 == l2: + print('Yes') +else: + print('No')" +p02909,s238591393,Accepted,"w=[""Sunny"",""Cloudy"",""Rainy"",""Sunny""];print(w[w.index(input())+1])" +p03745,s904397819,Wrong Answer,"n = int(input()); a = list(map(int, input().split())); b = -1; x = 1 +for i in range(n-1): + if b == 0: + if a[i] > a[i+1]: b = -1; x += 1 + elif b == 1: + if a[i] < a[i+1]: b = -1; x += 1 + else: + b = 0 if a[i] < a[i+1] else 1 +print(x)" +p02600,s296858463,Accepted,"import math +x=int(input()) +k=8-math.floor((x-400)/200.0) +print(k)" +p02665,s622409061,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +AA=[0] +for a in A[1:]: + AA.append(AA[-1]+a) +print(AA) +f=1 if A[0]==0 else 0 +r=1 +b=1 +for i,a in enumerate(A[1:]): + x=min(b*2,AA[-1]-AA[i]) + if ia or i==N-1 and x==a: + b=x-a + r+=x + else: + f=0 +print(r if f else -1)" +p03485,s506819292,Accepted,"def ABC_82_A(): + a,b = map(int, input().split()) + print(int((a+b+1)/2)) + +if __name__ == '__main__': + + ABC_82_A()" +p02727,s126175161,Accepted,"import numpy as np + +x, y, a, b, c = map(int, input().split()) +p = np.array(list(map(int, input().split()))) +q = np.array(list(map(int, input().split()))) +r = np.array(list(map(int, input().split()))) + +p = np.sort(p)[::-1][:x] +q = np.sort(q)[::-1][:y] +a = np.hstack((p, q, r)) +a = np.sort(a)[::-1][:(x+y)] + +print(np.sum(a))" +p02790,s996560769,Wrong Answer,"a,b=map(int,input().split()) +hai1=[] +hai2=[] +for k in range(0,a): + hai1.append(str(b)) +for i in range(0,b): + hai2.append(str(a)) +ak="""".join(hai1) +bk="""".join(hai2) +c=[0]*2 +c[0]=int(ak) +c[1]=int(bk) +c.sort() +print(c[0])" +p03241,s188880863,Wrong Answer,"n, m = map(int, input().split()) +def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + divisors.sort() + return divisors +div = make_divisors(n) +for i in div[::-1]: + if i <= m / n: + print(i) + break" +p02957,s453715144,Accepted,"A, B = map(int, input().split()) +div, rem = divmod(abs(A - B), 2) +print(""IMPOSSIBLE"" if rem else min(A, B) + div) +" +p03289,s539463574,Accepted,"strs=input() +che=True +c=True +coun=False +for i in range(0,len(strs)) : + if(i==0): + c=True if strs[i]==""A"" else False + else : + if(strs[i].isupper()): + if( (not coun) and i>=2 and i<=len(strs)-2 and strs[i]=='C'): + coun=True + else: + che=False +print(""AC"") if che and coun and c else print(""WA"") + +" +p02612,s157879330,Accepted,"n = int(input()) + +a = n % 1000 +if a == 0: + print(0) +else: + print(1000 - a)" +p03624,s165014488,Accepted,"s=input() +s=list(set(s)) + +A=[] +for i in range(97,123): + A.append(chr(i)) + + +for i in range(len(A)): + if A[i] in s: + continue + else: + print(A[i]) + exit() + +print(""None"")" +p02766,s141280626,Accepted,"n,k=map(int,input().split()) +cnt=0 +while n>0: + n//=k + cnt+=1 +print(cnt) +" +p02957,s599781699,Wrong Answer,"a,b=input().split() +a=int(a) +b=int(b) +if (a+b)%2>=0: + print(int((a+b)/2)) +else: + print(""IMPOSSIBLE"")" +p02694,s813810236,Wrong Answer,"a=int(input()) +i=100 +f=0 +while (i/a)<1: + if (i/a)<1/4424440255150901545896526287522681900236800: + i=int(i*44244402551509015458965262875226819002368/100) + f=f+9000 + else: + i=int(i*1.01) + f=f+1 +print(f)" +p03037,s294713097,Accepted,"n,m=map(int,input().split()) +l=[] +r=[] +for i in range(m): + templ,tempr=map(int,input().split()) + l.append(templ) + r.append(tempr) +l_max=max(l) +r_min=min(r) + +if l_max<=r_min: + print(r_min-l_max+1) +else: + print(0) + " +p03773,s402225336,Accepted,"a,b=map(int,input().split()) +print(a+b-24 if a+b>=24 else a+b)" +p02623,s731312362,Wrong Answer,"n,m,k=map(int,input().split()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) +AS=[0] +BS=[0] +r=0 +for i in A: + if i+AS[-1]k: + j-=1 + r=max(r,i+j) +print(r)" +p03131,s177718357,Accepted,"k,a,b = map(int,input().split()) +k -= a-1 +div,mod = divmod(k,2) +ans = 1 + (a-1) +if a+2 <= b: + dum = b-a + ans += dum*div + if mod == 1: + ans += 1 +else: + ans += k +print(ans)" +p02767,s444940013,Wrong Answer,"N = int(input()) +X = input().split() +X = [int(s) for s in X] + +X = sorted(X) +range_X = X[-1] - X [0] + +E_min = 10000000000000 +for p in range(range_X): + E = 0 + for x in X: + E += (x-p)**2 + if E < E_min: + E_min = E +print(E_min)" +p03796,s000253431,Accepted,"N = int(input()) +power = 1 +for i in range(1,N+1): + power = power * i % (10**9+7) +print(power)" +p03281,s625351260,Wrong Answer,"n = int(input()) + +if n < 105: + print(0) +elif n < 165: + print(1) +elif n < 195: + print(2) +else: + print(3)" +p02796,s590497332,Wrong Answer,"n = int(input()) +ls = [] +for i in range(n): + x, l = map(int, input().split()) + ls.append([x-l, x+l]) +ls.sort() + +now = ls[0] + +ans = n + +for i in range(1,n): + if now[1] > ls[i][0]: + ans -= 1 + else: + now = ls[i] + +print(ans)" +p03095,s102076371,Wrong Answer,"import collections + +N = int(input()) +S = list(input()) + +MOD = 10 ** 9 +c = collections.Counter(S) +ans = 1 +for k, v in c.items(): + ans *= v + 1 + ans %= MOD + +ans -= 1 +print(ans) +" +p03723,s941348861,Wrong Answer," +a, b, c = list(map(int, input().split(' '))) +cnt = 0 +if a == b == c: + cnt = -1 +else: + while not (a%2 or b%2 or c%2): + cnt += 1 + a,b,c=(b+c)/2,(a+c)/2,(a+b)/2 + +print(cnt) +" +p03037,s475234201,Wrong Answer,"n,k = map(int,input().split()) +rc = [list(map(int,input().split())) for i in range(k)] + +tmp = set(range(1,n+1)) + +for i in rc: + tmp = tmp & set(range(i[0],i[1])) + +print(len(tmp)) +" +p03612,s868373254,Wrong Answer,"import sys +input = sys.stdin.readline +def main(): + N = int(input()) + p = list(map(int, input().split())) + ans = 0 + for i in range(N-1): + if i+1 == p[i]: + tmp = p[i] + p[i] = p[i+1] + p[i+1] = tmp + ans += 1 + print(ans) +if __name__ == ""__main__"": + main()" +p02661,s412838578,Wrong Answer,"N = int(input()) +A = [0] * (N + 1) +B = [0] * (N + 1) + +count = 0 + +for i in range(1, N + 1): + A[i], B[i] = map(int, input().split()) + +if N % 2 == 1: + centerA = int(A[(N + 1) // 2]) + centerB = int(B[(N + 1) // 2]) +else: + centerA = (A[N // 2] + A[N // 2 + 1]) / 2 + centerB = (B[N // 2] + B[N // 2 + 1]) / 2 + +#print(centerA, centerB) + +if N % 2 == 1: + count = int(centerB) - int(centerA) + 1 +else: + count = int(centerB * 2) - int(centerA * 2) + 1 + +print(int(count))" +p02832,s022329865,Wrong Answer,"import sys +N=int(input()) +a = list(map(int,input().split())) +cnt=0 +j=0 +if((1 in a)==False): + print(-1) + sys.exit() +for i in range(N): + for n in range(j,N): + if(a[n]==i+1): + j=n+1 + break + else: + cnt+=1 + + +print(cnt) + + +" +p02765,s027856445,Accepted,"n,r = map(int,input().split()) +if n >= 10: + print(r) +else: + print(r+100*(10-n))" +p03799,s510796332,Accepted,"n,m=map(int,input().split()) + +ans=0 + +if m-2*n>=0: + m-=2*n + ans+=n + (m//4) + print(ans) +else: + ans+=m//2 + print(ans) + exit(0)" +p02552,s438501239,Accepted,"s=int(input('')) +if s==0: + print(1) +else: + print(0)" +p02787,s544693745,Wrong Answer,"import math +import copy +H,N=map(int,input().split()) + +inf=float('inf') +dp=[0]+[inf]*H + +for i in range(N): + A,B=map(int,input().split()) + ndp=copy.deepcopy(dp) + for j in range(A,H+1): + ndp[j]=min(ndp[j-A]+B,dp[j]) + + if j > H-A: + ndp[-1]=min(ndp[-1],ndp[j]+B) + + dp=ndp + if A>=H: + ndp[-1]=min(B,dp[-1]) + +print(dp[-1]) +" +p02713,s724181493,Wrong Answer,"def gcd(p, q): + if p % q == 0: + return q + else: + new_p = q + q = p % q + return gcd(new_p, q) + + +memo = [] +ans = 0 +K = int(input()) +for a in range(1, K+1): + for b in range(1, K+1): + memo.append(gcd(a,b)) +memo.sort() +new_memo = list(set(memo)) +for c in range(1, K + 1): + ans += gcd(c, new_memo[c-1]) * memo.count(new_memo[c-1]) +print(ans) +" +p02958,s055509058,Accepted,"#!/usr/bin/env python3 +n = int(input()) +p = list(map(int, input().split())) +q = [0]*n +for i in range(n): + q[i] = p[i] - i - 1 +if q.count(0) >= n - 2: + print('YES') +else: + print('NO')" +p03860,s603255584,Accepted,"# A +s = list(map(str, input().split())) + +print(s[0][0]+s[1][0]+s[2][0])" +p03043,s217569182,Accepted,"import sys + + +inint = lambda: int(sys.stdin.readline()) +inintm = lambda: map(int, sys.stdin.readline().split()) +inintl = lambda: list(inintm()) +instrm = lambda: map(str, sys.stdin.readline().split()) +instrl = lambda: list(instrm()) + +n, k = inintm() + +ans = 0 + +for i in range(1,n+1): + b = 0 + for _ in range(1,18): + if i >= k: + break + i *= 2 + b += 1 + ans += (1/n)*(0.5**b) + +print(ans) +" +p03556,s587889346,Accepted,"n = int(input()) +for i in range(n): + a = i**2 + if a>n: + b = i + break +if n<=2: + print(1) +else: + print((b-1)**2)" +p02923,s869492008,Accepted,"n = int(input()) +l_h = list(map(int, input().split())) + +max_mov_cnt = 0 +tmp = 0 +for i in range(n-1): + if l_h[i] >= l_h[i+1]: + tmp += 1 + else: + max_mov_cnt = max(max_mov_cnt, tmp) + tmp = 0 + +max_mov_cnt = max(max_mov_cnt, tmp) +print(max_mov_cnt) +" +p02602,s323369169,Accepted,"#!/usr/bin/env python3 +import collections as cl +import sys + + +def II(): + return int(sys.stdin.readline()) + + +def MI(): + return map(int, sys.stdin.readline().split()) + + +def LI(): + return list(map(int, sys.stdin.readline().split())) + + +def main(): + n, k = MI() + scores = LI() + + score_now = 1 + + for i in range(k, n): + next_score = scores[i] / scores[i - k] + print(""Yes"" if next_score > 1 else ""No"") + + +main() +" +p02663,s462166220,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) + +print((H2 * 60 + M2) - (H1 * 60 + M1) - K)" +p03624,s752737196,Wrong Answer,"L = [chr(i) for i in range(97, 123)] +f = 0 +s = input() +for l in L: + if s.count(l) == 0: + print(l) + f = 1 +if f == 0: + print(""None"")" +p03625,s179094260,Accepted,"from collections import Counter + +input() +d = Counter(map(int, input().split())) +d = dict(sorted(d.items(), reverse=True)) +ans = [] +for i, j in d.items(): + if j >= 4: + ans.append(i) + if j >= 2: + ans.append(i) +if len(ans) >= 2: + print(ans[0] * ans[1]) +else: + print(0)" +p02773,s101447551,Wrong Answer,"import sys +import collections +n = int(input()) +li=[input() for _ in range(n)] +li.sort() +c = collections.Counter(li) +max_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())] +for s in max_list: + print(s)" +p03075,s288450014,Accepted,"a,b,c,d,e,k=[int(input()) for i in range(6)] +if b-a>k or c-a>k or d-a>k or e-a>k or c-b>k or d-b>k or e-b>k or d-c>k or e-c>k or e-d>k: + print("":("") +else: + print(""Yay!"")" +p02773,s541019136,Accepted,"def main(): + num = int(input()) + + tmp = [input() for i in range(num)] + + tmp2 = {} + for t in tmp: + if len(tmp2) == 0: + tmp2[t] = 1 + else: + if t in tmp2: + tmp2[t] += 1 + else: + tmp2[t] = 1 + + _tmp2 = sorted(tmp2.items(), key=lambda x:x[1]) + tmp3 = sorted(tmp2.items()) + for t in tmp3: + if _tmp2[-1][1] == t[1]: + print(t[0]) + +main()" +p02796,s774240126,Accepted,"n=int(input()) +a = [list(map(int, input().split())) for i in range(n)] + +for i in range(n): + a[i].append(a[i][0]-a[i][1]) + a[i].append(a[i][0]+a[i][1]) + +a.sort(key=lambda x: x[3]) + +left=-float('inf') +count=0 +for i in range(n): + if a[i][2]>=left: + count+=1 + left=a[i][3] + +print(count)" +p02983,s746468625,Accepted,"L,R = map(int,input().split()) +if R-L >= 2019: + print(0) +else: + mR = R%2019 + mL = L%2019 + if mL > mR: + print(0) + else: + mini = 2019 + for i in range(mL, mR): + for j in range(i+1, mR+1): + mini = min(mini, (i*j)%2019) + print(mini)" +p02713,s797807230,Accepted,"from math import gcd + +K = int(input()) + +ans = 0 +for a in range(1, K+1): + for b in range(1, K+1): + for c in range(1, K+1): + p = gcd(a, b) + ans += gcd(p, c) +print(ans)" +p02790,s546488700,Wrong Answer,"a,b = input().split() +a1 = a*int(b) +a2 = b*int(a) +print(max(a1,a2))" +p03627,s262213584,Accepted,"import collections +N = int(input()) +a = collections.Counter(list(map(int,input().split()))) +p = sorted([i for i in a.items() if i[1]>=2]) +if len(p)<2: + print(0) +elif p[-1][1]>=4: + print(p[-1][0]**2) +else: + print(p[-1][0]*p[-2][0])" +p02790,s211226597,Accepted,"a, b = map(int, input().split()) +print(str(min(a, b)) * max(a, b)) +" +p03161,s233622468,Wrong Answer,"N, K = map(int, input().split()) +H = list(map(int, input().split())) +DP = [100000]*N +for i, h in enumerate(H): + if i == 0: + DP[0] = 0 + for k in range(1,K+1): + if i - k >= 0 : + DP[i] = min(DP[i], DP[i-k]+abs(H[i]-H[i-k])) +print(DP[-1])" +p02621,s765888856,Accepted,"a=int(input()) +k=a+a**2+a**3 +print(k)" +p03261,s564979096,Wrong Answer,"#https://atcoder.jp/contests/abc109/tasks/abc109_b +import collections +N = int(input()) +Word_List = [] +SP = """" +for i in range(N): + CW = str(input()) + if i == 0: + Word_List.append(CW) + SP = CW[-1] + elif SP != CW[0]: + break + else: + Word_List.append(CW) + SP = CW[-1] +else: + Word_List = collections.Counter(Word_List) + if len(Word_List) != N: + print(""No"") + else: + print(""Yes"")" +p02688,s793260137,Accepted,"n,k = map(int,input().split()) + +okashi = [0 for i in range(n)] +for i in range(k): + d = int(input()) + for j in list(map(int,input().split())): + okashi[j-1] = 1 + +cnt = 0 +for i in okashi: + if i == 0: + cnt += 1 + +print(cnt)" +p02594,s528195825,Accepted," +import collections + + +def main(): + x = int(input()) + + print(""Yes"" if x >= 30 else ""No"") + + +if __name__ == '__main__': + main() +" +p03433,s775409342,Accepted,"N = int(input()) +A = int(input()) + +B = N//500 +C = N - 500*B + +if C <= A: + print(""Yes"") +else: + print(""No"")" +p02664,s347933401,Wrong Answer,"t= list(input()) +n=len(t) +for i in range(n): + if i==0: + if t[i]=='?': + t[i]='D' + else: + if t[i]=='?': + if t[i-1]=='D': + t[i]='P' + elif t[i-1]=='P': + t[i]='D' + +ans = ''.join(t) +print(ans)" +p03043,s864041240,Accepted," +N, K = map(int, input().split()) + + +import math + +sum = 0 +for i in range(N): + X = math.log2(K/(i+1)) + X = math.floor(X) if X % 1 == 0 else math.floor(X+1) + #print(X, i, K) + X = X if X > 0 else 0 + sum += (1/N)*(1/2)**X + +print(sum)" +p03624,s439961791,Accepted,"S = input() + +import sys +for i in range(26): + ans = chr(ord('a') + i) + if not(ans in S): + print(ans) + sys.exit() +ans = ""None"" +print(ans)" +p02663,s790607585,Accepted,"h1, m1, h2, m2, K = map(int, input().split()) + +a = 60*h1 + m1 +b = 60*h2 + m2 +print(b-K-a)" +p02767,s239269004,Wrong Answer,"n = int(input()) +x_list = list(map(int, input().split("" ""))) + + +min = min(x_list) +max = max(x_list) + +ans = 100*100 + +for p in range(1, 100+1): + tmp = 0 + for x in x_list: + tmp += (x - p) ** 2 + if ans > tmp: + ans = tmp + +print(ans) + + +" +p03434,s881708811,Accepted,"n = int(input()) + +a_list = list(map(int, input().split())) +# print(a_list) + +a_list = sorted(a_list, reverse=True) +# print(a_list) + +alice = 0 +bob = 0 +for i in range(len(a_list)): + if i % 2 == 0: + alice += a_list[i] + else: + bob += a_list[i] +print(alice - bob)" +p03639,s501446767,Accepted,"import sys +input = sys.stdin.readline + +n = int(input()) +a = list(map(int, input().split())) +cnt_0 = 0 +cnt_2 = 0 +for i in range(n): + if a[i] % 4 == 0: + cnt_2 += 1 + elif a[i] % 2 == 1: + cnt_0 += 1 +if (cnt_2 >= cnt_0 - 1 and cnt_2 + cnt_0 == n) or cnt_2 >= cnt_0: + print('Yes') +else: + print('No') +" +p02546,s190892259,Accepted,"s = input() + +if s[-1] == 's': + s += 'es' +else: + s += 's' + +print(s)" +p03799,s680269253,Accepted,"s,c = map(int,input().split()) +res = 0 +if s*2 <= c: + res = s + c -= s*2 + s = 0 +else: + res += c//2 + c = 0 + +if c: + res += c//4 +print(res)" +p03474,s719685116,Accepted,"import re +a,b = map(int,input().split()) +s = input() +if s[a]=='-' and re.match(r'^\d+$',s[:a]) and re.match(r'^\d+$',s[a+1:]): + print('Yes') +else: + print('No')" +p03605,s945832723,Accepted,"nStr = input() + +if nStr[0] == ""9"" or nStr[1] == ""9"": + print(""Yes"") +else: + print(""No"") +" +p03487,s755016580,Accepted,"def main(): + n=int(input()) + a=list(map(int,input().split())) + a.sort() + a.append(-1) + cnt=1 + ans=0 + for i in range(n): + if a[i]==a[i+1]: + cnt+=1 + else: + if cnt>=a[i]: + ans+=cnt-a[i] + else: + ans+=cnt + cnt=1 + print(ans) +if __name__==""__main__"": + main()" +p02923,s312038302,Accepted,"N = int(input()) +H = list(map(int, input().split())) +total = 0 +max_total = 0 + +for i in range(N-1): + if H[i] >= H[i+1]: + total += 1 + max_total = max(total, max_total) + else: + total = 0 + +print(max_total)" +p03282,s685837669,Accepted,"S = input() +K = int(input()) +ans = 1 +for i, s in enumerate(S): + if i+1 == K: + ans = s + break + if s == '1': + continue + else: + ans = s + break + +print(ans)" +p03352,s617056839,Wrong Answer,"x = int(input()) + +for i in range(x): + for j in range(2, 10): + if (x-i)**(1/j) % 1 == 0: + print(x-i) + exit()" +p03041,s011469812,Wrong Answer,"n,k=map(int,input().split()) +s=list(input()) +s[k-1]=s[k-1].lower() +print(s) +print("""".join(s))" +p02691,s617296809,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +b = [0]*n +c = [0]*n +for i in range(n): + b[i] = a[i]-i +for i in range(n): + c[i] = a[i]+i +cb = Counter(b) +cc = Counter(c) +k=cb.keys() +ans = 0 +for i in k: + ans += cb[i]*cc[i*(-1)] +print(ans) +" +p03612,s565328803,Wrong Answer," +url = ""https://atcoder.jp//contests/abc072/tasks/arc082_b"" + +def main(): + n = input() + p = list(map(int, input().split())) + count = 0 + for i, v in enumerate(p): + if i == len(p)-1: + print(count) + exit() + if i+1 == v or i+2 == p[i+1]: + p[i] = p[i+1] + p[i+1] = v + count += 1 + + + + +if __name__ == '__main__': + main() +" +p03673,s260913299,Accepted,"from collections import deque + +n = int(input()) +a = list(map(int, input().split())) + +b = deque() + + +for i in range(n): + if i % 2 == 0: + b.appendleft(a[i]) + else: + b.append(a[i]) +if n % 2 == 0: + b = list(b)[::-1] +print(*b) +" +p02572,s481999559,Accepted," +N=int(input()) +A=list(map(int,input().split())) + +mod=10**9+7 + +sumA=sum(A) + +ans=0 +for i in range(N): + ans+=(A[i]*(sumA-A[i])) + +ans=ans//2 +print(ans%mod) + " +p02754,s439277465,Accepted,"N, A, B = map(int,input().split()) +patternNum = N // (A + B) +remains = N % (A + B) +if (remains > A): + print(patternNum * A + A) +else: + print(patternNum * A + remains)" +p02911,s330584214,Accepted,"from collections import Counter +N, K, Q = map(int, input().split()) +A = Counter([int(input()) for _ in range(Q)]) +[print(""Yes"" if K > Q - A.get(i+1, 0) else ""No"") for i in range(N)] +" +p03799,s295271127,Accepted,"def INT(): + return int(input()) + +def MI(): + return map(int, input().split()) + +def LI(): + return list(map(int, input().split())) + +N, M = MI() + +if 2 * N <= M: + ans = N + (M - 2 * N) // 4 + +else: + ans = M // 2 + +print(ans)" +p03352,s397020206,Accepted,"x = int(input()) +ans = 1 +for i in range(2,x): + a = 2 + while i**a<=x: + ans = max(i**a,ans) + a+=1 +print(ans)" +p02624,s585258185,Accepted,"n = int(input()) +ans = 0 +for i in range(1,n+1): + ans += ((i+i*(n//i))*(n//i))//2 + #print(ans) +print(ans)" +p03862,s406707764,Accepted,"from copy import deepcopy +N, x = map(int, input().split()) +a = list(map(int, input().split())) +c = 0 +for i in range(N - 1): + if a[i] + a[i + 1] > x: + c += a[i] + a[i + 1] - x + a[i + 1] -= a[i] + a[i + 1] - x + if a[i + 1] < 0: + a[i] -= -a[i + 1] + a[i + 1] = 0 +print(c)" +p02768,s348438521,Wrong Answer,"line = input('') +n = int(line.split(' ')[0]) +a = int(line.split(' ')[1]) +b = int(line.split(' ')[2]) + +sum_case = 0 +for i in range(1,n): + if i != a and i != b: + c = n * (n-1) / 2 + sum_case += c + +all_case = 10**9+7 +print((sum_case+1) % all_case) +" +p03219,s134299696,Accepted,"x, y = map(int, input().split()) + +print(x + y // 2) +" +p02711,s373885787,Accepted,"n=input() +if ""7"" in n: + print(""Yes"") +else: + print(""No"")" +p03672,s304162866,Wrong Answer,"s = input() +while s[:len(s)//2] != s[len(s):]: + s = s[:-2] +print(len(s))" +p03607,s247802932,Accepted,"N = int(input()) + +paper = [] +numbers = sorted([int(input()) for _ in range(N)]) + +# for n in numbers: +for i in range(N - 1): + if numbers[i] == numbers[i + 1]: + numbers[i] = -1 + numbers[i + 1] = -1 + if numbers[i] != -1: + paper.append(numbers[i]) + +if numbers[N - 1] != -1: + paper.append(numbers[N - 1]) +print(len(paper))" +p02888,s527571135,Wrong Answer,"import itertools + +n = int(input()) + +l = list(map(int, input().split())) + +zzz = list(itertools.combinations(l,2)) + + +cnt = 0 +print(zzz) + +for z in zzz: + + b = z[0] + c = z[1] + + b_flg = True + + c_flg = True + + for i in l: + if b_flg and i == b: + continue + + if c_flg and i == c: + continue + + if abs(b-c) < i < b+c: + cnt += 1 + +print(cnt / 3) +" +p03037,s617706029,Accepted,"n, m = map(int,input().split()) +lst = [] +for i in range(m): + lst.append(list(map(int,input().split()))) + +min = lst[0][0] +max = lst[0][1] +for v in lst: + if v[0] > min: + min = v[0] + if v[1] < max: + max = v[1] +if min <= max: + print(max-min + 1) +elif min > max: + print(0) +" +p03417,s907889891,Accepted,"def solve(): + N, M = map(int, input().split()) + + if N == 1 and M == 1: + print(1) + elif N == 1 or M == 1: + print(N * M - 2) + else: + print(N * M - (N * 2 + M * 2 - 4)) + +if __name__ == '__main__': + solve()" +p02767,s272451347,Accepted,"N = int(input()) +l_x = list(map(int, input().split())) +d_min = 999999999999999 +left = min(l_x) +right = max(l_x) +for p in range(left, right + 1): + total = 0 + for x in l_x: + total += (p - x) ** 2 + if total < d_min: + d_min = total + +print(d_min) " +p02570,s101777350,Accepted,"a = input().split() +dist = int(a[0]) +time = int(a[1]) +speed = int(a[2]) +if(speed * time < dist): + print(""No"") +else: + print(""Yes"")" +p02676,s009707032,Wrong Answer,"k = input() +s = input() +print(s) +if(len(s) <= int(k)): + print(s) +else: + print(s[:int(k)])" +p02624,s174122791,Accepted,"n = int(input()) +ans = 0 + +for i in range(1, n + 1): + y = n // i + ans += y * (y+1) * i // 2 +print(ans)" +p03338,s040102649,Wrong Answer,"n=int(input()) +s=input() +x="""" +y="""" +saidai=0 +for i in range(n): + x=s[:i+1] + y=s[i:] + #print(x,y) + x_y_and=set(x)&set(y) + if len(x_y_and)>saidai: + saidai=len(x_y_and) + x="""" + y="""" + x_y_and="""" +print(saidai) +" +p03633,s488704870,Accepted,"N = int(input()) +T = [int(input()) for _ in range(N)] + +import fractions +def lcm(x, y): + return (x * y) // fractions.gcd(x, y) + +ans = 1 +for i in T : + ans = lcm(ans, i) + +print(ans) +" +p02935,s779762578,Accepted,"n = int(input()) +V = list(map(int, input().split())) + +V = sorted(V) + +for i in range(n-1): + V[0] = (V[0] + V[1]) / 2 + del V[1] + +print(V[0]) + " +p02843,s166081086,Wrong Answer,"n = str(input()) +if len(n) <= 2: + print(0) +else: + a = n[0:-2] + tens = int(n[-2]) + need = tens*2 + ones = int(n[-1]) + if ones < 5: + need += 1 + else: + need +=2 + + if need < int(a): + print(1) + else: + print(0) +" +p02778,s100631213,Accepted,"S=str(input()) +print('x'*len(S))" +p03767,s777426735,Accepted,"n = int(input()) +a = sorted(list(map(int, input().split())), reverse=True) + +ans = 0 + +for i in range(1, 2*n, 2): + ans += a[i] + +print(ans)" +p02697,s696564021,Accepted,"n,m=map(int,input().split()) +for i in range(m):print(i+1,n-i-((i>=m/2)&~n))" +p02583,s948959336,Accepted,"#B - Making Triangle +N = int(input()) +L = list(map(int,input().split())) +count = 0 +for i in range(N-2): + for j in range(i+1,N): + for k in range(j+1,N): + if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i] and L[i] != L[j] and L[j] != L[k] and L[k]!=L[i]: + count += 1 + else: + pass + +print(count)" +p02959,s075485851,Accepted,"N = int(input()) +Monster = list(map(int, input().split())) +Yusha = list(map(int, input().split())) + +total = 0 + +for i in range(N+1): + if i > 0: + Min = min(Monster[i], Yusha[i-1]) + Monster[i] -= Min + Yusha[i-1] -= Min + total += Min + + if i < N: + Min = min(Monster[i], Yusha[i]) + Monster[i] -= Min + Yusha[i] -= Min + total += Min + +print(total)" +p03262,s422787937,Accepted,"import numpy as np +from fractions import gcd +n,x=map(int,input().split()) +xl=list(map(int,input().split())) + +xl.append(x) + + +p=min(xl) +ans=x-p +for i in range(n+1): + ans=gcd(xl[i]-p,ans) +print(ans) +" +p03773,s991903959,Accepted,"a, b = map(int, input().split()) + +print((a+b)%24)" +p02813,s294645152,Wrong Answer,"import itertools + +def main(): + n = int(input()) + nums = [] + for i in range(2): + nums.append(list(map(str, input().split()))) + kumi = list(itertools.permutations([str(i) for i in range(1, n+1)], n)) + f, t = 0, 0 + for i, s in enumerate(kumi): + if ''.join(nums[0]) == ''.join(s): + f = i + elif ''.join(nums[1]) == ''.join(s): + t = i + print(abs(f - t)) + +if __name__ == '__main__': + main()" +p03799,s193722943,Wrong Answer,"N,M = map(int, input().split()) + +ans = 0 +if M>=2*N: + ans = ans + N + M = M - 2*N + N = N - N + ans = ans + M//4 + print(ans) +else: + print(0)" +p03371,s225443647,Wrong Answer,"##import sys +#import numpy as np +import math +#from fractions import Fraction +import itertools +from collections import deque +from collections import Counter +import heapq +from fractions import gcd +#input=sys.stdin.readline +#import bisect +a,b,c,x,y=map(int,input().split()) +if xt: i-=1 + t=i +else: print('Yes')" +p03417,s071789157,Accepted,"n,m = map(int,input().split()) +if n == m == 1: + print(1) +elif min(n,m) == 1: + print(max(0, max(n,m) - 2)) +else: + print((n-2) * (m-2))" +p02753,s759189427,Accepted,"import sys +import numpy as np + +# input = sys.stdin.readline + +s = input() + +if (s == ""AAA"") or (s == ""BBB""): + print(""No"") +else: + print(""Yes"")" +p02987,s120203390,Wrong Answer,"s=list(input()) +s.sort() +if s[0]==s[1] and s[2]==s[3]:print('Yes') +else:print('No')" +p02729,s010402479,Wrong Answer,"#A +n,m=map(int,input().split()) +if n<=1: + n_ans=0 +else: + n_ans=n*(n-1)/2 + +if m<=1: + m_ans=0 +else: + m_ans=m*(m-1)/2 + + +print(n_ans+m_ans)" +p02789,s581609384,Accepted,"n, m = map(int, input().split()) + +print(""Yes"" if n == m else ""No"")" +p03351,s188920406,Accepted,"import sys + + +stdin = sys.stdin +def ns(): return stdin.readline().rstrip() +def ni(): return int(stdin.readline().rstrip()) +def nm(): return map(int, stdin.readline().split()) +def nl(): return list(map(int, stdin.readline().split())) + + +def main(): + *A, d = nm() + a = A[0] + c = A[2] + A = sorted(A) + D = [A[i + 1] - A[i] for i in range(2)] + if all([dd <= d for dd in D]) or abs(a - c) <= d: + print('Yes') + else: + print('No') + + +if __name__ == '__main__': + main() +" +p03254,s370245494,Wrong Answer,"N, x = map(int, input().split()) +a = list(map(int, input().split())) + +cont = 0 + +for y in sorted(a): + if x >= y: + cont += 1 + x -= y + +if x != 0: + cont = cont-1 +print(cont)" +p02630,s320577466,Wrong Answer,"n = int(input()) +arr = list(map(int,input().split())) +t = int(input()) +while t: + t-=1 + k,r = map(int,input().split()) + arr.sort() + if k in arr: + for i in range(n): + if arr[i]>k: + break + if arr[i]==k: + arr[i]=r + + print(arr) + print(sum(arr))" +p02699,s543930235,Accepted,"S, W = map(int, input().split()) +print(""unsafe"" if S <= W else ""safe"") +" +p02720,s942313970,Accepted,"import queue + +k = int(input()) + +lunlun = queue.Queue() +for i in range(1,10): + lunlun.put(i) + +def make_lunlun(p): + last = p%10 + if last != 0: + lunlun.put(p * 10 + last - 1) + lunlun.put(p*10 + last) + if last != 9: + lunlun.put(p * 10 + last + 1) + +i = 0 +while i < k: + p = lunlun.get() + make_lunlun(p) + i += 1 + if i == k: + print(p) + break +" +p02953,s532936944,Wrong Answer,"n = int(input()) +h = list(map(int, input().split())) + +for i in range(n - 1): + if h[i] - h[i + 1] > 1: + print('No') + break + + elif h[i] - h[i + 1] == 1: + if x == 1: + print('No') + break + else: + x = 1 + + + elif h[i] - h[i + 1] < 1: + x = 0 + +else: + print('Yes') +" +p03639,s980741100,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +cnt = 0 +cnt4 = 0 +for i in a: + if i%2==1: + cnt+=1 + if i%4==0: + cnt4+=1 + +if n-cnt == cnt4: + if cnt4>=n//2: + print('Yes') + else: + print('No') +elif cnt4>=cnt: + print('Yes') +else: + print('No')" +p02552,s987171507,Wrong Answer,"a = input() +if a==1: + print(0) +else: + print(1)" +p03543,s337286975,Accepted,"import math + +N=input() + +if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]: + print('Yes') +else: + print('No')" +p03544,s373333515,Accepted,"N = int(input()) +L = [2, 1] +for i in range(N): + L.append(L[-2] + L[-1]) +print(L[N]) +" +p02708,s322368730,Accepted,"n,k = map(int,input().split()) +n += 1 +p = 0 +for i in range(k,n+1): + p += i * (n - i)+1 + p %= 1000000007 +print(p)" +p02766,s268825939,Wrong Answer,"n,k =list(map(int,input().split())) +A=1 + +while True: + n =n//k + A+=1 + if n//k<1: + break +print(A)" +p02765,s942213076,Accepted,"# -*- coding: utf-8 -*- +N, R = map(int, input().split()) + +print(100 * (10 - N) + R if N < 10 else R)" +p02775,s133439633,Accepted,"L = list(map(int,list(input()))) +L = [0] + L +N = len(L) +dp1 = [0 for _ in range(N+1)] +dp2 = [0 for _ in range(N+1)] + +for i in range(N): + dp1[i+1] = min(dp1[i] + L[i], dp2[i] + 10 - L[i]) + dp2[i+1] = min(dp2[i] + 10 - L[i] - 1, dp1[i] + L[i] + 1) + +print(dp1[-1])" +p03605,s536674424,Accepted,"N=list(input()) +if N[0]=='9' or N[1]=='9': + print('Yes') +else: + print('No') +" +p03524,s873830519,Accepted,"s = list(map(str,input())) +a,b,c = 0,0,0 + +for i in range(len(s)): + if s[i] == ""a"": + a += 1 + elif s[i] == ""b"": + b += 1 + else: + c += 1 + +if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1: + print(""YES"") +else: + print(""NO"")" +p02718,s812078247,Accepted,"N, M = map(int, input().split()) +ITEMS = list(map(int, input().split())) +MAX = sum(ITEMS) +def solve(): + count = 0 + for item in reversed(list(sorted(ITEMS))): + if item >= MAX * (1 / (4 * M)): + count += 1 + if count >= M: + print(""Yes"") + return + + print(""No"") + +solve()" +p02621,s988115724,Accepted,"#!/usr/bin/env python3 +a = int(input()) +print(a + a ** 2 + a ** 3)" +p02842,s963801878,Accepted,"N = int(input()) +for i in range(int(N * 0.9), N + 1): + if int(i * 1.08) == N: + print(i) + break +else: + print(':(') +" +p02613,s601485174,Accepted,"n = int(input()) + +c0 = 0 +c1 = 0 +c2 = 0 +c3 = 0 + +for i in range(n): + s = input() + if s == ""AC"": + c0 += 1 + elif s == ""WA"": + c1 += 1 + elif s == ""TLE"": + c2 += 1 + elif s == ""RE"": + c3 += 1 +print(""AC x {}"".format(c0)) +print(""WA x {}"".format(c1)) +print(""TLE x {}"".format(c2)) +print(""RE x {}"".format(c3))" +p03030,s144373553,Accepted,"n = int(input()) +d = {tuple(map(str, input().split())):i for i in range(1,n+1)} +sort_d = sorted(d.items(), key=lambda x:(x[0][0],-int(x[0][1]))) #点数に-で降順でマイナス順になる +r = [] +for i in sort_d: + print(i[1])" +p02924,s174930583,Wrong Answer,"n=int(input()) +print(int((n*(n-1))/2))" +p02641,s211675496,Wrong Answer,"x, n = map(int, input().split()) +if n ==0: + print(x) +else: + p = list(map(int, input().split())) + q = list(range(101)) + a = x + for i in range(x, 0, -1): + if p.count(i) == 0: + a = i + break + + b = x + for i in range(x, 101): + if p.count(i) == 0: + b = i + break + + if abs(x-a) > abs(x-b): + print(b) + else: + print(a) +" +p02797,s487771302,Wrong Answer,"N, K, S = map(int, input().split()) +A = [] +for i in range(K): + A.append(S) +for i in range(K, N): + A.append(S+2) +print(*A)" +p02608,s139400952,Accepted,"from collections import defaultdict +d = defaultdict(int) +for i in range(1,101): + for j in range(1,101): + for k in range(1,101): + a = i**2+j**2+k**2+i*k+k*j+j*i + d[a] += 1 + +n = int(input()) +for i in range(1,n+1): + print(d[i])" +p03062,s170231950,Accepted,"N = int(input()) +A = [int(_) for _ in input().split()] + +cnt = 0 +for i in range(N): + if A[i] < 0: + cnt += 1 + A[i] *= -1 + +if cnt % 2 == 0: + print(sum(A)) +else: + print(sum(A) - min(A) * 2) +" +p03160,s443489082,Wrong Answer,"INF = 10 ** 4 + 10 + +n = int(input()) +H = list(map(int, input().split())) +DP = [INF] * n +DP[0] = 0 +DP[1] = abs(H[1] - H[0]) +for i in range(2, n): + DP[i] = min(DP[i], DP[i-1] + abs(H[i] - H[i-1])) + DP[i] = min(DP[i], DP[i-2] + abs(H[i] - H[i-2])) +print(DP[-1])" +p02873,s035273947,Accepted,"S = input() +a = [0 for i in range(len(S)+1)] +for i, x in enumerate(S): + if x == '<': + a[i+1] = max(a[i+1], a[i]+1) +for i in range(len(S)): + if S[-i-1] == '>': + a[-i-2] = max(a[-i-2], a[-i-1]+1) +print(sum(a)) " +p02946,s393023248,Wrong Answer,"K,X=map(int,input().split()) +ans=list(range(X-(K-1),X+K)) +print(ans) +" +p02718,s996511736,Accepted,"n, m = [int(x) for x in input().split()] + +xs = [] +for i in input().split(): + xs.append(int(i)) + +bound = 1/4/m * sum(xs) + +count = 0 +for x in xs: + if x >= bound: + count += 1 + +print('Yes') if count >= m else print('No') +" +p02963,s654916142,Accepted,"import sys +# sys.setrecursionlimit(100000) + + +def input(): + return sys.stdin.readline().strip() + + +def input_int(): + return int(input()) + + +def input_int_list(): + return [int(i) for i in input().split()] + + +def main(): + S = input_int() + x0 = y0 = 0 + x1 = 1 + x2 = 10**9 + y2 = -S % 10**9 + y1 = (S + y2) // 10**9 + + print(x0, y0, x1, y1, x2, y2) + return + + +if __name__ == ""__main__"": + main() +" +p02848,s908243063,Accepted,"letters = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') +L = len(letters) + +n = int(input()) +word = input() +result = '' + +for letter in word: + idx = letters.index(letter) + f_idx = (idx + n) % L + result += letters[f_idx] + +print(result)" +p03380,s479294396,Wrong Answer,"import sys +input = sys.stdin.readline + +n = int(input()) +a = [int(x) for x in input().split()] +a.sort() + +ans = [-1, 0, 0] + +import bisect + +i = a[-1] +idx = [bisect.bisect_left(a, i // 2), bisect.bisect_left(a, i // 2) - 1] + +if abs(i // 2 - a[idx[0]]) < abs(i // 2 - a[idx[1]]): + print(i, a[idx[0]]) +else: + print(i, a[idx[1]]) +" +p03069,s403896604,Wrong Answer,"import sys + +input = sys.stdin.readline + + +def main(): + N = int(input()) + S = input().rstrip() + + ans = 0 + for i in range(N): + if S[i] == ""#"": + ans = S[i + 1:].count(""."") + break + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03759,s163275408,Accepted,"x,y,z = map(int,input().split()) +if (y-x)==(z-y): + print(""YES"") +else: + print(""NO"") +" +p03785,s864188383,Accepted,"N, C, K = list(map(int, input().split())) +T = [int(input()) for _ in range(N)] +T.sort() +i = 0 +res = 0 +while i < N: + j = 0 + while i < N and j < C and T[i] - T[i - j] <= K: + i += 1 + j += 1 + res += 1 +print(res) +" +p03971,s050693553,Accepted,"N,A,B = map(int,input().split()) +S = input() +pas = 0 +num = A + B +kaigai = 0 +for i in range(len(S)): + if S[i] == ""a"": + if pas < num: + pas += 1 + print(""Yes"") + else: + print(""No"") + elif S[i] == ""b"": + kaigai += 1 + if pas < num and kaigai <= B: + pas += 1 + print(""Yes"") + else: + print(""No"") + else: + print(""No"") + +" +p02959,s511073756,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +count = 0 +for i in range(n): + count += min(a[i], b[i]) + b[i] = max(b[i]-a[i], 0) + + count += min(a[i+1], b[i]) + b[i] = max(b[i] - a[i+1], 0) + a[i+1] = max(a[i+1] - b[i], 0) + +print(count) +" +p02879,s172541327,Accepted,"# ABC144A + +a, b = map(int, input().split()) + +print(a * b if 1 <= a <= 9 and 1 <= b <= 9 else -1) +" +p03721,s350227542,Accepted,"n, k = map(int, (input().split())) +arr = [0] * 100100 +for i in range(n): + a, b = map(int, input().split()) + arr[a] += b + +cur = 0 +for i in range(100100): + cur += arr[i] + if cur >= k: + print(i) + break" +p02613,s724229042,Accepted,"from collections import Counter +import sys +from collections import defaultdict +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10**8) + + +def geta(fn=lambda s: s.decode()): + return map(fn, readline().split()) + + +def gete(fn=lambda s: s.decode()): + return fn(readline().rstrip()) + + +def main(): + n = gete(int) + s = [] + for _ in range(n): + s.append(gete()) + + c = Counter(s) + + for v in ['AC', 'WA', 'TLE', 'RE']: + print(v, ""x"", c[v]) + + +if __name__ == ""__main__"": + main() +" +p02630,s475532177,Accepted,"import collections +n=int(input()) +l=list(map(int, input().split())) +q=int(input()) +s=sum(l) +d=collections.Counter(l) +for i in range(q): + a,b=map(int, input().split()) + s=s-(a*d[a]) + s=s+(b*d[a]) + d[b]=d[b]+d[a] + d[a]=0 + print(s)" +p03545,s477105753,Accepted,"a= list(str(input())) + + +for i in range(2**3): + x = [""+"",""+"",""+""] + for j in range(len(a)): + if (i >> j) & 1 == 1: + x[j] = ""-"" + if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7: + print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+""=7"") + break +" +p02552,s868067804,Accepted,"x = int(input()) + +if x == 0: + print(1) +elif x == 1: + print(0)" +p03778,s430411619,Accepted,"W, a, b = map(int, input().split()) +if(a > b): + [a,b] = [b,a] + +print(max(b-a-W,0)) +" +p03681,s346661412,Accepted,"n, m = map(int, input().split()) +mod = 10 ** 9 + 7 +if abs(n - m) >= 2: + ans = 0 +elif abs(n - m) == 1: + if m > n: + m, n = n, m + c = 1 + for i in range(1, n): + c *= i + c %= mod + l = (c * n) % mod + ans = c * l % mod +else: + c = 1 + for i in range(1, n + 1): + c *= i + c %= mod + ans = (c * c * 2) % mod +print(ans)" +p03680,s941193963,Accepted,"N = int(input()) +A = [int(input()) for i in range(N)] + +G = [1] +for i in range(N): + G.append(A[G[-1]-1]) + +ans = 0 +ok = False +for i in range(N+1): + if G[i]==2: + ok = True + break + ans += 1 + +if not ok: + ans = -1 + +print(ans)" +p03524,s209012425,Accepted,"s = input() + +a = s.count(""a"") +b = s.count(""b"") +c = s.count(""c"") + +mx = max(a, b, c) +mn = min(a, b, c) + +if mx - mn > 1: + print(""NO"") +else: + print(""YES"")" +p02959,s529366078,Accepted,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +ans = 0 +pre = a[0] +for ai, bi in zip(a[1:], b): + if pre <= bi: + ans += pre + bi -= pre + else: + ans += bi + bi = 0 + pre = ai + if pre <= bi: + ans += pre + pre = 0 + else: + ans += bi + pre -= bi +print(ans) +" +p03607,s184608796,Accepted,"N = int(input()) + +ans = 0 +L = [] +ans_L = {} + +for i in range(N): + L.append(int(input())) + +for j in L: + if not j in ans_L.keys(): + ans_L[j] = 0 + + if ans_L[j]==0: + ans_L[j] += 1 + elif ans_L[j]== 1: + ans_L[j] -= 1 + +print(sum(ans_L.values()))" +p02773,s774158182,Accepted,"n = int(input()) +d = {} + +for _ in range(n): + s = input() + if(s in d):d[s] += 1 + else:d[s] = 1 + +d = sorted(d.items(),key=lambda x:(x[1],x[0]),reverse=True) + +m = d[0][1] +l = [] +for i in range(len(d)): + if(d[i][1] < m):break + l.append(d[i][0]) +l.sort() +for r in l:print(r)" +p03075,s684193483,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) + +if e - a > k: + print("":("") +elif e - b > k: + print("":("") +elif e - c > k: + print("":("") +elif e - d > k: + print("":("") +else: + print(""Yay!"")" +p03860,s348595975,Wrong Answer,"s = input() +print(s[0]+s[8]+s[10])" +p02547,s366068502,Wrong Answer,"import sys + +n = int(input()) +cnt = 0 +for i in range(n): + a,b = map(int,input().split()) + if cnt == 3: + print('Yes') + sys.exit() + if a == b: + cnt += 1 + else: + cnt = 0 +print('No') +" +p02973,s085520696,Wrong Answer,"n = int(input()) +a = [int(input()) for _ in range(n)] +print(a) +ans = 0 +lst = [a[0]]*2 +for aa in a: + if aa <= lst[0]: + lst[0] = aa + ans += 1 + elif lst[0] < aa <= lst[1]: + lst[0] = aa + elif aa > lst[1]: + lst[1] = aa + else: lst[0] = aa +print(ans)" +p02664,s502904668,Accepted,"T = input() +print(''.join(['D' if s=='?' else s for s in T]))" +p02820,s473065485,Accepted,"n, k = map(int, input().split()) +s, p, r = map(int, input().split()) +t = input() + +cnt = 0 +for i in range(k): + f = 0 + pre = """" + for j in range(i, n, k): + if pre != t[j] or f == 1: + cnt += eval(t[j]) + f = 0 + else: + f = 1 + pre = t[j] +print(cnt)" +p03699,s104094139,Wrong Answer,"n=int(input()) +a = [int(input()) for _ in range(n)] +ans=0 +a.sort() +for i in a: + if sum(a)%10 == 0: + a.remove(i) + else: + print(sum(a)) + exit(0) +print(0)" +p02836,s010931704,Accepted,"S = input() +print(len([True for i in range(len(S)//2) if S[i] != S[-1-i]])) +" +p03379,s058435166,Wrong Answer,"n = int(input()) +x = sorted(list(map(int, input().split()))) + +a = x[len(x)//2] +b = x[(len(x)//2) - 1] +for _ in range(len(x)//2): + print(a) +for _ in range(len(x)//2): + print(b) +" +p03360,s008034254,Accepted,"A=[int(i) for i in input().split()] +K=int(input()) +print(max(A)*(2**(K)-1)+sum(A)) +" +p02706,s862940178,Accepted,"import numpy as np + +n, m = map(int, input().split()) + +As = np.asarray(input().split(), dtype=np.int32) + +ans = n - np.sum(As) + +if ans < 0: + print(-1) +else: + print(ans) +" +p03637,s361610740,Wrong Answer,"#coding: utf-8 +import math +import heapq +import bisect +import numpy as np +from collections import Counter +#from scipy.misc import comb + +N = int(input()) +A = list(map(int, input().split())) + +cnt1 = 0 +cnt4 = 0 +for a in A: + if a%4 == 0: + cnt4 += 1 + else: + cnt1 += 1 + +if cnt1 <= cnt4: + print(""Yes"") +else: + print(""No"")" +p02989,s669202704,Accepted,"import sys +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +read = sys.stdin.buffer.read +sys.setrecursionlimit(10 ** 7) + +N = int(input()) +D = list(map(int, input().split())) +D.sort() + +num = N // 2 +arc = 0 +for _ in range(N): + arc_first = D.pop() + arc += 1 + if arc == num: + break +abc_last = D.pop() + +if abc_last == arc_first: + # 同じ数にできない + ans = 0 +else: + ans = arc_first - abc_last + +print(ans)" +p03017,s243391051,Accepted,"import sys + +sys.setrecursionlimit(10 ** 7) +rl = sys.stdin.readline + + +def solve(): + N, A, B, C, D = map(int, rl().split()) + S = input() + + if C < D: + if S[A - 1:D].find('##') == -1: + print('Yes') + else: + print('No') + else: + if S[B - 2:D + 1].find('...') == -1: + print('No') + else: + print('Yes') + + +if __name__ == '__main__': + solve() +" +p02583,s336715355,Accepted,"import itertools +N = int(input()) +nums = map(int, input().split("" "")) +num_comb = list(itertools.combinations(nums, 3)) + +counter = 0 +for _nums in num_comb: + nums = list(_nums) + nums.sort() + n_pure = len(set(nums)) + # print(nums, n_pure) + if (nums[0] + nums[1] > nums[2]) & (n_pure == 3): + counter += 1 + +print(counter) + " +p02717,s775015243,Accepted,"A,B,C = map(int,input().split()) +A,B = B,A + +A,C = C,A +print(A,B,C) +" +p02995,s606817883,Accepted,"import numpy as np +import functools +import math +import collections +import scipy +import fractions +import itertools + +def solve(): + a, b, c, d = map(int, input().split()) + a -= 1 + lc = (c*d)//fractions.gcd(c,d) + ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc) + print(ans) + return 0 + +if __name__ == ""__main__"": + solve()" +p04019,s767223630,Accepted,"import collections + +def main(): + S = list(input()) + Sset = set(S) + if len(Sset) in [1, 3]: + print('No') + elif Sset == set(['S', 'N']) or Sset == set(['W', 'E']): + print('Yes') + elif len(Sset) == 4: + print('Yes') + else: + print('No') + +if __name__ == ""__main__"": + main() +" +p02661,s094700901,Accepted,"from statistics import median + +n = int(input()) +ab = [list(map(int, input().split())) for _ in range(n)] + +a = [ab[i][0] for i in range(n)] +b = [ab[i][1] for i in range(n)] + +if n % 2 == 0: + ma, mb = median(a), median(b) + print(int(2 * mb - 2 * ma + 1)) +if n % 2 == 1: + ma, mb = median(a), median(b) + print(int(mb - ma + 1)) + + +" +p03324,s559593652,Wrong Answer,"D,N = map(int,input().split()) +print(N*100**D)" +p02859,s479869153,Accepted,"r = int(input()) + +print((r**2)//1)" +p03699,s659552917,Accepted,"n = int(input()) +s = [0] * n +for i in range(n): + s[i] = int(input()) +ans = sum(s) +s.sort() +if ans % 10 == 0: + for i in s: + if (ans - i) % 10 != 0: + print(ans-i) + exit() + print(0) +else: + print(ans)" +p03250,s411268211,Wrong Answer,"a, b, c = map(str, input().split()) +max = int(a+b) + int(c) +if max < int(a) + int(b+c): + max = int(a) + int(b+c) + +print(max)" +p03605,s032257122,Accepted,"n = input() +if ""9"" in n: + print(""Yes"") +else: + print(""No"") +" +p03239,s107923180,Accepted,"N,T = map(int,input().split()) +ans = 1001 +ls = [] +for i in range(N): + ls.append(list(map(int,input().split()))) +for i in ls: + if i[1] <= T: + ans = min(ans,i[0]) + else: + continue +if ans == 1001: + print('TLE') +else: + print(ans)" +p03455,s376526564,Accepted,"a, b = map(int, input().split()) +print('Odd' if a & 1 and b & 1 else 'Even')" +p03449,s083267287,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +c = {} +for i in range(n): + c[i] = (a[i] - b[i]) +ans = 0 +for i in range(n): + ans = max(ans,c[i]) +num = 0 +for i in range(n): + if ans == (a[i]-b[i]): + num = i +ch = 0 +#print(""num"",num) +for i in range(n): + if i <= num: + ch += a[i] + else: + ch += b[i] +print(ch+b[num])" +p02731,s144065847,Wrong Answer,"import sys +L=int(input()) + +length=int(L/3) +L=L-length +width=int(L/2) +L=L-width +height=L +print(length*width*height) +" +p02747,s906896901,Wrong Answer,"s = input() +r = 'Yes' +for i in range(0, len(s) - 1, 2): + if s[i] != 'h' or s[i + 1] != 'i': + r = 'No' + break +print(r)" +p03075,s349364340,Accepted,"import sys + +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) + +Ant = [a, b, c, d, e] + +for i in range(4): + for j in range(i, 5): + if abs(Ant[j]-Ant[i]) > k: + print("":("") + sys.exit() + +print(""Yay!"")" +p02916,s303755296,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) +C = list(map(int,input().split())) + +ans = sum(B) +for i in range(len(A)-1): + if A[i] + 1 == A[i+1]: + ans += C[A[i]-1] + +print(ans)" +p02917,s430038271,Accepted,"a=input() +b=input().split() +sum=int(b[0]) + +for i in range(len(b)-1) : + sum+=min(int(b[i]),int(b[i+1])) +sum+=int(b[-1]) + +print(sum)" +p02832,s494381312,Accepted,"n = int(input()) +A = list(map(int, input().split())) + +c = 1 +for a in A: + c += a == c +print(n-c+1 if c > 1 else -1)" +p03137,s672848656,Accepted,"import sys +input=sys.stdin.readline + +n,m=map(int,input().split()) +if n>=m: + print(0) + exit() + +lst=sorted(map(int,input().split())) +sa=[] +for i in range(m-1): + sa.append(lst[i+1]-lst[i]) +sa=sorted(sa) +print(sum(sa[:m-n]))" +p02572,s207987826,Accepted,"N = int(input()) +A = [int(s) for s in input().split()] +mod = 10**9+7 + +wa = 0 +wa_list = [] +for i in range(N)[::-1]: + if i == 0: + break + wa += A[i] + wa_list.append(wa) + +wa_list.reverse() +ans = 0 +for i in range(N-1): + seki = A[i]*wa_list[i] + ans += seki + +print(ans % mod)" +p03852,s482236578,Accepted,"v=['a','i','u','e','o'];print('vowel' if 0!=v.count(input()) else 'consonant')" +p03962,s812232865,Accepted,"a, b, c = map(int, input().split()) +ans = 3 +if a == b or b == c or c == a: + ans -= 1 +if a == b == c: + ans -= 1 +print(ans)" +p03329,s965532722,Accepted,"N = int(input()) +ans = 100000 +for A in range(N+1): + num = 0 + B = N-A + while A != 0: + num += A % 6 + A = A//6 + while B != 0: + num += B % 9 + B = B//9 + ans = min(ans,num) +print(ans)" +p02640,s913343255,Wrong Answer,"x, y = map(int, input().split()) +if (y-2*x) % 2 == 0 and 0 <= y-2*x <= x: + print('Yes') +else: + print('No') +" +p02916,s730939680,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) +C=list(map(int,input().split())) + + +ans=0 +for i in range(N): + ans+=B[A[i]-1] + if(i>=1): + if(A[i]==A[i-1]+1): + ans+=C[i-1] + +print(ans) + +" +p03086,s586464292,Wrong Answer,"s = input() + +mx = 0 +n = len(s) +kensa = [""A"", ""C"", ""G"", ""T""] + +for i in range(n): + for j in range(i,n-1): + mj = s[i:j+1] + bl = True + for l in range(len(mj)): + if mj[l] not in kensa: + bl = False + break + if bl & mx= 2*c: + ans = c//2 +else: + ans = S + c -= 2*S + ans += c//4 +print(ans) +" +p02795,s970681953,Accepted,"#import math +#import collections +#n,k = map(int, input().split( )) +#A = list(map(int, input().split( ))) +h = int(input()) +w = int(input()) +N = int(input()) + +m = max(h,w) +d = N//m +if N%m == 0: + print(d) +else: + print(d+1)" +p03274,s048352594,Accepted,"n, k = map(int, input().split()) +x = list(map(int, input().split())) +l = 0 + +ans = 10 ** 18 +for r in range(k-1, len(x)): + ans = min(ans, abs(x[l]) + abs(x[r] - x[l])) + ans = min(ans, abs(x[r]) + abs(x[r] - x[l])) + l += 1 +print(ans) +" +p02900,s888213767,Wrong Answer,"from fractions import gcd + +a,b = map(int,input().split()) +n = gcd(a,b) +ans = 1 +for i in range(2,n): + if n%i == 0: + ans += 1 + while n%i == 0: + n = n//i + if n == 1: + break +print(ans)" +p02577,s461050119,Accepted,"N=input() + +num=0 +for i in N: + num+=int(i) + +if num%9==0: + print(""Yes"") +else: + print(""No"")" +p03387,s599661486,Accepted,"a,b,c=sorted(map(int,input().split())) +count=0 +A,B=(c-a)//2,(c-b)//2 +a+=A*2 +b+=B*2 +count+=A+B +if a==b==c: + print(count) +elif a==b: + print(count+1) +else: + print(count+2)" +p02744,s598577595,Wrong Answer,"N=input() +A=""abcdefghij"" + +S=[""a""] +for n in range(2,N+1): + temp=[] + for s in S: + for i in range(n): + if i==n-1: + if s[-1]==A[i-1]: + temp.append(s+A[i]) + else: + temp.append(s+A[i]) + S=temp + +S.sort() +for x in S: + print x +" +p04043,s872676909,Accepted,"lima = 0 +tujuh = 0 +a = [int(tmp) for tmp in input().split()] +for i in range(3) : + if a[i] == 5 : + lima += 1 + elif a[i] == 7 : + tujuh += 1 +if lima==2 and tujuh == 1 : + print(""YES"") +else : + print('NO')" +p02811,s821902980,Accepted,"k, x = map(int, input().split()) + +if x <= (k * 500): + print('Yes') +else: + print('No')" +p02700,s062920673,Wrong Answer,"input_line = input().split() +A = int(input_line[0]) +B = int(input_line[1]) +C = int(input_line[2]) +D = int(input_line[3]) + +X = A//D +Y = C//B +if X > Y: + print('Yes') + +elif Y > X: + print('No') + +elif X ==Y: + print('Yes')" +p04012,s110985108,Wrong Answer,"import sys +s = input() +n = len(s) + +if n %2 != 0: + print('No') + sys.exit() +for i in range(26): + if s.count(chr(i)) %2 != 0: + print('No') + sys.exit() +print('Yes')" +p02785,s889605854,Accepted,"import numpy as np +n, k = [int(i) for i in input().split()] +h = np.array(sorted([int(i) for i in input().split()], reverse=True)) +print(sum(h[k:]))" +p02993,s610661180,Wrong Answer,"n = input() +print('Yes' if n[0] != n[1] and n[1] != n[2] and n[2] != n[3] else 'No')" +p02933,s637970157,Wrong Answer,"a = int(input()) +s = input() +if a > 3200: + print (s) +else: + print(""red"")" +p03565,s481606616,Accepted,"s = input() +t = input() + +def match(k): + flag = True + for i in range(len(t)): + if s[i + k] != t[i] and s[i + k] != ""?"": + flag = False + break + return flag + +flag = False +for k in reversed(range(len(s) - len(t) + 1)): + if match(k): + s = s[:k] + t + s[k + len(t):] + flag = True + break + +if flag: + print(s.replace('?', 'a')) +else: + print('UNRESTORABLE')" +p03544,s002100528,Accepted,"n = int(input()) +lst = [2, 1] +for i in range(90): + lst.append(lst[-1] + lst[-2]) +print(lst[n])" +p03773,s752600263,Wrong Answer,"A, B = map(int, input().split()) +if A + B > 24: + print((A + B) - 24) +else: + print(A + B)" +p02597,s905122891,Accepted,"N = int(input()) +c_str = input() +R_cnt = c_str.count('R') +tmp_cnt = c_str[:R_cnt].count('R') +print(R_cnt - tmp_cnt)" +p02725,s322936580,Accepted,"k,n=map(int,input().split()) +a=list(map(int,input().split())) +lenmax=k-a[n-1]+a[0] +for i in range(n-1): + if(lenmax<-1*(a[i]-a[i+1])): + lenmax=-1*(a[i]-a[i+1]) +print(k-lenmax)" +p03639,s203744420,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) + +four = 0 +odd = 0 + +for a in A: + if a % 4 == 0: + four += 1 + elif a % 2 == 1: + odd += 1 + +if odd == 0: + print('Yes') +else: + if four + odd == n: + print('Yes' if four > n // 2 else 'No') + else: + print('Yes' if four >= (four + odd + 1) // 2 else 'No') +" +p02647,s225139897,Accepted,"import sys +import numpy as np +from numba import jit +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N, K, *A = map(int, read().split()) + +@jit +def imos(A): + B = np.zeros_like(A) + for i,x in enumerate(A): + a = max(0,i-x) + b = min(N-1,i+x) + B[a] += 1 + if b+1 <= N-1: + B[b+1] -= 1 + B = np.cumsum(B) + return B + +for i in range(K): + if i >= 50: + break + A = imos(A) +print(*A)" +p02732,s587394379,Accepted,"from collections import defaultdict, Counter + +N = int(input()) +A = list(map(int, input().split())) + +#要素数の確認 +C = Counter(A) + +# 総パターンは普遍 +k = 0 +for i,j in C.items(): + if j == 1: + k += 0 + else: + k += j*(j-1)//2 +# 自分の数字のパターンがへる +# delta = j(j-1)/2 - (j-1)(j-2)/2 = j - 1 +d = defaultdict(int) +for i,j in C.items(): + if j == 1: + d[i] = 0 + else: + d[i] = j-1 + +for i in A: + print(k-d[i])" +p02791,s179629791,Accepted,"n=int(input()) +p=list(map(int,input().split())) + +minl=[0 for _ in range(n)] + +for i in range(n): + if i==0: + minl[0]=p[0] + else: + minl[i]=min(minl[i-1],p[i]) +ans=sum([p[i]==minl[i] for i in range(n)]) +print(ans)" +p02546,s230848545,Accepted,"s = input() +l = len(s) +if s[l-1] == ""s"": + print(s + ""es"") +else: + print(s + ""s"")" +p03035,s252283504,Accepted,"A,B=map(int,input().split()) +if 12>=A>=6: + print(B//2) +elif 5>=A: + print(0) +else: + print(B) +" +p02712,s260796355,Accepted,"n=int(input()) +ans=0 +for i in range(1,n+1): + if(i%3!=0 and i%5!=0): + ans+=i + + +print(ans)" +p02661,s844918771,Accepted,"N = int(input()) +A = [0]*N +B = [0]*N +for i in range(N): + s,t = map(int,input().split()) + A[i] = s + B[i] = t +A.sort() +B.sort() +if N%2 == 1: + a = A[(N-1)//2] + b = B[(N-1)//2] + print(b-a+1) +if N%2 == 0: + a = A[N//2 - 1] + A[N//2] + b = B[N//2 - 1] + B[N//2] + print(b-a+1)" +p03773,s853364502,Accepted,"a,b=map(int,input().split()) + +if a+b<=23: + print(a+b) +else: + print(a+b-24)" +p04030,s967883507,Accepted,"input_line = list(input()) +t = [] +for i in input_line: + if i == ""0"": + t.append(""0"") + elif i == ""1"": + t.append(""1"") + else: + if t == []: + t == [] + else: + t.pop(-1) +print("""".join(t))" +p02880,s488062155,Accepted,"n=int(input()) +ans=""No"" +for i in range(1,10): + for j in range(1,10): + if n==i*j: + ans=""Yes"" + break +print(ans)" +p03416,s600534828,Accepted,"A, B = map(int, input().split()) +print(len([1 for i in range(A,B+1) if str(i)[0:]==str(i)[::-1]]))" +p02897,s562502434,Wrong Answer,"n = int(input()) + +odd = n +if n%2==0: + odd = n//2 +elif n%2==1: + odd = n//2 + 1 + +ans = odd / n +print(odd)" +p03329,s519868659,Wrong Answer,"import math + +n = int(input()) + +dp = [10**18] * (100000 + 10) +dp[0] = 0 + +for i in range(1, n+1): + dp[i] = dp[i-1] + 1 + +for i in range(n-1): + s = n-i + for j in range(int(math.log(s, 9)+1)): + dp[i+9**j] = min(dp[i+9**j], dp[i]+1) + for k in range(int(math.log(s, 6)+1)): + dp[i+6**k] = min(dp[i+6**k], dp[i]+1) + + +print(dp[n])" +p02842,s920528976,Accepted,"# B - Tax Rate + +N = int(input()) + +for i in range(1, 50001): + if int(i * 1.08) == N: + print(i) + break +else: + print(':(') +" +p02717,s203269072,Wrong Answer,"X, Y, Z = map(int, input().split()) +print(Z, Y, X)" +p02597,s846191597,Accepted,"import heapq +N = int(input()) +c = input() + +w = [i for i in range(N) if c[i]=='W'] +r = [-i for i in range(N) if c[i]=='R'] +heapq.heapify(w) +heapq.heapify(r) +ans = 0 +for i in range(N): + if w and r: + a = heapq.heappop(w) + b = -heapq.heappop(r) + if a-b==1: + break + else: + heapq.heappush(w,b) + heapq.heappush(r,-a) + ans += 1 +print(ans)" +p03495,s143854609,Wrong Answer,"from collections import Counter + +N,K = map(int,input().split()) +A = list(map(int,input().split())) +cnt = len(set(A)) - K +d = Counter(A) +l = sorted(d.keys(),reverse=True) +res = 0 +for i in range(cnt): + res += d[l[i]] +print(res) +" +p02882,s759993729,Accepted,"import math as m + + +a, b, x = map(int, input().split()) + +if x == b * a**2: + print(0) + +elif x >= b * a**2 / 2: + y = 2 * (b - x / (a**2)) + print(90 - m.atan(a / y) * 180 / m.pi) +else: + y = 2 * x / (a * b) + print(90 - m.atan(y / b) * 180 / m.pi)" +p03761,s757277166,Accepted,"n = (int)(input()) +alp = [10000 for i in range(0 , 90)] # initialize to infinity +for i in range(0 , n): + s = input() + now = [0 for i in range(29)] + for i in s: + now[ord(i)-ord('a')]+=1 # counting letters + for i in range(0 ,27): + alp[i]=min(alp[i], now[i])# consider minimum frequency of every letter occuring in the string +res = """" +for i in range(0 , 26): + if alp[i]>=1: + res = res+"""".join(([(chr(i+ord('a')))]*alp[i])) # very complex +print(res)" +p02796,s857624120,Accepted,"from operator import itemgetter + +n = int(input()) +XLs = [list(map(int, input().split())) for i in range(n)] + +for i in range(n): + x = XLs[i][0] + l = XLs[i][1] + XLs[i].append(x+l) + +#右手の端の位置でソート +XLs.sort(key=itemgetter(2)) + +choice = -10**10 +cnt = 0 +for i in range(n): + x = XLs[i][0] + l = XLs[i][1] + + if choice <= x-l: + choice = x+l + cnt += 1 + +print(cnt)" +p02687,s968143782,Wrong Answer,"s = input() +if s is ""ABC"": print(""ARC"") +else: print(""ABC"") +" +p02765,s128032276,Accepted,"k,r = map(int,input().split()) +if k>=10: + print(r) +else: + print(r+100*(10-k))" +p03994,s875725177,Accepted,"sl = list(input()) +k = int(input()) + +for i in range(len(sl)): + ord_s = ord(sl[i]) + use = 123 - ord_s + if k - use >= 0 and sl[i] != ""a"": + sl[i] = ""a"" + k -= use + +if k > 0: + sl[-1] = chr((ord(sl[-1]) + k - 97) % 26 + 97) + +print("""".join(sl)) + +" +p03607,s507385887,Accepted,"import sys +from collections import Counter +input = sys.stdin.readline +N = int(input()) +A = [int(input()) for _ in range(N)] +c = Counter(A) +print(sum(map(lambda x: x % 2, c.values())))" +p03544,s033130808,Wrong Answer,"if __name__ == '__main__': + + n = int(input()) + + A = [2,1] + if n == 1: + print(A[1]) + else: + for i in range(2,n+1): + A.append(A[i-2] + A[i-1]) + print(A[n])" +p02952,s822673629,Accepted,"n=int(input()) +if n<10: + print(n) +if 10<=n<100: + print(9) +elif 100 <= n < 1000: + print(n-90) +elif 1000 <= n < 10000: + print(909) +elif 10000 <= n < 100000: + print(n-9090) +elif n==100000: + print(90909)" +p02916,s736590769,Accepted,"n = input() +N = int(n) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +c = list(map(int,input().split())) + +i=0 +man=0 +oldA=1 +for A in a: + #print(A) + B = b[int(A)-1] + #print(B) + man = man + int(B) + if i>0: + if oldA+1==A: + C = int(c[oldA-1]) + man = man + C + #print(C) + i=i+1 + oldA=A +print(man)" +p03681,s894670302,Accepted,"N = 10**6 +mod = 10**9 + 7 +fact = [1] +for i in range(1, N+1): + fact.append(fact[-1]*i%mod) + +n,m = map(int, input().split()) + +if n-m > 1 or m-n >1: + ans=0 +elif n-m == 0: + ans = 2*fact[n]*fact[m]%mod +else: + ans = fact[n] * fact[m] % mod +print(ans) +" +p03211,s129428129,Accepted,"s = [int(c) for c in list(input())] +num = 753 +ans = num +for i in range(len(s) - 2): + x = s[i] * 10 ** 2 + s[i + 1] * 10 + s[i + 2] + ans = min(ans, abs(num - x)) +print(ans)" +p02676,s274628472,Accepted,"import sys +sys.setrecursionlimit(700000) + +def s_in(): + return input() + +def n_in(): + return int(input()) + +def l_in(): + return list(map(int, input().split())) + +k=n_in() +s=s_in() + +if len(s) <= k: + print(s) +else: + print(s[:k]+""..."") + +" +p03077,s970831934,Accepted,"from math import ceil + +N, *ABCDE = map(int, open(0).read().split()) +bottle_neck = min(ABCDE) +print(ceil(N / bottle_neck) + 4)" +p03262,s965888382,Accepted,"N, X = map(int,input().split()) +ls = list(map(int,input().split())) + +ls_x = [abs(l - X) for l in ls] + +import fractions + +ans = ls_x[0] +for i in range(1, N): + ans = fractions.gcd(ans, ls_x[i]) +print(ans)" +p03565,s358331588,Accepted,"def check(a, b): + for i in range(len(a)): + if not(a[i] == b[i] or a[i] == '?'): + return False + return True + + +s_prime = input() +t = input() +ans_list = [] +for i in range(len(s_prime) - len(t) + 1): + if check(s_prime[i:i+len(t)], t): + s = s_prime[:i] + t + s_prime[i+len(t):] + ans = s.replace('?', 'a') + ans_list.append(ans) +ans_list.sort() +if not ans_list: + print('UNRESTORABLE') +else: + print(ans_list[0])" +p02642,s215716427,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = set() +cnt = 0 +for i in range(N-1): + for j in range(N-1): + if A[j] % A[i] == 0 and i != j: + B.add(A[j]) +for i in range(N-1): + if A[j] == A[i] and i != j: + cnt += 1 + +print(N-cnt-len(B)-1)" +p02618,s137039434,Accepted,"import sys +#sys.setrecursionlimit(10**6) +input=sys.stdin.readline +from random import randint +d=int(input().rstrip()) +c=[int(i)for i in input().split()] +s=[[int(i)for i in input().split()]for _ in range(d)] +last=[0]*26 +for i in range(d): + print((i+4)%26+1)" +p03345,s555243278,Wrong Answer,"A, B, C, K = map(int, input().split()) +if K == 0: + print(A - B) +elif K == 1: + print(B - A) +else: + print(0) +" +p02995,s059029108,Wrong Answer,"from math import * +a,b,c,d = map(int,input().split()) +f =(c*d)//gcd(c,d) +r = f +rock = 2 +compteur= b//f +div1 = ((b//c)-(a//c)) +div2 = ((b//d)-(a//d)) +if a%c == 0: + div1+=1 +if a%d ==0: + div2 +=1 +roger =(div1+div2)-compteur +mm = (b-a)+1 +print(mm-roger) +" +p02727,s421045273,Accepted,"x,y,a,b,c=map(int,input().split()) +p=list(map(int,input().split())) +q=list(map(int,input().split())) +r=list(map(int,input().split())) + +p.sort() +q.sort() +r.sort(reverse=True) +del p[:a-x] +del q[:b-y] + +s=p+q +s.sort() +if s[0]=r[i]: + break + else: + s[i]=r[i] + +print(sum(s))" +p03773,s745542088,Accepted,"A, B =map(int, input().split()) +print((A+B)%24)" +p02743,s940594243,Wrong Answer,"a, b, c = map(int,input().split()) +R, L = 10**9, 0 +mod = 10**9+7 +while L < R: + if (a*b)%mod < (((R+L)//2)**2)%mod: + R = (R+L)//2 - 1 + else: + L = (R+L)//2 +if a==b: + if 4*a < c: + print(""Yes"") + else: + print(""No"") +else: + if a+b+2*R+1<= c: + print(""Yes"") + else: + print(""No"")" +p02996,s858472018,Accepted,"import numpy as np +# 締切が早いものから処理 +N = int(input()) +AB = np.array([[int(x) for x in input().split()] for _ in range(N)]) +A = AB[:,0] +B = AB[:,1] +idx = B.argsort() +A = A[idx] +B = B[idx] +np.cumsum(A, out = A) +bl = (A <= B).all() +answer = 'Yes' if bl else 'No' +print(answer) +" +p03474,s895659403,Wrong Answer,"import sys +a,b = map(int,input().split()) +s = list(input()) +print(s) +if s[a] != ""-"": + print(""No"") + sys.exit() +s[s.index(""-"")] = ""1"" +for i in range(len(s)): + if s[i].isdigit(): + if int(s[i]) >= 6 or int(s[i]) <= 0: + print(""No"") + sys.exit() + else: + print(""No"") + sys.exit() +print(""Yes"")" +p02628,s612636818,Accepted,"n, k = map(int, input().split()) +ps = list(map(int, input().split())) + +ps = sorted(ps) + +print(sum(ps[:k])) + +" +p02743,s672090608,Wrong Answer,"import math as mt +a, b, c = map(int, input().split()) +if a**2 + b**2 + 2*mt.sqrt(a*b) < c**2: + print(""Yes"") +else: + print(""No"") +" +p02660,s145887075,Accepted,"def II(): return int(input()) +N=II() +d=2 +ans=0 +while d*d<=N: + if N%d!=0: + d+=1 + continue + z=d + while N%z==0: + ans+=1 + N//=z + z*=d + while N%d==0: + N//=d +if N!=1: + ans+=1 +print(ans)" +p03352,s219369629,Wrong Answer,"x = int(input()) +ans = 1 +for i in range(1,x//2): + for j in range(2,10): + if i ** j <= x: + ans = i**j +print(ans)" +p03815,s789297451,Accepted,"x = int(input()) + +ans = 2 * (x // 11) + +if x % 11 == 0: + pass +elif x % 11 < 7: + ans += 1 +else: + ans += 2 +print(ans)" +p03150,s686621456,Accepted,"s = input() +k = 'keyence' +res = 'NO' +if s[:len(k)]==k or s[len(s)-len(k):]==k: + res = 'YES' +else: + for i in range(len(k)+1): + if s[:i]+s[len(s)-len(k)+i:] == k: + res = 'YES' + break +print(res)" +p03239,s598687606,Accepted,"a, b = map(int, input().split()) +menor_t, menor_c = 1000, 1000 +index = 0 +for i in range(a): + c, t = map(int, input().split()) + if t <= b: + if c < menor_c: + menor_c = c + index = i + 1 +if index == 0: + print('TLE') +else: + print(menor_c)" +p02848,s539338958,Accepted,"# ASCII A-Z 65-90 +N = int(input()) +S = list(input()) +out = '' +for i in S: + if ord(i) + N > 90: + out += chr(ord(i) + N - 26) + else: + out += chr(ord(i) + N) +print(out)" +p03557,s676326859,Accepted,"from bisect import bisect_left, bisect_right +n=int(input()) +a=sorted(map(int,input().split())) +b=sorted(map(int,input().split())) +c=sorted(map(int,input().split())) + +ans=0 +for i in range(n): + s=b[i] + upper=bisect_left(a,s) + lower=n-bisect_right(c,s) + ans+=(upper*lower) + +print(ans)" +p02647,s931997352,Wrong Answer,"stdin = [input() for i in range(2)] +line = stdin[0].split(' ') +N = int(line[0]) +K = int(line[1]) +line = stdin[1].split(' ') +Ai = [0]*N +for i in range(len(line)): + Ai[i] = int(line[i]) + +for i in range(K): + Bi = [1]*N + for i, d in enumerate(Ai): + for j in range(1,d+1): + if i-j >=0: + Bi[i-j] +=1 + if i+j =2019: + minimum=0 +else: + left,right=L%2019,R%2019 + minimum=2018**2 + for i in range(left,right+1): + for j in range(i+1,right+1): + minimum=min(minimum,i*j%2019) +print(minimum)" +p02819,s032299242,Accepted,"X = int(input()) + +if X == 2: + print(2) + exit() + +prime = [2] +k = 3 +while True: + isPrime = True + maxK = int(k ** 0.5) + 1 + for p in prime: + if p >= maxK: + break + isPrime &= (k % p != 0) + if isPrime: + prime.append(k) + if k >= X: + break + k += 2 +print(prime[-1]) +" +p03433,s841315615,Accepted,"N=int(input()) +A=int(input()) +amari=N%500 +if A>=amari: + print(""Yes"") +else: + print(""No"")" +p03524,s489617268,Accepted,"s = input() + +a_cnt = 0 +b_cnt = 0 +c_cnt = 0 +for i in range(len(s)): + if s[i] == 'a': + a_cnt += 1 + elif s[i] == 'b': + b_cnt += 1 + else: + c_cnt += 1 + +abc_max = max(a_cnt, b_cnt, c_cnt) +abc_min = min(a_cnt, b_cnt, c_cnt) + +if abc_max < abc_min + 2: + print('YES') +else: + print('NO')" +p02882,s568006360,Accepted,"import math +a, b, x = map(int, input().split()) + +if x/a >= (a*b)/2: + ans = math.degrees(math.atan((2/a)*(b-(x/a**2)))) +else: + ans = math.degrees(math.atan((a*b*b)/(2*x))) +print('{:.10f}'.format(ans))" +p02742,s225806992,Accepted,"H, W = map(int, input().split()) + +if min(H,W) == 1: + print(1) +else: + print(-(-H*W//2))" +p03804,s718888709,Wrong Answer,"N,M=list(map(int,input().split())) +l=[list(input()) for i in range(N)] +mini=[list(input()) for i in range(M)] +mini="""".join(sum(mini,[])) +for i in range(N-M+1): + for j in range(N-M+1): + let="""" + for k in range(i,M+i): + let+="""".join(l[k][j:j+M]) + if mini == let: + print(""Yes"") + exit() +print(""No"")" +p03971,s848615861,Accepted,"n,a,b=map(int,input().split()) +ac=0 +bc=0 +for i in input(): + if i=='a': + if ac+bc= 0: + print(count) +else: + print(0)" +p02847,s450195347,Wrong Answer,"s = input() +week = [""MON"", ""TUE"", ""WED"", ""THU"", ""FRI"", ""SAT"", ""SUN""] +for i in range(7): + if s == week[i]: + print(6-i) +" +p03665,s979405483,Accepted,"import collections +n, p = list(map(int, input().split())) +a = list(map(int, input().split())) +a2 = [ai%2 for ai in a] +a2 = collections.Counter(a2) + +if a2[1] == 0: + print(2 ** n if p == 0 else 0) +else: + print( 2 ** (n-1)) + +" +p02712,s814119320,Wrong Answer,"N = int(input()) +count = 0 +for x in range(1, N+1): + if x%3==0 or x%5==0: + count=count+x +print(count)" +p02879,s613304632,Accepted,"A,B = map(int,input().split()) +print(A*B if (A<10 and B<10) else -1)" +p02582,s842638791,Wrong Answer," +s=input() +flg = 0 +cnt = 0 +if s[1] == ""S"": + flg = 1 +for i in range(3): + if s[i] == ""S"": + cnt += 1 +print(cnt if flg == 1 else cnt -1)" +p02595,s250155356,Accepted,"from math import sqrt +n, d = map(int, input().split()) +c = 0 +for i in range (n): + m,p = map(int, input().split()) + c += sqrt(m**2 + p**2) <= d +print(c)" +p02615,s359341663,Accepted,"N = int(input()) +A = map(int, input().split()) + +sortA = sorted(A) + +result = 0 +for i in range(1, N): + result += sortA[N - (i // 2) - 1] + +print(result)" +p02946,s949015078,Accepted,"K, X = map(int, input().split()) + +min_x = max(X-(K-1), -1000000) +max_x = min(X+(K-1), 1000000) + +ans = list(range(min_x, max_x+1)) + +print(*ans) +" +p03386,s169409477,Wrong Answer,"a, b, k = map(int,input().split()) +ans = [] +for i in range(k): + if a <= a+i <= b: + ans.append(str(a+i)) + if a <= b-i <= b: + ans.append(str(b-i)) +for i in (sorted(set(ans))): + print(i)" +p03543,s275113664,Wrong Answer,"N = input() +s1 = N[1:len(N)] +s2 = N[0:len(N) - 1] +isOk = True +for i in range(1, len(N)-1): + if s1[i] != s1[i - 1]: + break + isOk = False + else: + continue + +if isOk: + print('Yes') + exit(0) + +isOk = True +for i in range(1, len(N)-1): + if s2[i] != s2[i - 1]: + break + isOk = False + else: + continue + +if isOk: + print('Yes') +else: + print('No') +" +p03435,s472117699,Accepted,"lst = [] +for i in range(3): + l = list(map(int, input().split())) + lst.append(l) +for i in range(1, 3): + diff = lst[i][0] - lst[0][0] + for j in range(3): + lst[i][j] -= diff + if lst[i] != lst[0]: + print('No') + exit() +print('Yes')" +p02993,s350778615,Wrong Answer,"s = list(map(int, input())) +for i in range(1,4): + if s[i]==s[i-1]: + print('Bad') + exit() +print('Yes')" +p03799,s817820135,Wrong Answer,"n, m = map(int, input().split()) + +import math +#x = math.ceil((m-2*n)/4) +if m >= 2*n: + x = math.ceil((m-2*n)/4) + y = math.floor((m-2*n)/4) + ans = max(n+y, (m-2*x)//2) + print(ans) +else: + print(n) +" +p03625,s921476308,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +from collections import Counter + +A_=Counter(A) +A_.most_common() + +Rectangle = [_ for _ in A_.keys() if A_[_] >1] +sq_list=[_ for _ in A_.keys() if A_[_] >= 4] + +Rectangle.sort() +sq_list.sort() + +ans=0 + +if len(Rectangle) >= 2: + a_1 = Rectangle[-1] + a_2 = Rectangle[-2] + ans = a_1*a_2 + +if len(sq_list) >= 1: + s_1 = sq_list[-1] + if ans < s_1**2: + ans=s_1**2 + +print(ans)" +p02642,s323118994,Accepted,"def main(): + N=input() + A=sorted(map(int,input().split())) + M=A[-1]+1 + B=[True]*M + c=0 + x=0 + for i in A: + if B[i]: + if i!=c: + for j in range(i*2,M,i): + B[j]=False + x+=1 + c=i + else: + B[i]=False + x-=1 + print(x) +main()" +p03017,s969358516,Accepted,"n,a,b,c,d = map(int,input().split()) +s = list(input()) +s.insert(0,0) +for i in range(a,max(c,d)): + if '#' == s[i] and '#' == s[i+1]: + print('No') + exit(0) +if c < d: + print('Yes') +else: + for i in range(b-1,d): + if '.' == s[i] and '.' == s[i+1] and '.' == s[i+2]: + print('Yes') + exit(0) + print('No')" +p03013,s732502864,Accepted,"n,m=map(int,input().split()) +a=[0]*(m+1) +mod=1000000007 +for i in range(m): + a[i]=int(input()) +s=[1,1] +j=0 +for i in range(2,n+1): + if i-1==a[j]: + s[i-1]=0 + j+=1 + s.append(s[i-1]+s[i-2]) + +print(s[n]%mod) + + +" +p03352,s079874352,Accepted,"X = int(input()) + +ans = 0 +for b in range(1, X + 1): + p = 2 + while b ** p <= X: + ans = max(ans, b ** p) + if b == 1: break + p += 1 + +print(ans) +" +p04033,s687787046,Wrong Answer,"def resolve(): + ''' + code here + ''' + a,b = [int(item) for item in input().split()] + + if a > 0: + print('Positive') + else: + if a <= 0 and b >= 0 or a == b: + print('Zero') + else: + cnt = a - b + + if cnt % 2 == 1: + print('Posivite') + else: + print('Negative') + +if __name__ == ""__main__"": + resolve() +" +p03408,s875591156,Wrong Answer,"n=int(input()) +word={} +for i in range(n): + new=input() + if new in word: + word[new]+=1 + else: + word[new]=1 +m=int(input()) +for i in range(m): + new=input() + if new in word: + word[new]-=1 + else: + word[new]=-1 + +print(max(word.values()))" +p02819,s064686042,Accepted,"input_num = input() +number = int(input_num) +target = number +while 1: + count = 0 + for i in range(target+1): + if i == 0: + continue + if target%i == 0: + count += 1 + if count == 2: + break + target += 1 + +print(target)" +p02723,s665773299,Accepted,"S =input().strip() + +def check(i, j): + if S[i] == S[j]: + return True + return False + +if check(2,3) and check(4,5): + print(""Yes"") +else: + print(""No"") +" +p03387,s631424654,Accepted,"a, b, c = sorted([int(i)for i in input().split()]) +ans = 0 +ma, mb, mc = [a % 2, b % 2, c % 2] + +if ma == mb == mc: + pass +elif ma != mb and mb == mc: + b += 1 + c += 1 + ans += 1 +elif ma == mc and ma != mb: + a += 1 + c += 1 + ans += 1 +elif ma == mb and mb != mc: + a += 1 + b += 1 + ans += 1 + +ans += (c - b) // 2 +ans += (c - a) // 2 + +print(ans) +" +p02793,s324749468,Accepted,"import fractions + +n = int(input()) +a_list = list(map(int,input().split())) + +ans = a_list[0] +for i in range(1, n): + ans = ans * a_list[i] // fractions.gcd(ans, a_list[i]) + +num = 0 +for a in a_list: + num += ans//a + +print(num%1000000007)" +p03862,s969164818,Accepted,"N,x = map(int,input().split()) +a = list(map(int,input().split())) + +res = 0 +if a[0]>x: + res = a[0]-x + a[0] = x +for i in range(1,N): + tmp = a[i]+a[i-1]-x + if tmp > 0: + a[i] -= tmp + res += tmp +print(res) + + +" +p03665,s914618201,Accepted,"from math import factorial + +def combi(n, k): + return factorial(n) // factorial(n-k) // factorial(k) + +N, P = map(int, input().split()) +A = list(map(int,input().split())) + +e = len([a for a in A if a % 2 == 0]) +o = N - e + +ans = 0 +for i in range(P, o+1, 2): + ans += combi(o, i) +print(ans * pow(2, e))" +p02548,s062628566,Wrong Answer,"N = int(input()) + +count = 0 +for x in range(1, int(N/2+2)): + for y in range(1, int(N/2+2)): + if x * y < N: + count += 1 + else: + break + +print(count)" +p03672,s121392737,Wrong Answer,"S = input() +leng = len(S) +ans = 0 +for i in range(leng, 1, -1): + if S[:(i // 2)] == S[i // 2:i]: + ans = i +print(ans) +" +p03778,s779520174,Wrong Answer,"w, a, b = map(int, input().split()) + +print(b-(w+a))" +p03617,s815625659,Wrong Answer,"Q, H, S, D = list(map(int, input().split())) +Q *= 8 +H *= 4 +S *= 2 +A = min(Q, H, S, D) +B = min(Q, H, S) +N = int(input()) + +print(int(N/2*A+N%2*B))" +p03438,s277450277,Accepted,"import math +n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +c=sum(b)-sum(a) +d=0 +for i in range(n): + if a[i]>b[i]:d+=a[i]-b[i] + elif a[i]%2!=b[i]%2:d+=1 +print(""No""if c 10**6: + break + dp[i*j] += 1 + elif dp[i] == 1: + dp[i] += 1 + +for i in a: + if dp[i] == 1: + ans += 1 + + +print(ans) +" +p03137,s202086668,Accepted,"n, m = map(int, input().split()) +x = list(map(int, input().split())) +x.sort() +if m <= n: + print(0) +else: + length = abs(x[0]-x[-1]) + abs_x = [0]*(m-1) + for i in range(m-1): + abs_x[i] = abs(x[i+1] - x[i]) + abs_x.sort(reverse=True) + for i in range(n-1): + length -= abs_x[i] + print(length)" +p03220,s842745847,Accepted,"n = int(input()) +t,a = map(int,input().split()) +li = list(map(int,input().split())) +for i in range(n): + li[i] = abs(a - (t - li[i]*0.006)) +print(int(li.index(min(li)))+1)" +p03281,s319905093,Accepted,"n = int(input()) +ans = 0 +for i in range(1,n+1,2): + cnt = 0 + for j in range(1,i+1): + cnt += (i%j==0) + if cnt==8: ans+=1 +print(ans)" +p02570,s116106739,Accepted,"d,t,s = map(int,input().split()) + +if t >= d/s: + print('Yes') +else: + print('No') +" +p03481,s881879992,Wrong Answer,"x,y=map(int, input().split()) +import math +k=int(math.log2(y/x))+1 +print(k)" +p02661,s556868630,Accepted,"def main(): + n = int(input()) + A, B = [None]*n, [None]*n + for i in range(n): + A[i], B[i] = map(int, input().split()) + A.sort() + B.sort() + if n%2 == 0: + p = (A[n//2-1] + A[n//2])/2 + q = (B[n//2-1] + B[n//2])/2 + print(int((q-p+0.5)*2)) + else: + print(B[n//2] - A[n//2] + 1) + +if __name__ == ""__main__"": + main()" +p02772,s497144647,Accepted,"n = int(input()) +a = input().split() +even = [] +even_counter = 0 +div = 0 + +for i in a: + int_a = int(i) + if int_a % 2 == 0: + even.append(int_a) + even_counter += 1 + +for i in range(even_counter): + if int(even[i]) % 3 == 0 or int(even[i]) % 5 == 0: + div += 1 + +if div == even_counter: + print(""APPROVED"") +else: + print(""DENIED"") +" +p03665,s835766621,Wrong Answer,"import scipy.misc +n,p = map(int,input().split()) +ai = [int(i)%2 for i in input().split()] + +zero = ai.count(0) +one = ai.count(1) + + +tmp = 2**zero +ans = 0 +for i in range(one//2+1): + if p == 0: + if i*2 > one: + break + ans += scipy.misc.comb(one,0+i*2) + else: + if i*2+1 > one: + break + ans += scipy.misc.comb(one,1+i*2) +print(int(ans*tmp))" +p03161,s030331043,Wrong Answer,"N, K = map(int,input().split()) +h = list(map(int,input().split())) + +dp = [10000000]*(N) +dp[0]=0 +for i in range(0,N): + for j in range(0,K+1): + if i+j>j)&1: ability += a[j] ; cost += c[j] + if np.all(ability>=x): ans = min(ans,cost) + +ans = -1 if ans==np.inf else ans +print(ans) +" +p02663,s588989644,Accepted,"# 2020/05/30 +# NOMURA プログラミングコンテスト 2020 - A + +# Input +h1, m1, h2, m2, k = map(int,input().split()) + +# Calc +hm1 = h1 * 60 + m1 +hm2 = h2 * 60 + m2 +ans = hm2 - hm1 - k + +# Output +print(ans) +" +p02971,s732544170,Wrong Answer,"n = int(input()) +a = [] +for i in range(n): + a.append(int(input())) +m = max(a) +for i in range(n): + if a[i] != m: + print(m) + else: + print(max(a[:i],a[i+1:])[0])" +p02600,s771105734,Accepted,"X = int(input()) + +if X in range(400,600): + print(8) +elif X in range(600,800): + print(7) +elif X in range(800,1000): + print(6) +elif X in range(1000,1200): + print(5) +elif X in range(1200,1400): + print(4) +elif X in range(1400,1600): + print(3) +elif X in range(1600,1800): + print(2) +else: + print(1)" +p04034,s087065321,Accepted,"N,M = map(int,input().split()) +XY = [tuple(map(int,input().split())) for i in range(M)] + +may_red = [0] * N +may_red[0] = 1 +balls = [1] * N + +for x,y in XY: + x,y = x-1,y-1 + if may_red[x]: + may_red[y] = 1 + if balls[x] == 1: + may_red[x] = 0 + balls[x] -= 1 + balls[y] += 1 +print(sum(may_red))" +p02766,s241056960,Wrong Answer,"N, K = map(int,input().split()) + +ans = 0 +for i in range(10**9): + if K**i < N: + i = i + 1 + else: + ans = i + break + +print(ans)" +p02640,s966775949,Wrong Answer,"x, y = map(int,input().split()) +z =-2 +for i in range(x): + if i % 2 == 0: + z +=4 + else: + z +=2 +if z == y or z == (y-2): + print(""Yes"") +elif z!=y : + print(""No"")" +p02881,s123845534,Accepted,"n = int(input()) +ans = 10**15 +for i in range(1, n): + if n % i == 0: + ans = min(ans, n // i - 1 + i - 1) + if i * i > n: + break +print(ans)" +p02947,s098506271,Accepted,"n = int(input()) +ans = 0 +ls = {} +for _ in range(n): + s = ''.join(sorted(input())) + if s in ls: + ans += ls[s] + ls[s] += 1 + else: + ls[s] = 1 +print(ans)" +p02705,s297407499,Wrong Answer,"r = int(input()) +if 0 <= r <= 100: + length = r * 3.1415926535 + print(length) +" +p03745,s997377761,Accepted,"N=int(input()) +A=list(map(int, input().split())) + +ans=0 +uf=False +lf=False +pre=A[0] +for i in range(1,N): + if pre==A[i]: + continue + + if A[i]>pre: + uf=True + if lf: + ans+=1 + uf=False + lf=False + else: + lf=True + if uf: + ans+=1 + uf=False + lf=False + pre=A[i] + +print(ans+1) + " +p03075,s621495785,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) +print (""Yay!"") if e-k <= k else print ("":("") +" +p02957,s642888871,Accepted,"A,B=map(int,input().split()) +print((A+B)//2 if (A+B)%2==0 else ""IMPOSSIBLE"")" +p03544,s314838131,Wrong Answer,"t=[0,1] +for i in range(2,90): + t.append(t[i-1]+t[i-2]) +print(t[int(input())]) +" +p02657,s791651553,Accepted,"a, b = list(map(int, input().split())) +print(a*b)" +p03472,s070216222,Accepted,"n, h =map(int, input().split()) +A=[] +B=[] +w=0 +sub=0 +for i in range(n): + a,b=map(int, input().split()) + A.append(a) + B.append(b) + w=max(a,w) + +ans=0 +B.sort(reverse=True) +for i in range(n): + if B[i]>w: + h-=B[i] + ans+=1 + if 1>h: + print(ans) + exit() +ans+=h//w +if h%w==0: + print(ans) +else: + print(ans+1) +" +p02767,s551388677,Accepted,"N=int(input()) +S=list(map(int,input().split())) + +select=len(S) +goukei=10**10 +for i in range(1,100): + kouho=0 + for j in range(select): + kouho+=(S[j]-i)**2 + + if kouho= x: + ans = 90 - degrees(atan((2 * x) / (a * b * b))) +else: + ans = degrees(atan((2 * ((a**2 * b) - x))/(a ** 3))) +print(ans)" +p03323,s291600870,Accepted,"import sys +A,B = map(int,input().split()) + +if not (1 <= A <= 16 and 1 <= B <= 16 and (A + B <= 16)) : + sys.exit() + +print('Yay!') if A <= 8 and B <= 8 else print(':(')" +p02791,s918438575,Accepted,"n = int(input()) +p = list(map(int, input().split())) + +c = 0 +m = p[0] +for i in p: + if m >= i: + c += 1 + m = i + +print(c) + +" +p03427,s170068147,Accepted,"n=input() +l=len(n)-1 +if int(n)==(int(n[0])+1)*10**l-1: + print(int(n[0])+9*l) +else: + print(int(n[0])+9*l-1)" +p02700,s597265909,Accepted,"a, b, c, d = map(int, input().split()) +if -(-a//d)+1 > -(-c//b): + print('Yes') +else: + print('No')" +p03803,s047141126,Wrong Answer,"a,b=map(int,input().split()) + +if (a-1)%13>(b-1)%13: + print(""Alice"") +elif (a-1)%13<(b-1)%13: + print(""Bob"") +else: + print(""Draw"")" +p02607,s515391398,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] + +count = 0 +for i in range(n): + if(i % 2 == 0 and a[i] % 2 == 1): + count +=1 + + +print(count) + + + + + +" +p02707,s560149899,Accepted,"n = int(input()) +k =[0]*n +a = list(map(int, input().split())) + +for i in range(n-1): + k[a[i]-1] += 1 + +for i in range(len(k)): + print(k[i])" +p02862,s361710234,Accepted,"import sys +input = lambda: sys.stdin.readline().rstrip() + +mod = 1000000007 +X,Y = map(int, input().split()) + + +def combination(n, r, mod): + r = min(r, n-r) + + numer = 1 + denom = 1 + + for i in range(r): + numer = numer * (n-i) % mod + denom = denom * (r-i) % mod + + return numer * pow(denom, mod-2, mod) % mod + + +m_n = (X+Y) // 3 +m = X - m_n +n = Y - m_n + +if (X+Y) % 3 != 0 or m < 0 or n < 0: + print(0) + exit() + + +print(combination(m_n, m, mod))" +p04019,s891480893,Wrong Answer,"s=input() +if str(s in ""S"")==str(s in ""N"") and str(s in ""E"")==str(s in ""W""): + print(""Yes"") +else: + print(""No"") +" +p02842,s793199710,Accepted,"import math +N=int(input()) +X=N/1.08 +X=math.ceil(X) +if math.floor(X*1.08)==N: + print(X) +else: + print("":("")" +p03160,s207637272,Accepted,"n=int(input()) +import sys +sys.setrecursionlimit(10 ** 6) +h=list(map(int,input().split())) +cos={0:0,1:abs(h[1]-h[0])} +def cost(x): + if x not in cos: + d1=cost(x-1)+abs(h[x]-h[x-1]) + d2=cost(x-2)+abs(h[x]-h[x-2]) + cos[x]=min(d1,d2) + return cos[x] + else: + return cos[x] + +print(cost(n-1))" +p02993,s251425677,Wrong Answer,"if len(list(set(list(input())))) == 4: + print(""Good"") +else: + print(""Bad"")" +p03352,s827428165,Accepted,"X = int(input()) +L = [] +for i in range(33): + for j in range(2, 10): + x = i ** j + if x <= X: + L.append(x) + +print(max(L)) +" +p02953,s667663245,Accepted,"n = int(input()) +h = list(map(int,input().split()))[::-1] +ans = 'Yes' +for i in range(n-1): + if h[i+1] - h[i] >= 2: + ans = 'No' + elif h[i+1] - h[i] == 1: + h[i+1] -= 1 +print(ans)" +p02792,s447473023,Wrong Answer,"# -*- coding: utf-8 -*- + +n=int(input()) +c = int((n * n/100.0) + 8) + +print(c)" +p02714,s801710736,Accepted,"N = int(input()) +S = input() + +d = {""R"": 0, ""G"": 0, ""B"": 0} +for i in range(N): + d[S[i]] += 1 + +ans = d[""R""] * d[""G""] * d[""B""] + +cnt = 0 +for i in range(1, N - 1): + for j in range(i + 1, N): + k = 2 * j - i + if k > N or S[i - 1] == S[j - 1]: + continue + + if S[i - 1] != S[k - 1] and S[j - 1] != S[k - 1]: + cnt += 1 + +print(ans - cnt) + +" +p02952,s327779624,Accepted,"# B - Uneven Numbers + +N = int(input()) +cnt = 0 +for i in range(1, N + 1): + if len(str(i)) % 2 != 0: + cnt += 1 + +print(cnt)" +p04034,s570012483,Accepted,"def operate(x, y): + if is_red[x]: + is_red[y] = True + if num_ball[x] == 1: + is_red[x] = False + num_ball[x] -= 1 + num_ball[y] += 1 + + +if __name__ == ""__main__"": + + N, M = [int(x) for x in input().split("" "")] + num_ball = [1 for _ in range(N)] + is_red = [True] + [False for _ in range(N - 1)] + + for _ in range(M): + x, y = [int(x) for x in input().split("" "")] + x, y = x - 1, y - 1 + operate(x, y) + print(sum(is_red))" +p03106,s506891443,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + A, B, K = map(int, readline().split()) + + vec = [] + for n in range(1, max(A, B) + 1): + if A % n == 0 and B % n == 0: + vec.append(n) + + print(vec[-K]) + return + + +if __name__ == '__main__': + main() +" +p02785,s057212499,Accepted,"n, k = map(int, input().split()) +h = list(map(int, input().split())) +h.sort() +print(sum(h[:max(0,n-k)])) +" +p02552,s512034472,Accepted,"n = int(input()) +if n == 1: + print(0) +else: + print(1)" +p02900,s216845109,Accepted,"from fractions import gcd +#from math import gcd +def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a +a,b=map(int,input().split()) +m=gcd(a,b) +P=prime_factorize(m) +print(1+len(list(set(P))))" +p03555,s670811165,Accepted,"x = input() +y = input() + +x = list(x) +y = list(y) +x_ = x +y_ = y +x_ = reversed(x) +y_ = reversed(y) +x_ = list(x_) +y_ = list(y_) + + +if y_ == x and x_ == y: + print(""YES"") +else: + print(""NO"")" +p02556,s552666645,Accepted,"N = int(input()) +A = [[int(a) for a in input().split()] for _ in range(N)] +for i in range(N): + z = A[i][0] + A[i][1] + w = A[i][0] - A[i][1] + if i==0: + M_z = m_z = z + M_w = m_w = w + if z > M_z: M_z = z + if z < m_z: m_z = z + if w > M_w: M_w = w + if w < m_w: m_w = w +print(max(M_z-m_z,M_w-m_w))" +p03371,s913380715,Accepted,"a,b,c,x,y=map(int,input().split()) + +ans=10**9 +for i in range(2*max(x,y)+1): + s=max(x-i//2,0) + t=max(y-i//2,0) + t_ans=s*a+t*b+i*c + ans=min(ans,t_ans) + +print(ans)" +p03487,s189262427,Accepted,"input() +from collections import * +c=Counter(map(int,input().split())) +print(sum(v-k*(k<=v) for k,v in c.items()))" +p03061,s501315779,Wrong Answer,"from fractions import gcd + +N = int(input()) +As = list(map(int, input().split())) +re_As = As[::-1] +gcds = [0]*(N+1) +rgcds = [0]*(N+1) + +for i in range(N): + gcds[i] = gcd(As[i], As[i-1]) + rgcds[i] = gcd(re_As[i], re_As[i-1]) + +rgcds = rgcds[::-1] + +ans = [0]*(N+1) + +for i, (s, r) in enumerate(zip(gcds, rgcds)): + ans[i] = gcd(s, r) + +print(max(ans))" +p02701,s155385505,Wrong Answer,"s=input() +n=len(s) +ans=0 +for i in range(n-3): + for j in range(i+3,n+1): + if int(s[i:j])%2019==0: + ans+=1 +print(ans)" +p03434,s395476358,Accepted,"N = int(input()) + +a = list(map(int,input().split())) + +for i in range(N): + for j in reversed(range(i+1,N)): + #print(i,j) + if a[j] > a[j-1]: + temp = a[j] + a[j] = a[j-1] + a[j-1] = temp + +Alice = 0 +Bob = 0 + +k = 0 +count =1 +while k < N: + if count % 2 == 0: + Bob += a[k] + else: + Alice += a[k] + k += 1 + count += 1 + +print(Alice-Bob)" +p02556,s428670680,Wrong Answer,"from collections import defaultdict +dic = defaultdict(list) +N = int(input()) +l = [] +z = [] +for _ in range(N): + x, y = map(int, input().split()) + l.append([x, y]) + z.append(x+y) +z.sort() +ans = z[-1]-z[0] + +for t in l: + a = t[0]+t[1] + dic[a].append(t) +for u in dic: + dic[u].sort() + b = dic[u][-1][0]-dic[u][0][0] + ans = max(2*b,ans) +print(ans)" +p03804,s009970518,Accepted,"N, M = map(int, input().split()) +A = [""""] * N +B = [""""] * M + +for i in range(N): + A[i] = input() +for i in range(M): + B[i] = input() + +trm = [""""] * M + +for i in range(N-M+1): + for j in range(N-M+1): + trm = [A[k+i][j:j+M] for k in range(M)] + if B == trm: + print(""Yes"") + break + else: + continue + break +else: + print(""No"")" +p03665,s733812236,Wrong Answer,"n,p=map(int, input().split()) +A=[int(i)%2 for i in input().split()] +t=sum(A) + +if t==0: + if p==1: + sum=0 + else: + print(2**n) +else: + print(2**(n-1)) +" +p03944,s367503675,Accepted,"w, h, n = map(int, input().split()) + +min_x, min_y, max_x, max_y = 0, 0, w, h +for _ in range(n): + x, y, a = map(int, input().split()) + + if a == 1: + min_x = max(min_x, x) + elif a == 2: + max_x = min(max_x, x) + elif a == 3: + min_y = max(min_y, y) + else: + max_y = min(max_y, y) + +if min_x < max_x and min_y < max_y: + print((max_x - min_x) * (max_y - min_y)) +else: + print(0)" +p03359,s607775570,Accepted,"# -*- coding: utf-8 -*- +a, b = map(int, input().split()) +print(a - int(a > b))" +p02601,s689905334,Accepted,"from sys import stdin +import sys +import itertools as it + +A, B, C = [int(x) for x in stdin.readline().rstrip().split()] +K = int(input()) +if C > B and B > A: + print(""Yes"") + sys.exit() +for i in range(K+1): + c1 = C*(2**i) + b1 = B*(2**(K-i)) + if c1 > b1 and b1 > A: + print(""Yes"") + sys.exit() +print(""No"") +" +p03779,s052358638,Accepted,"x=int(input()) +for i in range(10**5): + if 2*x<=(i+1)*i: + print(i) + break" +p03416,s383012662,Accepted,"A,B = list(map(int, input().split())) + +ans = 0 +#各桁の数字を求める +for i in range(A,B+1): + if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]: + ans += 1 + +print(ans) + +" +p03281,s433136456,Accepted,"N = int(input()) +cnt=0 +def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + + # divisors.sort() + return divisors + +for i in range(1,N+1,2): + if(len(make_divisors(i))==8): + cnt+=1 + +print(cnt)" +p02689,s935795137,Accepted,"N, M = map(int, input().split()) +H = list(map(int, input().split())) +a = [True] * N +for i in range(M): + ai, bi = map(int, input().split()) + if H[ai-1] <= H[bi-1] : + a[ai-1] = False + if H[ai-1] >= H[bi-1]: + a[bi-1] = False +print(sum(a)) + " +p03071,s263517708,Accepted,"A,B = map(int,input().split()) + +ans = 0 +for i in range(2): + if A >= B: + ans += A + A -= 1 + else: + ans += B + B -= 1 + +print(ans)" +p03087,s701541606,Accepted,"n,q = map(int,input().split()) +s = input() +cnt = [0] * (n+1) +for i in range(n): + if s[i:i+2] == ""AC"": + cnt[i+1] = cnt[i] + 1 + else: + cnt[i+1] = cnt[i] +for i in range(q): + l,r = map(int,input().split()) + print(cnt[r-1]-cnt[l-1])" +p02768,s042550632,Accepted,"n,a,b=map(int,input().split()) +mod=10**9+7 + +def pow(x, n): + ans = 1 + while(n > 0): + if(bin(n & 1) == bin(1)): + ans = ans*x%mod + x = x*x%mod + n = n >> 1 + return ans + +N=pow(2,n) +def comb(c,d): + x=1 + for i in range(d): + x=x*(c-i)%mod + y=1 + for i in range(d): + y=y*(i+1)%mod + return x*pow(y,mod-2)%mod +A=comb(n,a) +B=comb(n,b) +print((N-A-B-1)%mod)" +p02873,s176656668,Wrong Answer,"S=input() +L=[0]*(len(S)+1) +#print(L) +for i in range(len(S)-1): + if S[i]=='<': + L[i+1]=max(L[i+1],L[i]+1) +for i in range(len(S)-1,-1,-1): + if S[i]=='>': + L[i]=max(L[i],L[i+1]+1) +print(sum(L))" +p03251,s246288814,Accepted,"n,m,x,y = map(int,input().split()) +X = list(map(int,input().split())) +Y = list(map(int,input().split())) + +x_max = max(X) +y_min = min(Y) + +for i in range(x+1,y+1): + if x_max < i and y_min >= i: + print(""No War"") + exit() + +print(""War"")" +p02684,s623619808,Wrong Answer,"n, k = map(int, input().split()) +a_list = list(map(int, input().split())) +loop = [] +now = 1 +while not now in loop: + loop.append(now) + now = a_list[now - 1] +loop_start_index = loop.index(now) +print(loop[loop_start_index + (k - loop_start_index) % (len(loop) - loop_start_index)]) +" +p02753,s919835552,Accepted,"print ""Yes"" if len(set(raw_input()))!=1 else ""No"" +" +p02602,s435098555,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +ans = [] +for i in range(K, N): + ans.append(['No', 'Yes'][A[i] > A[i - K]]) + +print('\n'.join(ans))" +p03345,s130119593,Accepted,"a, b,c, k = map(int, input().split()) +x = b - a +if k % 2 == 0: + print(-x) +else: + print(+x)" +p03109,s348078976,Accepted,"s = input() + +m = int(s[5] + s[6]) + +if m >= 5: + print(""TBD"") + +else: + print(""Heisei"") + " +p03329,s364463728,Wrong Answer,"N = int(input()) + +a = N +for i in range(N): + cc = 0 + t = i + while t > 0: + cc += t%6 + t //= 6 + t = N - i + while t > 0: + cc += t%9 + t //= 9 + if a > cc: + a = cc + +print(a)" +p04020,s337973228,Accepted,"def main(): + n = int(input()) + cards = [] + for _ in range(n): + cards.append(int(input())) + cards.append(0) + answer = 0 + tmp = 0 + for i in range(n + 1): + if cards[i]: + tmp += cards[i] + else: + answer += tmp // 2 + tmp = 0 + print(answer) + + +if __name__ == '__main__': + main() + +" +p03862,s764254757,Accepted,"n, border = map(int, input().split()) + +boxes = [int(x) for x in input().split(' ')] + +count = 0 +for i in range(n): + if(boxes[i] > border): + count += boxes[i] - border + boxes[i] = border + +for i in range(n-1): + if(boxes[i] + boxes[i+1] > border): + count += boxes[i] + boxes[i+1] - border + boxes[i+1] -= boxes[i] + boxes[i+1] - border + +print(count)" +p03544,s466040682,Wrong Answer,"n=int(input()) + +if n==1: + print(2) +elif n==2: + print(1) +else: + ans=0 + num_1=2 + num_2=1 + for i in range(n-1): + ans = num_1+num_2 + num_1,num_2 = num_2, ans + print(ans) +" +p03854,s808767484,Accepted,"words = ['maerd', 'remaerd', 'esare', 'resare'] +S = input() +T = '' +for a in S[::-1]: + T += a + for s in words: + if T == s: + T = '' +print('YES' if T == '' else 'NO')" +p02988,s746949971,Accepted,"# -*- coding: utf-8 -*- + +n = int(input()) +p = list(map(int, input().split())) + +cnt = 0 + +for i in range(1, n-1): + if sorted(p[i-1:i+2])[1] == p[i]: + cnt += 1 + +print(cnt) +" +p03285,s039508035,Accepted,"n = int(input()) + +for i in range(26): + for j in range(15): + if 4*i + 7*j == n: + print('Yes') + exit() +print('No')" +p03486,s634085025,Accepted,"def main(): + S = [s for s in input()] + T = [t for t in input()] + S.sort() + T.sort(reverse=True) + if S < T: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + main() +" +p02801,s848655817,Wrong Answer,"alpha = input() +a_code = ord('a') +z_code = ord('z') +alpha_code = ord(alpha) +if alpha_code >= a_code and alpha_code < z_code: + next_alpha_code = alpha_code + 1 + next_alpha = chr(next_alpha_code) + print(alpha + 'の次は' + next_alpha + 'です。') +else:print('a ~ yを入力してください')" +p02547,s955805966,Wrong Answer,"N = int(input()) +xy = [map(int, input().split()) for _ in range(N)] +x, y = [list(i) for i in zip(*xy)] +count = 0 +for i in range(N-3): + if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]: + count += 1 + print(""Yes"") + break + +if count == 0: + print(""No"")" +p03126,s657820013,Accepted,"N,M = map(int,input().split()) +ans = [0]*M +for i in range(N): + KA = list(map(int,input().split())) + for j in range(1,len(KA)): + ans[KA[j]-1] += 1 +print(ans.count(N))" +p04029,s256552115,Wrong Answer,"import math +print(math.factorial(int(input())))" +p03487,s596037207,Accepted,"import collections + +n = int(input()) +l = list(map(int,input().split())) +c = collections.Counter(l) + +count = 0 + +for i,j in c.items(): + + if i < j: + count += j-i + elif i > j: + count += j +print(count)" +p03131,s105975515,Accepted,"K,A,B = map(int,input().split()) +ans = 1+K +rem = K-(A-1) +ans2 = A + rem%2 + (rem//2)*(B-A) +print(max(ans, ans2))" +p03998,s775604245,Accepted,"a=list(input()) +b=list(input()) +c=list(input()) + +a.append('A') +b.append('B') +c.append('C') + +def f(s): + if len(s)>1: + va=s[0] + del s[0] + if va=='a': + f(a) + elif va=='b': + f(b) + else: + f(c) + else: + return print(s[0]) +f(a)" +p03317,s293243123,Wrong Answer,"import numpy as np +N,K = map(int,input().split()) +an = list(map(int,input().split())) + +min_an_index = np.argmin(an) + +a = min_an_index +b = N - min_an_index - 1 + +a1 = a // (K-1) +if a % (K-1) != 0: + a1 += 1 + +b1 = b // (K-1) +if b % (K-1) != 0: + b1 += 1 + +count = a1 + b1 +print(count) +" +p03380,s402049282,Wrong Answer,"import bisect +n=int(input()) +a=[0]+sorted(list(map(int,input().split()))) +x=a[-1] +i=bisect.bisect_left(a,x//2) +if abs(a[i]-x)>abs(a[i-1]-x):y=a[i-1] +elif i==n:y=a[i-1] +else:y=a[i] +print(x,y)" +p02795,s951216240,Accepted,"h = int(input()) +w = int(input()) +n = int(input()) +ans = 0 + +while True: + if h >= w: + n = n - h + else: + n = n - w + + ans = ans + 1 + + if n <= 0: + break + +print(ans)" +p03150,s890306623,Accepted,"n = list(input()) + +for i in range(len(n)): + for j in range(i,len(n)): + tmp = n[:] + del tmp[i:j] + if ''.join(tmp) == 'keyence': + print('YES') + exit() +else: + print('NO') +" +p03495,s823084598,Wrong Answer,"r,k = map(int,input().split()) +b = [i for i in map(int,input().split())] +s = set(b) + +if len(s) <= k: + print(0) +else: + n = [b.count(i) for i in s] + n.sort() + ans = 0 + for i in range(len(s)-k): + ans += n[i] + print(n[i]) + print(ans)" +p02641,s066254968,Wrong Answer,"X, N = map(int, input().split()) +if (N == 0): + print(X) +else: + nums = list(map(int, input().split())) + + nums.sort() + low = nums[0] + high = nums[-1] + minDiff = 100000000 + minNum = -1 + for i in range(1, 101): + if i in nums: + continue + else: + Dif = abs(X-i) + if (Dif < minDiff): + minDiff = Dif + minNum=i + + if (minNum == -1): + print(X) + else: + print(minNum) + +" +p02584,s068324877,Accepted,"x,k,d = map(int,input().split()) +x = abs(x) +if x//d > k: + print(x-k*d) +elif (k-x//d)%2 == 0: + print(x%d) +else: + print(d-x%d)" +p02659,s049471639,Accepted,"a,b = input().split() +c = int(a) +d = round(float(b)*100) +print(c*d//100) +" +p03282,s083753738,Accepted,"def main(): + s = input() + k = int(input()) + r = '1' + for i,v in enumerate(s): + if v != '1': + r = v + break + if i >= k: + print(1) + else: + print(r) + +if __name__ == ""__main__"": + main()" +p03548,s276251613,Wrong Answer,"a,b,c =map(int,input().split()) + +print((a-1)//(b+c))" +p03971,s734099150,Wrong Answer,"N, A, B = input().split(' ') +N = int(N) +A = int(A) +B = int(B) +S = [] +S = list(input()) +JS = 0 +AS = 0 +OT = 0 + +for i in range(N): + print(S[i]) + if S[i] == 'a': + JS += 1 + elif S[i] == 'b': + AS += 1 + elif S[i] == 'c': + OT += 1 + + if S[i] == 'a' and A + B >= (JS + AS): + print('Yes') + elif S[i] == 'b' and A + B >= (JS + AS) and AS <= B: + print('Yes') + else: + print('No') " +p03799,s606973048,Accepted,"#ARC069-C +n,m = map(int,input().split()) +if n*2 <= m:#cのほうが多いとき + print((n*2 + m)//4) +else: + print(m//2)" +p03545,s187337657,Wrong Answer,"def resolve(): + s = input() + + def dfs(i, f): + if i == 3: + return f.split("","") + return dfs(i+1, f + ""+"" + s[i+1]) + dfs(i+1, f + ""-"" + s[i-1]) + for i in dfs(0, s[0]): + if eval(i) == 7: + print(i + ""=7"") + exit() +resolve()" +p02700,s019482096,Accepted,"S=list(map(int,input().split())) +while True: + S[2]=S[2]-S[1] + S[0]=S[0]-S[3] + if S[2]<=0: + print(""Yes"") + break + elif S[0]<=0: + print(""No"") + break" +p03804,s598168184,Accepted,"n, m = map(int, input().split()) +a = [input() for _ in range(n)] +b = [input() for _ in range(m)] +s = 0 +cnt = 0 + +for i in range(n-m+1): + for j in range(n-m+1): + for x in range(m): + for y in range(m): + if a[i+x][j+y] == b[x][y]: + s += 1 + if s == m ** 2: + cnt += 1 + else: + s = 0 +if cnt > 0: + print('Yes') +else: + print('No')" +p03416,s216410288,Wrong Answer,"def solve(n, m): + + ans = len([i for i in range(n, m+1) if str(i)[:2] == str(i)[:-2]]) + return ans + +if __name__ == ""__main__"": + n, m = [int(i) for i in input().split()] + print(solve(n, m)) +" +p02693,s069572133,Accepted,"N = int(input()) +A=input().split() + +s=int(A[0])//N +if int(A[0])%N==0: + print('OK') +else: + if (s+1)*N>int(A[1]): + print('NG') + else: + print('OK') +" +p03680,s987073428,Wrong Answer,"n = int(input()) +a = [int(input()) for i in range(n)] + +ans = 0 +tmp = 0 + +for i in range(n): + ans += 1 + if a[tmp] == 2: + break; + tmp = a[tmp] - 1 +if ans == 0: + ans = -1 + +print(ans) +" +p02880,s546448128,Accepted,"N = int(input()) + +for x in range(1, 10): + if N%x == 0: + y = N//x + if 1 <= y <= 9: + print('Yes') + break +else: + print('No') +" +p03721,s270591396,Accepted,"from collections import Counter +n, k = map(int, input().split()) +d = Counter([]) +for i in range(n): + a, b = map(int, input().split()) + d[a] += b +ans = 1 +cnt = 0 +while cnt < k: + cnt += d[ans] + ans += 1 + +print(ans - 1)" +p03795,s237431469,Wrong Answer,"N = int(input()) + +print(20*800 - 20//15*200)" +p02571,s798185580,Wrong Answer,"S = input() +T = input() + +ans = len(T) + +for i in range(len(T)): + for j in range(i + 1, len(T) + 1): + if T[i:j] in S[i:]: + if len(T) - len(T[i:j]) < ans: + ans = len(T) - len(T[i:j]) + +print(ans) +" +p03328,s572712128,Accepted,"a,b = map(int,input().split()) +print(int((b-a)*(b-a+1)/2-b))" +p02820,s289351989,Accepted,"N,K = map(int,input().split()) +R,S,P = map(int,input().split()) +T = list(""x"" * K + input()) + +win = {""r"":P,""s"":R,""p"":S} + +ans = 0 +for i in range(K, len(T)): + if T[i] == T[i - K]: + T[i] = ""x"" + else: + ans += win[T[i]] + +print(ans)" +p02859,s020293048,Wrong Answer,"def circle(r): + return r*r +" +p03495,s009356226,Wrong Answer,"n, k = list(map(int,input().split())) +arr = list(map(int,input().split())) +arr = list(set(arr)) +print(max(0,k - len(arr) ) )" +p02880,s424171893,Accepted,"n=int(input()) +for i in range(1,10): + for j in range(1, 10): + if i*j==n: + print(""Yes"") + exit(0) +print(""No"")" +p03042,s567095734,Accepted,"s = input() + +s1 = int(s[0]+s[1]) +s2 = int(s[2]+s[3]) + +if s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1: + print('AMBIGUOUS') +elif s1 <= 12 and s1 >= 1: + print('MMYY') +elif s2 <= 12 and s2 >= 1: + print('YYMM') +else: + print('NA')" +p02600,s132079246,Wrong Answer,"x = int(input()) + +if x < 600: + print(8) +elif 600 <= x < 800: + print(7) +elif 800 <= x < 1000: + print(6) +elif 600 <= x < 800: + print(5) +elif 1200 <= x < 1400: + print(4) +elif 1400 <= x < 1600: + print(3) +elif 1600 <= x < 1800: + print(2) +else: + print(1)" +p03730,s728852638,Accepted,"a, b, c = map(int, input().split()) +flag = False +for i in range(b): + if a*i % b == c: + flag = True + break +print('YES' if flag else 'NO') +" +p03351,s161385308,Wrong Answer,"a, b, c, d = map(int, input().split()) +# 標準入力複数 +# print(a, b, c, d) +if a - b <= 3 and b - c <= 3: + print(""Yes"") +elif b - a <= 3 and c - b <= 3: + print(""Yes"") +else: + print(""No"")" +p02663,s793050189,Accepted,"h1,m1,h2,m2,k = map(int, input().split()) + +bt = h1*60 + m1 +at = h2*60 + m2 + +time = at - bt + +print(time-k)" +p02714,s979745472,Wrong Answer,"n = int(input()) +s = input() +c = 0 +for k in range(n): + for j in range(n-1): + for i in range(n-2): + if s[k] != s[j] and s[j] != s[i] and s[i] != s[k]: + if j - k != k - j: + c += 1 +print(c)" +p03673,s328062915,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +ans = [] +for i in range(n): + if i%2 == 0: + ans.append(a[i]) + else: + ans.insert(0,a[i]) +for an in ans: + print(an,end=' ')" +p02714,s752847867,Accepted,"n = int(input()) +li = list(input()) + +R = li.count(""R"") +G = li.count(""G"") +B = li.count(""B"") + +cnt = 0 + +for i in range(n-1): + for j in range(i+1, n): + if 2*j - i > n-1: + continue + if li[i] != li[j]: + if li[2*j-i] != li[i] and li[2*j-i] != li[j]: + cnt += 1 +print(R*G*B - cnt)" +p03555,s498390027,Wrong Answer,"a = str(input()) +b = str(input()) +if a[1] == b[1] and a[0] == b[2] and a[2] == b[0]: + print(""Yes"") +else: + print(""No"")" +p02572,s242749899,Accepted,"from itertools import accumulate + +n = int(input()) +a = list(map(int, input().split())) + +sa = list(accumulate(a)) +mod = 10 ** 9 + 7 +ans = 0 +for i in range(n - 1): + ans += a[i] * (sa[-1] - sa[i]) + ans %= mod +print(ans) +" +p02819,s696003359,Accepted,"X=int(input()) + +def is_prime(n): + for i in range(2,n+1): + if i*i >n: + break + if n%i==0: + return False + return True + +for i in range(1000): + A=is_prime(X+i) + if A==True: + print(X+i) + break + " +p03069,s637627953,Wrong Answer,"N = int(input()) +S = input() +C = [0] * (N + 1) + +for i in range(N): + if S[i] == '#': + C[i + 1] = C[i] + 1 + else: + C[i + 1] = C[i] + + +# print(C) + +j = N +count = 0 +while j > 0: + jj = j - 1 + while jj >= 0 and C[jj] == C[j]: + jj -= 1 + + if jj >= 0 and jj < j - 1: + count += j - jj - 1 + + # print(j, jj) + j = jj + +print(count) +" +p02621,s953171719,Wrong Answer,"a=int(input()) +print(a+a**+a*a*a)" +p02688,s062074129,Accepted,"N,K = map(int,input().split()) +P = [0 for i in range(N)] +for i in range(K): + a = int(input()) + b = list(map(int,input().split())) + for j in range(a): + P[b[j]-1] = 1 +m = 0 +for i in range(N): + if P[i] == 0: + m += 1 +print(m)" +p02647,s897544338,Accepted,"import numpy as np +from numba import njit + +N, K = map(int, input().split()) +A = np.array((list(map(int, input().split()))), dtype=np.int64) + +@njit +def imos(A): + B = np.zeros(N, dtype=np.int64) + for i,x in enumerate(A): + a = max(0, i-x) + b = min(i+x, N-1) + B[a] += 1 + if b+1 <= N-1: + B[b+1] -= 1 + B = np.cumsum(B) + return B + +for i in range(K): + if i >= 50: + break + A = imos(A) +print(*A)" +p02732,s726763268,Wrong Answer,"import collections + +N=int(input()) +A=list(map(int, input().split())) +c = collections.Counter(A) +sum=0 +for i, j in c.items(): + sum+=j*(j-1)//2 + +for i in A: + b = c[i] + if b >= 2: + print(sum-b*(b-1)//2+(b-1)*(b-2)//2) + else: + print(0)" +p03208,s718825912,Wrong Answer,"n,k=map(int,input().split()) +l=[] +for i in range(n): + v=int(input()) + l.append(v) +tmp=l[n-1] +for j in range(n-k+1): + tmp=min(tmp,l[j+k-1]-l[j]) +print(tmp)" +p03779,s946148228,Wrong Answer,"x = int(input()) +t = int(x ** 0.5) +min_d = int(t * 0.5 * (t + 1)) +if min_d == x: + print(t) +elif (min_d + 2) <= x: + print(t + 2) +else: + print(t + 1) +" +p03221,s471982176,Accepted,"from collections import defaultdict + + +def create_id(p, o): + return str(p).zfill(6) + str(o).zfill(6) + + +n, m = [int(i) for i in input().split()] +db = defaultdict(list) +for i in range(m): + p, y = [int(i) for i in input().split()] + db[p].append((y, i)) + +ans = [None] * m +for p in db: + db[p].sort() + for i in range(len(db[p])): + ans[db[p][i][1]] = create_id(p, i + 1) +print(*ans, sep=""\n"") +" +p02760,s282277311,Accepted,"a=[list(map(int,input().split())) for i in range(3)] +n=int(input()) +b=[int(input()) for i in range(n)] +for i in range(3): + for j in range(3): + if a[i][j] in b: + a[i][j]=0 + +ans='No' +#tate +for i in range(3): + if a[0][i]+a[1][i]+a[2][i]==0: + ans='Yes' +#yoko +for i in range(3): + if sum(a[i])==0: + ans='Yes' +#naname +if a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[1][1]+a[2][0]==0: + ans='Yes' +print(ans)" +p03815,s116151061,Accepted,"z=int(input()) +#1と6の時は5 +#他はすべて6出せる。 +#つまり基本的には6,5,6,5,6,,,,と続けられます。 +#11で割ってあげた余りが6より大きいか小さいかで5を追加するか考える。 + +ans=z//11 +if z-(ans*11)==0: + print(ans*2) +elif z-(ans*11)>6: + print(ans*2+2) +else: + print(ans*2+1)" +p02958,s322638898,Wrong Answer,"N=int(input()) +list=input().split() +for all in list: + all=int(all) +flag=False +c=0 +x=""YES"" +leng=len(list) +for i in range(leng-1): + if list[i]>list[i+1]: + c=c+1 + t=list[i] + list[i]=list[i-1] + list[i-1]=t + print(list) + if c==2: + x=""NO"" + break +print(x)" +p02862,s186453379,Wrong Answer,"def fact(n,mod): + ret=1 + for i in range(2,n+1): + ret=(ret*i)%mod + return ret + +def pCq(p,q,mod): + pCq=1 + for i in range(q): + pCq*=p-i + pCq=pCq%mod + den=fact(q,mod) + inv=pow(den,mod-2,mod) + pCq=(pCq*inv)%mod + return pCq + +X,Y=map(int,input().split()) +MOD=10**9+7 +ans=0 +n,m=2*X-Y,2*Y-X +if n%3==0 and m%3==0: + n//=3 + m//=3 + ans+=pCq(m+n,min(m,n),MOD) +print(ans)" +p02695,s059475177,Accepted,"import itertools +N, M, Q = map(int, input().split()) +Qs = [list(map(int, input().split())) for _ in range(Q)] + +_max = 0 +for A in itertools.combinations_with_replacement(range(1, M+1), N): + score = sum([q[3] for q in Qs if A[q[1] - 1] - A[q[0] - 1] == q[2]]) + _max = score if _max < score else _max +print(_max)" +p03862,s054838260,Wrong Answer,"N,x=map(int,input().split()) +A=list(map(int,input().split())) +cnt=0 +for i in range(N-1,-1,-1): + gap=A[i]+A[i-1]-x + if gap>0: + cnt+=gap + A[i]-=gap +print(cnt)" +p03612,s269476429,Accepted," +url = ""https://atcoder.jp//contests/abc072/tasks/arc082_b"" + +def main(): + n = input() + p = list(map(int, input().split())) + count = 0 + for i, v in enumerate(p): + if i == len(p)-1 and i+1 == v: + count += 1 + break + if i+1 == v: + p[i] = p[i+1] + p[i+1] = v + count += 1 + print(count) + + +if __name__ == '__main__': + main() + +" +p03827,s285429664,Accepted,"n = int(input()) +s = list(input()) +x = 0 +ans = 0 +for i in range(n): + if s[i] == ""I"": + x += 1 + else: + x -= 1 + ans = max(ans,x) +print(ans)" +p03071,s882292451,Accepted,"A,B = map(int,input().split()) +if max(A,B) > min(A,B): + ans = max(A,B)*2-1 +else: + ans = A*2 +print(ans)" +p02795,s681673672,Accepted,"h = int(input()) +w = int(input()) +n = int(input()) + +c = 0 +count = 0 +while(True): + c += max(h,w) + count += 1 + if c>=n: + break + if h >= w: + w -= 1 + else: + h -= 1 + +print(count)" +p03095,s737409863,Accepted,"from collections import Counter +lim=10**9+7 +N=int(input()) +S=input() +d=Counter(S) +ans = 1 +for s in d.keys(): + ans = (ans*(d[s]+1))%lim + #print(ans) +print(ans-1)" +p02779,s220059978,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +if len(A)==len(set(A)): + print('Yes') +else: + print('No')" +p02724,s223090863,Wrong Answer,"X = int(input()) +d, v = divmod(X, 500) +print(d * 1000 + v * 5)" +p03017,s344247621,Accepted,"n,a,b,c,d = map(int, input().split()) +s = input() + +long_s = s[a-1:max(c,d)] +short_s = s[b-2:min(c,d)+1] +rocks = long_s.count(""##"") +change = short_s.count(""..."") + +if rocks >= 1: + print(""No"") +elif c > d and change == 0: + print(""No"") +else: + print(""Yes"")" +p02623,s503194982,Wrong Answer,"import bisect +N,M,K= map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +dpA = [0]*(N+1) +dpB = [0]*(M+1) + +for i in range(1,N+1): + dpA[i] = dpA[i-1] + A[i-1] + +for i in range(1,M+1): + dpB[i] = dpB[i-1] + B[i-1] + +ans = 0 +for i in range(1,N+1): + if dpA[i] > K: + continue + indexB = bisect.bisect_right(dpB, K - dpA[i]) + ans = max(ans, i + indexB - 1) + +print(ans)" +p03252,s888546538,Accepted,"from collections import defaultdict + +s = input() +t = input() + +in_deg = defaultdict(set) +out_deg = defaultdict(set) + +for es, et in zip(s, t): + out_deg[es].add(et) + in_deg[et].add(es) + +in_deg_mx = max(map(len, in_deg.values())) +out_deg_mx = max(map(len, out_deg.values())) + +if in_deg_mx <= 1 and out_deg_mx <= 1: + ans = ""Yes"" +else: + ans = ""No"" + +print(ans) +" +p04020,s610997783,Wrong Answer,"R = list() +L = list() +N = int(input()) +R.append(0) +for i in range(N): + k = int(input()) + L.append(k) + if k == 0: + R.append(len(L)) +R.append(N) +S = sum(L) +for i in range(len(R) - 1): + if sum(L[R[i] + 1 : R[i + 1]]) % 2 == 1: + S = S - 1 +print(S // 2) +" +p03419,s942517242,Wrong Answer,"N,M=map(int,input().split()) +N,M=min(N,M),max(N,M) + +if N==1: + print(M-2) +else: + print((N-2)*(M-2)) +" +p03219,s643669826,Accepted,"X,Y=map(int,input().split()) + +print(X+(Y//2))" +p02910,s134266906,Wrong Answer,"s = input() +for i in s: + if i == 'L' and s.index(i)%2 == 0: + print('No') + elif i == 'R' and s.index(i)%2 == 1: + print('No') + else: + print(""Yes"")" +p03774,s106209457,Accepted,"N,M=map(int,input().split()) +A=[] +B=[] +C=[] +D=[] +for i in range(N): + x,y=map(int,input().split()) + A.append(x) + B.append(y) +for i in range(M): + x,y=map(int,input().split()) + C.append(x) + D.append(y) +for i in range(N): + ans=[] + for j in range(M): + tmp=abs(A[i]-C[j])+abs(B[i]-D[j]) + ans.append(tmp) + T=len(ans) + for k in range(T): + if ans[k]==min(ans): + print(k+1) + break + " +p02912,s247073455,Accepted,"import heapq + +n, m = map(int, input().split()) +l = list(map(lambda x:int(x)*-1, input().split())) +heapq.heapify(l) + +for _ in range(m): + a = heapq.heappop(l) + heapq.heappush(l, a * (-1) // 2 * (-1)) + +print(sum(l)*-1)" +p03137,s821105066,Accepted,"n, m = map(int, input().split()) +x = list(map(int, input().split())) +x.sort() + +res = [] +for i in range(m-1): + res.append(x[i+1]-x[i]) +res.sort() + +ans = 0 +for i in range(m-n): + ans += res[i] +print(ans)" +p03127,s021929914,Accepted,"from fractions import gcd +N=int(input()) +A=list(map(int, input().split())) + +for i in range(N-1): + if i==0: + G=gcd(A[0],A[1]) + else: + G=gcd(G,A[i+1]) + +print(G) + + +" +p02683,s112517954,Accepted,"from itertools import combinations + +N, M, X = map(int, input().split()) +books = [] +for _ in range(N): + books.append(list(map(int, input().split()))) + +prices = [] +for i in range(1, N+1): + for to_buy in combinations(books, i): + _b = list(zip(*to_buy)) + _price = sum(_b[0]) + _points = _b[1:] + if all([True if sum(x) >= X else False + for x in _points]): + prices.append(_price) + +print(min(prices) if len(prices) else '-1')" +p03699,s333404852,Accepted,"N = int(input()) +S = [] +for _ in range(N): + S.append(int(input())) +S = sorted(S) + +ans = sum(S) +if ans % 10 != 0: + print(ans) +else: + for s in S: + if s % 10 != 0: + print(ans - s) + break + else: + print(0)" +p02802,s583009335,Wrong Answer,"N, M = map(int, input().split()) +PS = [input().split() for _ in range(M)] + +AC = [False] * (N+1) +ans = 0 +pena = 0 + +for p, s in PS: + p = int(p) + if AC[p]: + continue + elif s == ""WA"": + pena += 1 + elif s == ""AC"": + ans += 1 + AC[p] = True + + +print(ans, pena, sep=' ')" +p03456,s640035263,Accepted,"n = int(input().replace(' ', '')) +print('Yes' if n==int(n**0.5)**2 else 'No') +" +p03625,s770907045,Wrong Answer,"def main(): + N = int(input()) + A = list(map(int, input().split())) + A = sorted(A, reverse = True) + flag = True + num = 0 + ans = 1 + for i in range(N-1): + if A[i] == A[i+1] and flag: + ans *= A[i] + num += 1 + if num == 2: + break + flag = False + elif not flag: + flag = True + print(ans) +main() + + " +p02691,s068570743,Wrong Answer,"x = int(input()) +l = [int(x) for x in input().split()] +counter = 0 +for p in range(x): + if l[p] > x: + break + for q in range(p): + if p - q == l[p] + l[q]: + counter += 1 +print(counter)" +p03286,s628679248,Accepted,"def main(): + n = int(input()) + + if n == 0: + print(0) + exit() + + ans = '' + while n != 0: + if n % (-2) == 0: + ans = '0' + ans + else: + n -= 1 + ans = '1' + ans + + n /= (-2) + + print(ans) + +if __name__ == ""__main__"": + main() +" +p03817,s633772031,Accepted,"# 6>5>6>5>6>5... +import math +y=int(input()) +#print((55*x+9)//10=y) +print(((y*10-9)+54)//55)" +p02951,s382060635,Accepted,"A,B,C = map(int,input().split()) + +if C-(A-B) > 0: + print(C-(A-B)) +else: + print(""0"")" +p03827,s754734797,Accepted,"# Python3 (3.4.3) +import sys +input = sys.stdin.readline + +# ------------------------------------------------------------- +# function +# ------------------------------------------------------------- + + +# ------------------------------------------------------------- +# main +# ------------------------------------------------------------- +N = int(input()) +S = input().rstrip() + +ans,x = 0,0 +for s in S: + if s == ""I"": + x += 1 + else: + x -= 1 + ans = max(ans,x) + +print(ans)" +p02646,s310692391,Accepted,"a, v = map(int, input().split()) +b, w = map(int, input().split()) +t = int(input()) + +d = abs(a-b) +s = v - w + +if s <= 0: + print('NO') + exit(0) + +if (t * s) >= d: + print('YES') +else: + print('NO')" +p03000,s449991436,Accepted,"n,x = map(int,input().split()) +L = list(map(int,input().split())) +ans = 1 +l = 0 + +for i in range(n): + l += L[i] + if l <= x: + ans += 1 + +print(ans)" +p02987,s784861678,Wrong Answer,"S = list(input()) + +if S[0] == S[1] and S[2] == S[3]: + print(""Yes"") +elif S[0] == S[2] and S[1] == S[3]: + print(""Yes"") +elif S[0] == S[3] and S[1] == S[2]: + print(""Yes"") +else: + print(""No"")" +p02909,s274791565,Accepted,"S = input() +weather = ['Sunny', 'Cloudy', 'Rainy'] +next = weather.index(S) + 1 +if S == 'Rainy': + print(weather[0]) +else: + print(weather[next])" +p03720,s962639132,Accepted,"import collections +N,M = map(int, input().split()) + +A = [list(map(int, input().split())) for i in range(M)] + +c = collections.Counter(sum(A,[])) + +for i in range(1, N+1): + print(c[i])" +p03251,s794096434,Wrong Answer,"n, m, x, y = map(int, input().split()) +xx = tuple(map(int, input().split())) +yy = tuple(map(int, input().split())) + +if x > y: + print('War') + exit(0) + +if min(yy) - max(xx) > 1: + print(""No War"") +else: + print(""War"")" +p02814,s409982177,Accepted,"from functools import reduce +from fractions import gcd + +def lcm(a,b): + return a*b//gcd(a,b) + +n,m = map(int, input().split()) +a = list(map(int, input().split())) +b = [n//2 for n in a] + +l = reduce(lcm,b) + +for i in range(n): + if l//b[i]%2 == 0: + print(0) + break +else: + print(m//l//2+m//l%2) +" +p03284,s033003021,Accepted,"print(1*(eval(input().replace(' ','%'))>0))" +p03625,s625758217,Accepted,"import collections +N = int(input()) +A = list(map(int, input().split())) + +x = 0 +y = 0 +selection = sorted(list(set(A)))[::-1] +c = collections.Counter(A) +for i in selection: + if c[i] >= 4: + if x == 0: + x = i + if y == 0: + y = i + elif c[i] >= 2: + if x == 0: + x = i + elif y == 0: + y = i + if x != 0 and y != 0: + print(x * y) + exit() + +print(x * y)" +p03565,s944238713,Wrong Answer,"s = list(input()) +t = list(input()) +ls = len(s) +lt = len(t) +ans = [""UNRESTORABLE""] + +if ""?"" not in set(s): + print("""".join(s)) + +for i in range(ls-lt+1): + f = True + for j in range(lt): + f &= (s[i + j] == ""?"" or s[i + j] == t[j]) + + if f: + ans = s.copy() + for j in range(lt): + ans[i+j] = t[j] + + +print("""".join(ans).replace(""?"", ""a"")) +" +p02582,s980719749,Wrong Answer,"S = input() + +if S ==""SSS"": + print(0) +elif S[1] == ""S"": + print(1) +elif S == ""RRR"": + print(3) +else: + print(2)" +p02785,s655770287,Accepted,"N,K = [int(i) for i in input().split()] +A = [int(i) for i in input().split()] +A.sort(reverse=True) +B = 0 +ans = 0 +for a in A: + if Btotal): + print('No') +else: + print('Yes')" +p03324,s329379067,Accepted,"d,n=map(int,input().split()) +ans=n*100**d +if n!=100: + print(ans) +else: + print(ans+1*100**d)" +p02768,s457368613,Wrong Answer,"n,a,b = map(int, input().split()) + +k = n +h = 1 +sum = 0 +while n >= h : + if h !=a and h != b: + sum += k + k = k*(n-h)/(1+h) + h += 1 + +print(sum%(10**9+7)) +" +p02823,s813099010,Wrong Answer,"N, A, B = input().split(' ') +N = int(N) +A = int(A) +B = int(B) +if (B-A)%2 == 0: + Count = (B-A)/2 + print(int(Count)) +else: + if (N-A)<(B-1): + print(int(N-A)) + else: + print(int(B-1)) +" +p03038,s637690312,Accepted,"N,M = map(int,input().split()) + +A = list(map(int,input().split())) +A.sort(reverse=True) +BC = [] +for _ in range(M): + B, C = (int(x) for x in input().split()) + BC.append([B, C]) +BC = sorted(BC, key=lambda x: -x[1]) + +index = 0 + +ans = 0 + +while index < M and len(A) and A[-1] < BC[index][1]: + b, c = BC[index] + count = 0 + while len(A) and A[-1] < c and count < b: + A.pop() + ans += c + count += 1 + index += 1 +print(sum(A)+ans)" +p03695,s593408612,Wrong Answer,"n=int(input()) +A=list(map(int,input().split())) +B=[] +C=[] +for i in range(n): + for j in range(8): + if (j*400)<=A[i]<((j+1)*400): + B.append(j) + if 3200<=A[i]: + C.append(i+100) +print(len(set(B)),min(len(set(B))+len(C),8)) +" +p02646,s513910534,Accepted,"a, v = map(int, input().split()) +b, w = map(int, input().split()) +t = int(input()) +if abs(a-b)+w*t <= v*t: + print(""YES"") +else: + print(""NO"")" +p02627,s369392806,Wrong Answer,"a = input() +if a.islower: + print('a') +else: + print('A')" +p04044,s032852739,Wrong Answer,"from sys import stdin +input = stdin.readline + +L, N = map(int, input().split()) +D = [] + +for i in range(N): + D.append(input().strip()) + +D.sort() + +print(''.join(D))" +p02833,s827462976,Accepted,"N = int(input()) + +if N % 2 == 0: + count = 10 + amount_5 = 0 + while count <= N: + amount_5 += N // count + count = count * 5 +else: + amount_5 = 0 + +print(amount_5)" +p02789,s741942501,Accepted,"n, m = list(map(int, input().split())) +if n*n == m*n: + print('Yes') +else: + print('No')" +p03220,s628465561,Accepted,"N = int(input()) +T, A = map(int, input().split()) +H = list(map(int, input().split())) + +t = [0 for i in range(N)] +diff = [0 for i in range(N)] + +for i in range(N): + t[i] = T - 0.006*H[i] + diff[i] = abs(t[i] - A) + +print(diff.index(min(diff))+1)" +p02971,s345388311,Accepted,"n = int(input()) +a1 = int(input()) +a2 = int(input()) +if a1 >= a2: + maxa1 = a1 + maxa2 = a2 + res = 0 +else: + maxa1 = a2 + maxa2 = a1 + res = 1 + +for i in range(2, n): + a_ = int(input()) + if maxa1 <= a_: + maxa2 = maxa1 + maxa1 = a_ + res = i + elif maxa2 <= a_: + maxa2 = a_ + +for i in range(n): + if i == res: + print(maxa2) + else: + print(maxa1)" +p03962,s760106931,Wrong Answer,"a, b, c = map(int, input().split()) + +if a == b: + if b == c: + print(1) + else: + print(2) +elif b == c: + print(2) +else: + print(3)" +p02552,s497754703,Accepted,"n = int(input()) + +if(n==0): + print(1) +else: + print(0)" +p03086,s240232985,Wrong Answer,"s = list(input()) +ans = [] +for mozi in s: + if(mozi == ""A"" or mozi == ""G"" or mozi == ""C"" or mozi == ""T""): + ans.append(mozi) + else: + break +print("""".join(ans))" +p02577,s029788806,Wrong Answer,"#176-B + +N = input() +while len(N) > 1: + sum = 0 + for i in range(1,len(N)+1): + sum += int(N[-i]) + N = str(sum) + +if N == 9: + print('Yes') +else: + print('No') +" +p02939,s067104751,Wrong Answer,"from sys import stdin + +s = stdin.readline().rstrip() +N = len(s) + +if N == 1: + print(1) + exit() +elif N == 2: + if s[0] == s[1]: + print(1) + exit() + else: + print(2) + exit() + +dp = [0]*N +dp[0] = 1 +dp[1] = 1 +for i in range(2,N): + if s[i] == s[i-1]: + dp[i] = dp[i-3] + 2 + else: + dp[i] = dp[i-1] + 1 + +print(dp[N-1])" +p02801,s747962238,Wrong Answer,"a =[chr(ord('a') + i) for i in range(26)] +a.append(""a"") +c = input() +print(a[a.index(c)]) + +" +p03419,s637788712,Accepted,"N, M = list(map(int, input().split())) +result = 0 +if N == 1 and M == 1: + result = 1 +elif N == 1: + result = M - 2 +elif M == 1: + result = N - 2 +else: + result = (N - 2) * (M - 2) +print(result)" +p02660,s591308655,Accepted,"n = int(input()) + + +def prime_factorize(n): + res = [] + for i in range(2, int(n ** 0.5) + 1): + while n % i == 0: + res.append(i) + n //= i + if n != 1: + res.append(n) + return res + + +fac = prime_factorize(n) + +from collections import Counter + +ctr = Counter(fac) + +ans = 0 +for val in ctr.values(): + cnt = 1 + while val - cnt >= 0: + ans += 1 + val -= cnt + cnt += 1 + + +print(ans) +" +p03719,s874228005,Accepted,"a,b,c = map(int, input().split()) +if c >= a and c <= b: + print('Yes') +else: + print('No')" +p02675,s657352765,Wrong Answer,"a = input()[0] +if a in ""24579"": + print(""hon"") +elif a in ""0168"": + print(""pon"") +else: + print(""bon"")" +p03673,s474008720,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +ki=a[0::2] +ki2=[] +for i in ki[::-1]: + ki2.append(i) +guu=a[1::2] +guu2=[] +for i in guu[::-1]: + guu2.append(i) + +if n%2==0: + kotae=guu2+ki +else: + kotae=ki2+guu + +print(kotae)" +p02708,s236037019,Wrong Answer,"list = input().split() +N = int(list[0]) +K = int(list[1]) +i = K +s = 0 + +def sum(a,b): + i=0 + i = (a + b)*(b - a + 1)/2 + return i + +while i <= N + 1: + #print(sum(N-i+1,N) + sum(0,i-1)) + s = s + sum(N-i+1,N) - sum(0,i-1) + 1 + i += 1 +print(s % (10**9+7))" +p02689,s620714195,Accepted,"n,m = map(int, input().split()) + +h = [int(x) for x in input().split(' ')] +o = ['Good'] * n + +road = [] +for i in range(m): + a,b = map(int, input().split()) + + if(h[a-1] > h[b-1]): + o[b-1] = 'Bad' + elif(h[b-1] > h[a-1]): + o[a-1] = 'Bad' + else: + o[a-1] = o[b-1] = 'Bad' + +print(o.count('Good'))" +p02556,s159234293,Wrong Answer,"n = int(input()) +arr = [] +for i in range(n): + arr.append(tuple(map(int, input().split()))) +arr.sort(key = sum) +mx = 0 +for i in arr[1:]: + if mx <= abs(i[0] - arr[0][0]) + abs(i[1] - arr[0][1]): + mx = abs(i[0] - arr[0][0]) + abs(i[1] - arr[0][1]) +print(mx) +" +p02786,s845000657,Accepted,"H = int(input()) +#N,K,M= map(int,input().split()) +#A =list(map(int,input().split())) +#L = [list(map(str,input().split())) for i in range(N)] +h = H +count = 0 +while h: + h = h//2 + count += 1 + +print(2**count-1) +" +p02899,s615845513,Accepted,"n = int(input()) +a = list(map(int,input().split())) +ans = [0]*n +for i,j in enumerate(a,start=1): + ans[j-1] = i +for i in range(n): + print(ans[i],' ', end='') +" +p02829,s088029201,Accepted,print 6 - int(raw_input()) - int(raw_input()) +p03289,s646208172,Accepted,"S = input() +flag = True +cflag = False +for i, c in enumerate(S): + if i == 0: + if c == ""A"": + continue + else: + flag = False + break + + if c == ""C"" and 2 <= i < len(S)-1: + if cflag: + flag = False + cflag = True + + elif not (97 <= ord(c) <= 122): + flag = False + + +if flag and cflag: + print(""AC"") +else: + print(""WA"") +" +p03624,s900932408,Wrong Answer,"data=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t', + 'u','v','w','x','y','z',] +s=list(input()) +t=sorted(s) +i=0 +while (t[i]==data[i] and i<25): + i=i+1 +if i<25: + print(data[i]) +else: + print('None')" +p03328,s639923586,Accepted,"a,b=map(int,input().split()) +ans=0 +for i in range(b-a): + ans+=i +print(ans-a) +" +p02712,s174311074,Accepted,"n = int(input()) +import numpy as np +d = np.array(range(1,n+1)) +print(np.sum(d) - np.sum(d[d%3==0]) - np.sum(d[d%5==0]) + np.sum(d[d%15==0]))" +p02594,s924899463,Wrong Answer,"n = int(input()) +if n >= 25: + print('Yes') +else: + print('No')" +p02601,s956438685,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) + +cnt = 0 +if A >= B: + while A >= B: + B *= 2 + cnt += 1 + +if B >= C: + while B >= C: + C *= 2 + cnt += 1 + +if cnt <= K: + print('Yes') +else: + print('No')" +p02554,s044135574,Accepted,"n = int(input()) +mod = 10**9 + 7 +print((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod)" +p03359,s529776542,Wrong Answer,"a, b = map(int, input().split()) +print(min(a, b))" +p02951,s564379087,Accepted,"a = list(map(int, input().split())) +x = a[0] +y = a[1] +z = a[2] + +if y + z > x: + print(z-x+y) +else: + print(0)" +p02633,s479445116,Accepted,"import math + +def lcm(x, y): + return (x * y) // math.gcd(x, y) + +x = int(input()) +print(lcm(x, 360)//x)" +p02596,s462669106,Accepted,"K = int(input()) + +N = 0 +count = -1 + +for i in range(K): + N = (N*10+7)%K + if N == 0: + count = i+1 + break + +print(count) +" +p02547,s056825648,Accepted,"def main(): + n = int(input()) + + cont = 0 + for _ in range(n): + a, b = map(int, input().split()) + if a == b: + cont += 1 + if cont >= 3: + print('Yes') + return + else: + cont = 0 + print('No') + + +if __name__ == '__main__': + main() +" +p03293,s826964526,Accepted,"s = input() +t = input() +for i in range(len(s)): + s = s[-1] + s[0:-1] + if s == t: + print(""Yes"") + exit() +print(""No"")" +p03745,s911364169,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +ans = 0 +i = 0 +while i < n: + while i+1 < n and a[i] == a[i+1]: + i += 1 + if i+1 < n and a[i] < a[i+1]: + while i+1 < n and a[i] <= a[i+1]: + i += 1 + elif i+1 < n and a[i] > a[i+1]: + while i+1 < n and a[i] >= a[i+1]: + i += 1 + ans += 1 + i += 1 +print(ans) + + +" +p03854,s773850422,Accepted,"import re +print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" +p02615,s089712740,Accepted,"def main(): + n=int(input()) + A=list(map(int,input().split())) + A.sort(reverse=True) + if n%2==0: + ans=sum(A[:(n+1)//2])*2-A[0] + else: + ans=sum(A[:(n+1)//2])*2-A[0]-A[n//2] + print(ans) + +if __name__=='__main__': + main()" +p02743,s005640049,Accepted,"from decimal import * +getcontext().prec=1000 +a,b,c=map(int,input().split()) +A=Decimal(a)**Decimal(""0.5"") +B=Decimal(b)**Decimal(""0.5"") +C=Decimal(c)**Decimal(""0.5"") +D= Decimal(10) ** (-100) +if A+B+D>j&1 for j in range(N)]]).T + temp = (CA*bit).sum(axis=0) + if (temp[1:]>=X).all(): + ans = min(ans,temp[0]) +print(ans if ans!=float('INF') else -1) +" +p03339,s875038674,Accepted,"N = int(input()) +S = input() +L = [0]*(N+1) +for i in range(N): + if S[i]==""E"": + L[i+1] = L[i]+1 + else: + L[i+1] = L[i] +print(min(i-L[i]+L[N]-L[i+1] for i in range(N)))" +p02753,s814894467,Wrong Answer,"S = input() + +if S.count('A') or S.count('B') == 3: + print('No') +else: + print('Yes')" +p02576,s769382910,Accepted,"n, x, t=map(int,input().split()) + +if n % x == 0: + result = int(n / x * t) + +else: + result = int((n // x + 1) * t) + +print(result) +" +p02900,s244649970,Accepted,"import fractions + +A, B = map(int, input().split()) + +g = fractions.gcd(A, B) +d = [] +p = [] + +for i in range(1,int(pow(g, 0.5))+1): + if g % i == 0: + d.append(i) + if i != g//i: + d.append(g//i) + +for i in d: + s = 0 + for j in range(1,int(pow(i, 0.5))+1): + if i % j == 0: + s += 1 + + if s == 1: + p.append(i) + +print(len(p)) +" +p03379,s123776525,Accepted,"N = int(input()) +X = list(map(int, input().split())) +Y = sorted(X) +a = Y[N // 2 - 1] +b = Y[N // 2] +for i in range(N): + if X[i] <= a: + print(b) + else: + print(a)" +p04011,s417151679,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +if n > k: + print(k*x+(n-k)*y) +else: + print(n*x) +" +p03095,s391613416,Accepted,"from collections import Counter +n = int(input()) +s = Counter(input()) +mod = 10 ** 9 + 7 + +x = 1 +for v in s.values(): + x *= (v+1) +ans = x - 1 +print(ans%mod)" +p03317,s004252020,Accepted,"from math import ceil + + +def main(): + length, section_range = map(int, input().split("" "")) + numbers = list(map(int, input().split("" ""))) + print(ceil((length - 1) / (section_range - 1))) + + +if __name__ == '__main__': + main()" +p02759,s853508551,Accepted,print(0--int(input())//2) +p03679,s279923967,Accepted,"a,b,c=map(int,input().split()) +if a=b>=c: + print(""delicious"") +else: + print(""safe"")" +p02802,s798027021,Accepted,"N,M = map(int,input().split()) +wa_list= [0]*(N+2) +ac_list=[-1]*(N+2) +for i in range(M): + p,a = map(str,input().split()) + p = int(p) + if a =='WA': + wa_list[p]+=1 + if a =='AC' and ac_list[p] == -1: + ac_list[p]+=(wa_list[p]+1) +count = 0;count2 = 0 +for i in ac_list: + if i>=0: + count+=1 + count2+=i +print(count,count2) + " +p03417,s747299527,Accepted,"a,b=map(int,input().split()) +print(abs(a*b-(a+b)*2+4))" +p02952,s473415071,Accepted,"N = int(input()) + +ans = 0 +for i in range(1,N+1): + if len(str(i))%2 == 1: + ans += 1 +print(ans)" +p02861,s489755903,Wrong Answer,"n = int(input()) +l, l1, l2 = list(""""), list(""""), list("""") +for i in range(n): + x, y = map(int, input().split()) + l1.append(x) + l2.append(y) +for i in range(n - 1): + for j in range(i + 1, n): + l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5) +print(l) +print('{:.10f}'.format(2 * sum(l) / len(l)))" +p03221,s071240663,Accepted,"N, M = map(int, input().split()) +NPM = [[0] * 3 for _ in range(M)] +for i in range(M): + p, m = map(int, input().split()) + NPM[i][0] = i + NPM[i][1] = p + NPM[i][2] = m + +NPM.sort(key = lambda x:(x[2])) + +##print(NPM) +city_num = [0] * N +ans_list = [""""] * M +for i in range(M): + city_num[NPM[i][1]-1] += 1 + + ans_list[NPM[i][0]] = ""{:0>6}{:0>6}"".format(NPM[i][1], city_num[NPM[i][1]-1]) + +for i in range(M): + print(ans_list[i])" +p03625,s199763829,Wrong Answer,"def main(): + from collections import Counter + n, *a = map(int, open(0).read().split()) + b = Counter(a) + *c, = map(lambda x: tuple(x), b.items()) + c.sort(key=lambda x: x[0], reverse=True) + + ans = 1 + count = 0 + for (k, v) in c: + if v >= 2: + ans *= k + count += 1 + if count == 2: + break + if count < 2: + print(0) + else: + print(ans) + + +if __name__ == '__main__': + main() +" +p02700,s876264571,Accepted,"import math + +a,b,c,d = map(int,input().split()) + +num1 = math.ceil(c / b) +num2 = math.ceil(a / d) + +if num1 <= num2: + print('Yes') +else: + print('No') +" +p02675,s728467499,Wrong Answer,"n = int(input()) + +if n == 2 or n == 4 or n == 5 or n == 7 or n == 9: + print('hon') +elif n == 3: + print('bon') +else: + print('pon')" +p02753,s568545234,Accepted,"S=input() +s=set(S) +if len(s)==2: + print(""Yes"") +else: + print(""No"") +" +p02696,s100271778,Wrong Answer,"import math + + +def solve(): + A, B, N = map(float, input().split()) + + ans = 0 + div_ab = A/B + div_1b = 1/B + init_1 = (max(1, int(N)-100000)*A)/B + init_2 = max(1, int(N)-100000)/B + start = max(1, int(N)-100000) + + for i in range(max(1, int(N)-100000), int(N) + 1): + ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans) + + print(int(ans)) + + +if __name__ == '__main__': + solve() +" +p02618,s008889086,Accepted,"import sys +input=sys.stdin.readline + +D=int(input().rstrip('\n')) +cs=[int(x) for x in input().rstrip('\n').split()] +for i in range(D): + Ss = [int(x) for x in input().rstrip('\n').split()] + print(Ss.index(max(Ss))+1)" +p03261,s164640835,Accepted,"n=int(input()) +l=[input() for _ in range(n)] +b=l[0][-1] +for w in l[1:]: + if l.count(w)>1 or not w[0]==b: + print('No') + exit() + b=w[-1] +print('Yes') +" +p02779,s032409636,Accepted,"N = int(input()) +A_ls = input().split(' ') +rst = set() +for i in A_ls: + rst.add(i) +if len(rst) == N: + print('YES') +else: + print('NO')" +p02682,s466743431,Wrong Answer,"A, B, C, K = map(int, input().split()) + +if A >= K: + print(K) +elif A + B >= K: + print(A) +else: + print(max(A + B - C, -1 * K))" +p03971,s427709204,Accepted,"N, A, B = list(map(int, input().split())) +S = input() +passed_num = 0 +passed_foreigners_num = 0 +for i in S: + if passed_num < A + B: + if i == 'a': + print('Yes') + passed_num += 1 + elif i == 'b' and passed_foreigners_num < B: + print('Yes') + passed_num += 1 + passed_foreigners_num += 1 + else: + print('No') + else: + print('No')" +p02630,s917214495,Wrong Answer,"def main(): + N = int(input()) + A = list(map(int, input().split())) + Q = int(input()) + BC = [list(map(int, input().split())) for i in range(Q)] + print(BC) + + for i in range(Q): + B, C = BC[i][0], BC[i][1] + for j in range(len(A)): + if A[j] == B: + A[j] = C + print(sum(A)) + + +if __name__ == ""__main__"": + main() +" +p03319,s358889784,Accepted,"n,k = map(int,input().split()) +a = list(map(int,input().split())) +ans = (n-1)//(k-1) + 1*((n-1)%(k-1)!=0) +print(ans) +" +p02691,s849746349,Accepted,"from collections import Counter + +N = int(input()) +As = list(map(int, input().split())) + +Bs = [i-A for i, A in enumerate(As)] +cnt = Counter(Bs) + +ans = 0 +for L in range(N): + AL = As[L] + cnt[L-AL] -= 1 + ans += cnt[L+AL] + +print(ans) +" +p03377,s519488118,Accepted,"a,b,x=map(int,input().split()) +if a<=x and x<=a+b: + print(""YES"") +else: + print(""NO"")" +p03773,s091603705,Accepted,"a,b = map(int,input().split()) +print((a+b)%24)" +p03219,s949804493,Wrong Answer,"X, Y = map(int, input().split()) +print(X+Y/2) " +p03131,s775702832,Accepted,"k,a,b = map(int,input().split()) +if a+1 >= b: + print(1+k) +else: + if k // (a+1) == 0: + print(1+k) + else: + k -= a+1 + ans = b + if k%2 == 0: + print(ans+k//2*(b-a)) + else: + print(ans+k//2*(b-a)+1) +" +p03160,s286385452,Accepted,"N = int(input()) +h = list(map(int, input().split())) +ans = [0] * N +ans[0] = 0 +ans[1] = abs(h[0]-h[1]) +for i in range(2, N): + ans[i] = min(ans[i-1]+abs(h[i-1]-h[i]), ans[i-2]+abs(h[i-2]-h[i])) +print(ans[-1])" +p04005,s687762176,Accepted,"a,b,c = map(int,input().split()) +if any([i%2 == 0 for i in (a,b,c)]): + print(0) +else: + print(min(b*c,c*a,a*b))" +p02842,s944012537,Wrong Answer,"#B - Tax Rate +import math +N = int(input()) + +result = ':(' +for i in range(N): + if math.floor(i * 1.08) == N:#小数点以下切り捨て + result = i +print(result)" +p03481,s915961505,Accepted,"X,Y = map(int,input().split()) +a = 1 +x = X +mul = min(max(X,2),2) +cnt = 1 +for i in range(10000): + x *= mul + if x>Y: + cnt+=i + break +print(cnt)" +p02879,s013920397,Accepted,"a, b = map(int, input().split()) +if a > 9 or b > 9: + print(-1) +else: + print(a*b)" +p03804,s123355214,Accepted,"n,m = map(int, input().split()) +a = [str(input()) for i in range(n)] +b = [str(input()) for i in range(m)] +for i in range(0,n-m+1): + for j in range(0,n-m+1): + ans = 1 + for k in range(0,m): + for l in range(0,m): + if a[i+k][j+l] != b[k][l]: + ans = 0 + break + if ans == 1: + print('Yes') + exit() +print('No') +" +p03665,s621750334,Accepted,"n, p = map(int, input().split()) +even_count = sum(a % 2 == 0 for a in map(int, input().split())) +odd_count = n - even_count +if odd_count == 0: + print(0 if p == 1 else 2 ** even_count) +else: + print((2 ** even_count) * (2 ** (odd_count - 1)))" +p03745,s756694383,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +cnt = 1 +inc = False +dec = False +p = A.pop(0) + +for Ai in A: + if (not inc) and (not dec): + if Ai < p: + dec = True + elif Ai > p: + inc = True + elif inc: + if Ai < p: + cnt += 1 + inc = False + elif dec: + if Ai > p: + cnt += 1 + dec = False + p = Ai + +print(cnt)" +p02702,s115015863,Accepted,"s = input()[::-1] + +dataset = [0]*2019 +dataset[0] = 1 + +n = 0 +d = 1 + +for i in s: + n += int(i) * d + a = n % 2019 + dataset[a] += 1 + d *= 10 + d %= 2019 + +count = 0 +for i in dataset: + count += i * (i-1) // 2 + +print(count)" +p03408,s113100488,Wrong Answer,"a=int(input()) +b,d,e=[],[],[] +for i in range(a): + b.append(str(input())) +c=int(input()) +up,down=0,0 +for j in range(c): + d.append(str(input())) +for k in set(b): + up+=b.count(k) + down+=d.count(k) + e.append(up-down) + up,down=0,0 +print(max(e))" +p03487,s025029364,Accepted,"from collections import defaultdict +N = int(input()) +A = input().split() +dic = defaultdict(int) +for a in A: + dic[int(a)] += 1 +ans = 0 +for i, v in dic.items(): + if i < v: + ans += v - i + elif i > v: + ans += v +print(ans) +" +p02953,s902203865,Accepted,"N = int(input()) +H = list(map(int,input().split())) +D = 0 + +for n in range(N): + if D>H[n]: + print(""No"") + exit() + elif D<=H[n]-1: + H[n]-=1 + D=H[n] + +print(""Yes"") " +p03339,s513054449,Wrong Answer,"N = int(input()) +S =list(input()) +ans = N +W = 0 +E = S.count('E') + +for i in S: + ans = min(ans, W+E) + if i == 'W': + W +=1 + else: + E -= 1 +print(ans)" +p03221,s844756667,Accepted,"import sys +input = sys.stdin.buffer.readline + +N, M = map(int,input().split()) +town = [[] for _ in range(N)] +ans = [0] * M + +for i in range(M): + a, b = map(int,input().split()) + town[a-1].append((b,i)) + +for i in range(N): + town[i].sort() + for k in range(len(town[i])): + index = town[i][k][1] + t = town[i][k][0] + ans[index] = str(i+1).zfill(6) + str(k+1).zfill(6) + +for i in ans: + print(i)" +p02835,s936156083,Accepted,"print('win' if sum(map(int,input().split())) <= 21 else 'bust')" +p03126,s458152921,Accepted,"import sys +import copy +import math +import itertools +import numpy as np +l = [int(c) for c in input().split()] +N = l[0] +M = l[1] +KA = [list(map(int,input().split())) for c in range(N)] + +F = [0]*M + +for i in range(N): + for j in range(1,KA[i][0]+1): + F[KA[i][j]-1]+=1 +print(F.count(N))" +p02688,s223150200,Accepted,"N, K = map(int, input().split()) +sunuke = [0] * N +for i in range(K): + d = int(input()) + A = list(map(int, (input().split()))) + for j in range(d): + sunuke[A[j]-1] = 1 +ans = N - sum(sunuke) +print(ans)" +p03815,s450847382,Wrong Answer,"x = int(input()) + +#2回で3~11を作れる +count = 0 +if x == 7: + count=2 + x = 0 + +count += (x//11)*2 +x = x%11 +if x==0: + count += 0 +elif x>6: + count+=2 +elif x<6: + count += 1 + + +print(count)" +p04011,s862247213,Accepted,"N = int(input()) + +K = int(input()) + +X = int(input()) + +Y = int(input()) + +if N <= K: + print(X*N) +else: + print(X*K + Y*(N-K))" +p02713,s549699231,Wrong Answer,"k=int(input()) +l=list(range(1, k+1)) +import itertools +import math +from functools import reduce +def gcd(*numbers): + return reduce(math.gcd, numbers) +ans=0 +for v in itertools.combinations_with_replacement(l, 3): + ans+=gcd(*v) +print(ans)" +p02933,s633831666,Wrong Answer,"a = int(input()) +s = input() +if a>3219: + print(s) +else: + print(""red"")" +p04031,s610301893,Accepted,"N = input() +A = list(map(int, input().split())) + +num = round(sum(A) / len(A)) +cost = [(a - num)**2 for a in A] + +print(sum(cost)) +" +p03796,s975056251,Accepted,"N = int(input()) + +ans = 1 +MOD = 10**9 + 7 + +for i in range(1, N+1): + ans *= i + ans %= MOD + +print(ans) +" +p02958,s373666040,Wrong Answer,"n = int(input()) +p = list(map(int,input().split())) +c = 0 +for i in range(1,n+1): + if p != i: + c += 1 +if c == 2 or c == 0: + print(""YES"") +else: + print(""NO"")" +p03371,s557351442,Wrong Answer,"a, b, c, x, y = (int(each) for each in input().split()) + +cost = [x*a + y*b] +for i in range(max(x, y)*2+1): + numofabpizza = i*2 + numofapizza = max(0, (x-numofabpizza)) + numofbpizza = max(0, (y-numofabpizza)) + # print(numofapizza, numofbpizza, numofabpizza) + cost.append(numofapizza*a + numofbpizza*b + (2*numofabpizza)*c) +# print(cost) +print(min(cost))" +p02726,s153529698,Accepted,"n, x, y = list(map(int, input().split())) + +dist = [0 for _ in range(n - 1)] + +for i in range(n): + for j in range(i + 1, n): + k = min(j - i, + abs(x - 1 - i) + 1 + abs(y - 1 - j)) + dist[k - 1] += 1 + +for k in range(1, n): + print(dist[k - 1]) +" +p03345,s982221691,Accepted," +A, B, C, K = map(int, input().split()) +r = K % 2 +if r == 0: + ans = A - B +else: + ans = B - A + +if abs(ans) > 10**18: + print('Unfair') +else: + print(ans)" +p02641,s768030105,Wrong Answer,"# coding: utf-8 +# Your code here! +n,m=map(int,input().split()) +a=list(map(int,input().split())) +if len(a)==0: + print(n) +else: + a.sort() + if n not in a: + print(n) + else: + cnt=0 + for i in range(101): + if i in a: + continue + elif abs(cnt-n)>abs(i-n): + cnt=i + print(cnt) + +" +p03274,s704470697,Accepted,"n,k = map(int, input().split()) + +lis = sorted(list(map(int, input().split()))) + +ans = [] +for i in range(n-k+1): + a = lis[i] + b = lis[i+k-1] + ans.append(min(abs(a)+abs(b-a),abs(b)+abs(a-b))) + +print(min(ans))" +p02640,s496258484,Wrong Answer,"x,y= map(int,input().split()) + +for i in range(1,101): + if x - i == 0: + break + else: + for j in range(1,x - i + 1): + if 2 * i + 4 * j == y: + print(""Yes"") + exit() +print(""No"") + " +p03387,s149201208,Wrong Answer,"a = list(map(int,input().split())) +a.sort() +b = a[2] - a[1] +c = a[2] - a[0] +ans = 0 + +ans += b + +if (c-b) % 2 == 0: + ans += (c-b)//2 +elif (c-b) % 2 == 0: + ans += (c-b)//2 + 2 + +print(ans)" +p03611,s037414207,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +num = [0]*(10**5+1) +for i in a: + if i-1 >= 0: + num[i-1] += 1 + num[i] += 1 + if i+1 <= N: + num[i+1] += 1 + +print(max(num))" +p03487,s471526734,Accepted,"from collections import Counter + +n = int(input()) +al = list(map(int, input().split())) +c = Counter(al) + +ans = 0 +for k, v in c.items(): + if k == v: + continue + elif k > v: + ans += v + else: + ans += v-k + +print(ans) +" +p03012,s794784932,Accepted,"n = int( input() ) +s = list( map( int, input().split() )) + +total = sum( s ) + +minimum = total +part1 = total +for i in range( len( s ) ): + part1 = part1 - s[ i ] + minimum = min( minimum, abs( total - 2 * part1 )) + if total - 2 * part1 >= 0: + break + +print( minimum ) +" +p03324,s971853659,Accepted,"d, n = map(int, input().split()) + +if(d == 0): + print(n if n < 100 else n+1) +else: + print(100**d * n if n < 100 else 100**d * (n+1))" +p02866,s584654309,Wrong Answer,"from itertools import groupby +inputs = open(0).readlines() + +n = int(inputs[0]) +*D, = map(int, inputs[1].split()) +D.sort() +mod = 998244353 + +keys, nodes = [], [] +for k, g in groupby(D): + keys.append(k) + nodes.append(len(list(g))) + +if nodes[0] != 1 or any(i != k for i, k in enumerate(keys)): + print(0) +else: + patterns = [1] + for n0, n1 in zip(nodes, nodes[1:]): + patterns.append(patterns[-1] * pow(n0, n1, mod) % mod) + print(patterns[-1])" +p02556,s591810217,Wrong Answer,"N = int(input()) +xs = [] +ys = [] +for _ in range(N): + x,y = map(int,input().split()) + xs.append(x) + ys.append(y) +fxys = [] +for i in range(N): + x = xs[i] + y = ys[i] + fxys.append((x-y, x+y)) +m = 0 +for d in [0, 1]: + mx = 0 + mi = float(""inf"") + for i in range(N): + mx = max(fxys[i][d], mx) + for i in range(N): + mi = min(fxys[i][d], mi) + m = max(mx-mi, m) +print(m)" +p03557,s636251791,Accepted,"import numpy as np +N = int(input()) +A = np.array(list(map(int, input().split()))) +B = np.array(list(map(int, input().split()))) +C = np.array(list(map(int, input().split()))) + +A.sort() +B.sort() +C.sort() + +cnt_A = np.searchsorted(A,B) +cnt_C = N - np.searchsorted(C,B,side='right') +ans = (cnt_A*cnt_C).sum() + +print(ans) +" +p02873,s855829861,Accepted,"import itertools +S=input() +N=len(S)+1 +ans=0 +KEY=[] +gr=itertools.groupby(list(S)) +i=0 +for key,group in gr: + n=len(list(group)) + ans+=n*(n+1)//2 + KEY+=[n] + if key=="">"" and i!=0: + ans-=min(KEY[i-1],KEY[i]) + i+=1 +print(ans) " +p02598,s700707166,Accepted,"n, k = map(int, input().split()) +a = [i-1 for i in map(int, input().split())] + +left, right = 0, 10**9 +while left < right: + middle = (left+right)//2 + if middle==0: + left=1 + break + count = 0 + for i in a: + count += i//middle + + if count <= k: + right = middle + else: + left = middle + 1 + +print(left)" +p03679,s692421021,Accepted,"x,a,b = map(int, input().split()) + +if b <=a : + print(""delicious"") +elif b - a <= x: + print(""safe"") + +else: + print(""dangerous"") + " +p02970,s774589876,Accepted,"n,d=map(int,input().split()) +print((n+2*d)//(2*d+1))" +p02838,s450502428,Accepted,"n = int(input()) +a = list(map(int,input().split())) +mod = 10**9 + 7 + +c = [n]*61 +for i in range(n): + b = str(bin(a[i]))[2:] + b = b[::-1] + for j, x in enumerate(b): + if x == ""1"": + c[j] -= 1 + +ans = 0 +for i in range(60): + ans += c[i]*(n-c[i])*pow(2,i,mod) + ans %= mod +print(ans) +" +p02866,s483808624,Accepted,"import sys +input = lambda : sys.stdin.readline().rstrip() +sys.setrecursionlimit(max(1000, 10**9)) +write = lambda x: sys.stdout.write(x+""\n"") + + +n = int(input()) +d = list(map(int, input().split())) +M = 998244353 +from collections import Counter +c = Counter(d) +if d[0]!=0 or c[0]>=2: + ans = 0 +else: + m = max(c.keys()) + ans = 1 + for i in range(1,m+1): + if i not in c: + ans = 0 + break + ans *= pow(c[i-1], c[i], M) + ans %= M +print(ans%M)" +p03030,s104415418,Accepted,"n = int(input()) +l = [] +for i in range(n): + sp = input().split() + l.append([sp[0], int(sp[1]), i+1]) + +s = sorted(l, key=lambda i: (i[0], -i[1])) + +for i in range(n): + print(s[i][2])" +p02880,s783350873,Accepted,"# 81 + +# libraries +from itertools import combinations + +# input +N = int(input()) + +# solve +l = list(range(1,10)) +if N in [i*j for i, j in combinations(l+l, 2)]: + print('Yes') +else: + print('No') +" +p02702,s918194260,Accepted,"def main(): + S = input() + work, temp = [0] * 2019, 0 + work[0] = 1 + a = 1 + for s in S[::-1]: + temp += int(s) * a + work[temp%2019] += 1 + a *= 10 + a %= 2019 + print(sum([w*(w-1)//2 for w in work])) +main()" +p03131,s419477965,Wrong Answer,"K,A,B= map(int, input().split()) + +if A + 2 >= B or K < A + 2: + print(K + 1) + +else: + K -= A - 1 + q, m = divmod(K, 2) + print((B - A) * q + A + m) + " +p02993,s806789969,Accepted,"S = input() +f = 0 +for i in range(len(S)-1): + if S[i] == S[i+1]: + f = 1 +if f == 0: + print('Good') +else: + print('Bad')" +p03696,s512049915,Accepted,"N = int(input()) +S = input() + +L = 0 +cnt = 0 +for i in range(N): + if S[i] == '(': + cnt += 1 + else: + if cnt > 0: + cnt -= 1 + else: + L += 1 + +print('('*L + S + ')'*cnt)" +p03854,s209818496,Wrong Answer,"s=str(input()) +x=len(s) +a=s.count(""dream"") +b=s.count(""dreamer"") +c=s.count(""erase"") +d=s.count(""eraser"") +e=s.count(""dreameraser"") +a-=b +c-=d +if 5*(a+c)+6*(b+d)-e==x: + print(""YES"") +else: + print(""NO"")" +p03723,s985360867,Accepted,"a, b, c = map(int, input().split()) +cnt = 0 +while a%2==0 and b%2==0 and c%2==0: + if a==b==c: + print(-1) + exit() + a, b, c = b//2+c//2, a//2+c//2, a//2+b//2 + cnt += 1 +print(cnt)" +p03345,s642638490,Accepted,"A, B, C, K = map(int, input().split()) + +ans = A - B +if abs(ans) <= 10 ** 18: + if K % 2 == 0: + print(ans) + else: + print(ans * -1) +else: + print(""Unfair"")" +p02584,s272113963,Wrong Answer,"x, k, d = map(int, input().split()) # x現在地,k 移動回数,D移動できる距離 +a = x // d # 移動できる回数 +b = x % d # 移動した特のあまり +if k <= a: # 移動する回数がkより大きいとき + x = abs(x) - abs(k*d) +else: + k = k - a # ここで最短 + if k % 2 == 0: + x = abs(x) - abs(a * d) + else: + x = abs(x) - abs(a * d) + x = abs(x) - abs(d) + +print(abs(x)) +" +p03779,s573493132,Accepted,"import sys +input = sys.stdin.buffer.readline + +#sys.setrecursionlimit(10**9) +#from functools import lru_cache + +def RD(): return input().rstrip().decode() +def II(): return int(input()) +def FI(): return int(input()) +def MI(): return map(int,input().split()) +def MF(): return map(float,input().split()) +def LI(): return list(map(int,input().split())) +def LF(): return list(map(float,input().split())) +def TI(): return tuple(map(int,input().split())) +# rstrip().decode() + + +def main(): + n=II() + for i in range(10**10): + if (i*(i+1))//2>=n: + print(i) + exit() + + + + +if __name__ == ""__main__"": + main() +" +p03545,s831799366,Wrong Answer,"s = input() +n = len(s) + + +for i in range(2**(n-1)): + ans = int(s[0]) + f = s[0] + for j in range(n-1): + if i & (1< max_num: + max_num = num + +border = A.index(max_num) +height = [] +before_h = A[0] +for h in A[:border]: + if before_h <= h: + height.append(0) + + elif before_h > h: + height.append(before_h-h) + before_h = h + +for h in A[border:]: + height.append(max_num-h) + +print(sum(height)) + +" +p02761,s788574177,Accepted,"import sys +n,m=map(int,input().split()) +l=[0]*n +o=0 +for i in sys.stdin: + s,c=map(int,i.split()) + if s==1 and c==0 and n!=1: + o=-1 + break + elif l[s-1]==0 or l[s-1]==c: + l[s-1]=c + else: + o=-1 + break +if o==0: + if l[0]==0 and n>1: + l[0]=1 + o=''.join([str(i) for i in l]) +print(o)" +p03623,s552782723,Accepted,"x, a, b = map(int, input().split()) +if abs(x-a)<=abs(x-b): + print(""A"") +else: + print(""B"") + " +p02613,s779814018,Wrong Answer,"n = int(input()) +s=[] +for x in range(n): + s.append(input()) +a={""AC"":0, ""WA"":0,""TLE"":0,""RE"":0} +for x in s: + print(x) + a[x]+=1 +print(""AC x %s"" % a[""AC""]) +print(""WA x %s"" % a[""WA""]) +print(""TLE x %s"" % a[""TLE""]) +print(""RE x %s"" % a[""RE""])" +p03814,s416789602,Wrong Answer,"s = list(input()) + +flag = 0 +pos_a, pos_z = 1, 1 +length = 0 + +for i, ltr in enumerate(s): + if ltr == 'A': + pos_a = i + flag = 1 + elif ltr == 'Z' and flag == 1: + pos_z = i + if pos_z - pos_a > length: + length = pos_z - pos_a + else: + flag = 0 + +print(length)" +p02702,s724649930,Wrong Answer,"s = input()[::-1] +mod = 2019 +cnt = [0] * mod +x = 1 +cnt[0] = 1 +total = 0 +for s in s: + total = int(s) * x + total %= mod + cnt[total] += 1 + x *= 10 + +ans = sum(i*(i-1)//2 for i in cnt) +print(ans) +" +p02596,s550603588,Wrong Answer,"k=int(input()) +s=[] +s.append(7%k) +for i in range(1,k): + s.append((s[i-1]*10+7)%k) + if s[i]==0: + print(i+1) + exit() +print(-1) + " +p02631,s740636961,Accepted,"N = int(input()) +Ali = list(map(int,input().split())) +s = 0 + +for i in range(N): + s ^= Ali[i] + +for i in range(N): + print(s^Ali[i],end = "" "") + +print("""")" +p03469,s494923422,Wrong Answer,"print(input().replace(""2018"",""2017""))" +p02693,s215746490,Accepted,"k = int(input()) +a, b = map(int, input().split()) +for i in range(a, b+1): + if not i % k: print(""OK""); break +else: print(""NG"") +" +p03219,s724628333,Accepted,"x, y = map(int, input().split()) +print(x + y // 2)" +p03821,s900307702,Accepted,"n = int(input()) +ab = [] + +ans = 0 +for i in range(n): + a, b = map(int, input().split()) + ab.append([a, b]) + +ab = ab[::-1] + +ans = 0 +for i in range(n): + a, b = ab[i] + a += ans + if b == 1 or a % b == 0: + continue + elif b > a: + ans += b - a + else: + ans += b - (a % b) + +print(ans)" +p04043,s564643874,Accepted,"nums = list(map(int, input().split())) +nums.sort() +if nums == [5, 5, 7]: + print(""YES"") +else: + print(""NO"") +" +p03804,s056420310,Wrong Answer,"N, M = map(int, input().split()) +A = [input() for _ in range(N)] +B = [input() for _ in range(M)] + +flg = False +for y in range(N-M+1): + for x in range(N-M+1): + res = True + for i in range(M): + if A[y+i][y+i:y+i+3] != B[i][i:i+3]: res = False + if res: flg = True + if flg: break + if flg: break + +print(""Yes"" if flg else ""No"") +" +p03328,s896863621,Wrong Answer,"a, b = map(int, input().split()) + +s = 0 +for i in range(1, 1000): + s += i + if a < s: + print(s - a) + break" +p03778,s173363072,Wrong Answer,"W, a, b = map(int, input().split()) +print(max(0, max(a, b) - min(a, b)+W))" +p04031,s063254828,Accepted,"import statistics +n = int(input()) +a = [int(i) for i in input().split()] + +m = int(((sum(a)/n)*2 + 1) //2) +# m = statistics.mean(a) +# m = int(m) + 1 if m % 1 > 0.5 else int(m) +r = 0 +for i in a: + r += (i - m)**2 + +print(r) +" +p04044,s916062885,Wrong Answer,"n, l = map(int, input().split()) +a = sorted([input() for i in range(n)]) +print(a)" +p02947,s812155308,Accepted,"import sys +import os + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + N = int(sys.stdin.readline().rstrip()) + lines = ["""".join(sorted(line.rstrip())) for line in sys.stdin.readlines()] + + ret = 0 + sortedlines = {} + for n in range(N): + item = lines[n] + if item in sortedlines: + sortedlines[item] += 1 + ret += sortedlines[item] + else: + sortedlines[item] = 0 + + print(ret) + + +if __name__ == '__main__': + main() +" +p03485,s789514184,Wrong Answer,"import math +a, b = map(int, input().split()) +print(math.ceil(a+b))" +p02603,s890131417,Accepted,"N = int(input()) +A = list(map(int, input().split())) +kabu = 0 +total = 1000 + +A1 = [] +for i in range(1, N): + a = A[i] - A[i-1] + A1.append(a) +A1.append(A1[N-2]) + +for i in range(N): + if A1[i] > 0: + b = total // A[i] + total -= A[i] * b + kabu += b + elif A1[i] < 0: + total += kabu * A[i] + kabu = 0 + else: + continue + #print(total, kabu) +total += kabu * A[N-1] +print(total)" +p02843,s879569476,Wrong Answer,"n = int(input()) +a = n // 100 +b = n % 100 +check = a > 20 or b / 5 < a +print(""1"" if check else ""0"")" +p02596,s164951268,Accepted,"K = int(input()) + +def main(K): + cnt = 1 + amari = 0 + while True: + amari *= 10 + amari += 7 + amari %= K + if amari == 0: + return cnt + else: + cnt += 1 + + +if K % 2 == 0 or K % 5 == 0: + print(-1) +else: + print(main(K))" +p03319,s261496299,Wrong Answer,"n, k = map(int,input().split()) +A = list(map(int,input().split())) + +ind = A.index(1) +ans = 0 +if n==k: + print(1) + exit() +if ind != 0: + ans += -(-ind//(k-1)) +if ind != n-1: + ans += -(-(n-1-ind)//(k-1)) + +print(ans)" +p03220,s785238965,Accepted,"n = int(input()) +t, a = map(int, input().split()) +li = list(map(int, input().split())) +nl = [0] * n +for i in range(n): + nl[i] = abs(t - li[i] * 0.006 - a) +print(nl.index(min(nl))+1)" +p02946,s190550870,Accepted,"N,X=list(map(int, input().split())) +L=list(range(X-N+1,X+N)) +print(*L)" +p03448,s299459594,Accepted,"A = int(input()) +B = int(input()) +C = int(input()) +X = int(input()) + +ans = 0 + +for i in range(0, A+1, 1): + for j in range(0, B+1, 1): + for k in range(0, C+1, 1): + if 500 * i + 100 * j + 50 * k == X: + ans += 1 + +print(ans)" +p03379,s956537449,Wrong Answer,"import statistics +from collections import deque + +d = deque() + +a = int(input()) +d = list(map(int, input().split())) + +print(d) + +for i in range(a): + b = d.pop(0) + print(statistics.median(d)) + d.append(b) +# print(d)" +p02994,s378787903,Accepted,"import numpy as np + +N, L = map(int, input().split()) + +taste = np.arange(1, N+1) + L -1 +min_ind = np.argmin(np.abs(taste)) + +mask_1 = np.ones(N, dtype=bool) +mask_1[min_ind] = False + +ans = np.sum(taste[mask_1]) + +print(ans) +" +p03069,s562285579,Accepted,"n=int(input());s=input();b=0;w=a=s.count('.') +for c in s:b+=(x:=c=='#');w-=(x<1);a=min(a,b+w) +print(a)" +p03665,s229339278,Accepted,"def resolve(): + ''' + code here + ''' + N, P = [int(item) for item in input().split()] + As = [int(item)%2 for item in input().split()] + + is_all_even = True + for item in As: + if item == 1: + is_all_even = False + + res = 0 + if is_all_even: + if P == 0: + res = 2 ** N + else: + res = 0 + else: + res = 2**(N-1) + + print(res) + +if __name__ == ""__main__"": + resolve() +" +p02829,s289179012,Accepted,"def main(): + A=int(input()) + B=int(input()) + for i in range(1,4): + if i not in (A,B): + print(i) + return +main() +" +p02848,s784530813,Wrong Answer,"import sys + +input = sys.stdin.readline + + +def main(): + + # print(ord(""A"")) + # print(ord(""Z"")) + + SS =[] + N =int(input()) + S =input() + for i in range(len(S)): + temp = ord(S[i]) + N + temp = (temp-65) % 26 + 65 + SS.append( chr(temp)) + + + + for i in SS: + print(i,end="""") + + + + + +if __name__ == ""__main__"": + main()" +p03221,s771510965,Accepted,"n,m = map(int,input().split()) +ls = [[] for _ in range(n+1)] +di = [] +for i in range(m): + a,b = map(int,input().split()) + ls[a].append([b,i+1]) +for j in range(n+1): + if ls[j] != []: + ls[j].sort(key=lambda x :x[0]) + for k in range(len(ls[j])): + di.append([ls[j][k][1],str(10**12+j*10**6+k+1)[1:]]) +di.sort(key=lambda x :x[0]) +for l in range(m): + print(di[l][1])" +p03327,s575172419,Accepted,print('ABD' if 999 < int(input()) else 'ABC') +p03838,s765790968,Accepted,"a,b=map(int,input().split()) + +# aをずっと足していくパターン +i1=b-a if a=b else float(""inf"") + +# -aにしてずっと足していくパターン +i3=a+b+1 if -a<=b else float(""inf"") + +# -aにしてずっと足して、さらに -aにするパターン +i4=a-b+2 if a>=b else float(""inf"") + + +print(min(i1,i2,i3,i4))" +p02727,s486064131,Accepted,"x, y, a, b, c = map(int, input().split()) + +p = list(map(int, input().split())) +q = list(map(int, input().split())) +r = list(map(int, input().split())) + +# step1: sort red/green apples in descending order +p.sort(reverse=True) +q.sort(reverse=True) + +# step2:clip necessary apples +p = p[:x] +q = q[:y] + +# step3: sort red/green apples in ascending order +p.sort() +q.sort() + +# step4: sort non-color apples in descending order +r.sort(reverse=True) + +# step5:swap apples to eliminate the least delicious apple +d = [] + +d.extend(p) +d.extend(q) +d.extend(r) +d.sort(reverse=True) + +print(sum(d[: x + y])) +" +p02948,s633771887,Accepted,"import heapq +#解説の方法 +N,M = map(int,input().split()) +AB = [[] for _ in range(10**5+1)]#報酬振り込み日数ごとに報酬を格納 +for _ in range(N): + a,b = map(int,input().split()) + AB[a].append(-b) +q = [] +heapq.heapify(q) +ans =0 +for i in range(1,M+1): + for b in AB[i]: + heapq.heappush(q,b) + if len(q)>0: + ans += -heapq.heappop(q) +print(ans) + +" +p02647,s837890268,Accepted,"N, K, *A = map(int, open(0).read().split()) + +x = A[:] + +for _ in range(min(50, K)): + y = [0] * (N + 1) + for i in range(N): + y[max(0, i - x[i])] += 1 + y[min(N, i + x[i] + 1)] -= 1 + + for i in range(N): + y[i + 1] += y[i] + + x = y[:] + + +print(*x[:-1]) +" +p03971,s299352972,Accepted,"N,A,B=map(int,input().split()) +S=' '+input() +AB=A+B +j=1 +num=0 +for i in range(1,N+1): + if S[i]=='b' and num= 1: + print('Yes') + else: + print('No')" +p02971,s207490955,Accepted,"n = int(input()) +al =[ int(input()) for i in range(n)] +sal = sorted(al, reverse = True) +for i in al: + if i ==sal[0]: + print(sal[1]) + else: + print(sal[0])" +p03544,s140834139,Accepted,"N=int(input()) +L=[] + +for i in range(N+1): + if i==0: + L.append(2) + elif i==1: + L.append(1) + else: + L.append(L[-2]+L[-1]) + +print(L[-1])" +p03241,s913620996,Accepted,"def divisore(n): + divisors=[] + for i in range(1,int(n**0.5)+1): + if n%i==0: + divisors.append(i) + if i!=n//i: + divisors.append(n//i) + divisors.sort(reverse=True) + return divisors + +n,m=map(int,input().split()) +l=divisore(m) +for i in l: + if m/n>=i: + print(i) + exit()" +p03759,s417029104,Accepted,"a, b, c = map(int, input().split()) +print('YES' if (b - a) == (c - b) else 'NO')" +p02786,s760508409,Accepted,"h = int(input()) + +for i in range(50): + if 2 ** i <= h: + continue + else: + break + +ans = 0 + +for j in range(i): + ans += 2 ** j + +print(ans)" +p02777,s906550652,Accepted,"s, t = input().split(' ') +a, b = map(int, input().split()) +u = input() +if s == u: a -= 1 +if t == u: b -= 1 +print(a, b)" +p02918,s123887170,Accepted,"# coding: utf-8 +# Your code here! + +N, M = map(int, input().rstrip().split()) +A = input() + +count = 0 +for i in range(N-1): + if A[i] == A[i+1]: + count += 1 + +print(min(count + 2 * M, N - 1))" +p02958,s304551096,Accepted,"n = int(input()) +p = list(map(int,input().split())) +q = sorted(p) +ans = 0 +for i in range(n): + if p[i] != q[i]: + ans += 1 +if ans == 2: + print('YES') +elif ans == 0: + print('YES') +else: + print('NO') +" +p03359,s227350267,Wrong Answer,"a, b = map(int, input().split()) +print(""a-1"" if a>b else ""a"")" +p03485,s426033018,Accepted,"a, b = map(int,input().split()) +x = (a + b) /2 +if x % 1 != 0: + x = int(x) +1 +else: + x = int(x) +print(x)" +p02786,s609161506,Accepted,"import math + +h = int(input()) +atk = 0 +for i in range(int(math.log2(h)) + 1): + atk += 2 ** i + +print(atk)" +p04019,s160704631,Accepted,"S = input() +n = False +e = False +s = False +w = False +for _s in S: + if _s == 'N': + n = True + if _s == 'E': + e = True + if _s == 'S': + s = True + if _s == 'W': + w = True +if (n and s and e and w) or (n and s and not e and not w) or (not n and not s and e and w): + print('Yes') +else: + print('No') +" +p02633,s048077157,Accepted,"i = 1 +x = int(input()) +while True: + if (360 * i) % x == 0: + print(360 * i // x) + break + i += 1 +" +p02831,s517636685,Accepted,"def gcd(a, b): + while b: + a, b = b, a % b + return a +def lcm(a, b): + return a * b // gcd(a, b) +x, y = map(int, input().split()) +print(lcm(x, y)) +" +p02766,s178312543,Accepted,"N,R = map(int,input().split()) + +def Base_10_to_n(X, n): + X_dumy = X + out = '' + while X_dumy>0: + out = str(X_dumy%n)+out + X_dumy = int(X_dumy/n) + return out + +print(len(Base_10_to_n(N, R))) +" +p02707,s814560154,Accepted,"n=int(input()) +a=list(map(int, input().split())) +ans=[0 for i in range(n)] +for i in a: + ans[i-1]+=1 +for i in ans: + print(i)" +p03282,s056142787,Accepted,"import sys +S=input() +K=int(input()) +ans='' +i=0 +while True: + ans=S[i] + if(K==(i+1)): + print(ans) + sys.exit() + elif(ans=='1'): + i+=1 + else: + print(ans) + sys.exit() + +" +p02660,s970596486,Accepted,"n=int(input()) +def prime_factor(n): + ass=[] + for i in range(2,int(n**0.5)+1): + while n%i==0:ass.append(i);n//=i + if n!=1:ass.append(n) + return ass +d=prime_factor(n) +from collections import Counter +ans=0 +c=Counter(d) +for i in c: + m=c[i] + mm=1 + while mm<=m: + m-=mm + mm+=1 + ans+=1 +print(ans)" +p02659,s231878070,Accepted,"from decimal import * + +a, b = map(float, input().split()) + +a = Decimal(str(a)) +b = Decimal(str(b)) +b *= Decimal(str(100)) +ans = a * b +ans //= Decimal(str(100)) + +print(ans) +" +p02691,s556025845,Accepted,"n = int(input()) +a = list(map(int, input().split(' '))) +b = [a[i] + i for i in range(n)] +c = [j - a[j] for j in range(n)] +d = dict() +ans = 0 +for i in range(n): + if d.get(b[i]) is None: + d.setdefault(b[i],1) + else: + d[b[i]] += 1 + if d.get(c[i]) is not None: + ans += d[c[i]] +print(ans)" +p02701,s235974309,Wrong Answer,"N = int(input()) +r = set() +for i in range(N): + r |= set(input()) + +print(len(r))" +p03243,s215065285,Accepted,"N = int(input()) + +n = N +for i in range(1000): + if str(n)[0] == str(n)[1] == str(n)[2]: + ans = n + break + n += 1 + +print(ans)" +p04005,s298007546,Wrong Answer,"a=list(map(int,input().split())) +a.sort() +mid=1 +ans=10**9 +for i in range(2): + mid*=a[i] + +for i in range(a[-1]//2-1,a[-1]//2+1): + b=mid*i + c=mid*(a[-1]-i) + sa=abs(b-c) + if ans>sa: + ans=sa +print(ans)" +p02641,s701732443,Accepted,"def main(): + x, n = map(int, input().split()) + P = list(map(int, input().split())) + if n == 0: + print(x) + return + ans = 0 + min_dis = 1000 + for item in range(102): + if item in P: + continue + dis = abs(item - x) + if min_dis > dis: + min_dis = dis + ans = item + print(ans) + return + +if __name__ == ""__main__"": + main()" +p02602,s657471943,Accepted,"n, k = map(int,input().split()) +A = list(map(int, input().split())) +for i in range(n-k): + print('Yes' if A[i+k]>A[i] else 'No')" +p03328,s657285876,Accepted,"a,b=map(int,input().split()) +s=0 +for i in range(b-a): + s+=i +print(s-a)" +p02629,s194099414,Wrong Answer,"def func(tmp): + print(tmp) + ans = '' + sub_ans = tmp/26 + if sub_ans >0: + ans += func(int(sub_ans)) + + ans += chr(96 + int(tmp)%26) + + return ans + + +tmp = int(input()) +print(func(tmp)[1:])" +p02691,s813646334,Accepted,"from collections import Counter + +N = int(input()) +A = list(map(int, input().split())) + +P = [] +Q = [] + +for i in range(N): + P.append(i + 1 + A[i]) + Q.append(i + 1 - A[i]) + +P = Counter(P) +Q = Counter(Q) + +res = 0 + +for v, c in P.items(): + if v in Q: + res += c * Q[v] + +print(res)" +p03795,s706597803,Wrong Answer,"n = int(input()) +x = n*800 +y = n//15 +print(x-y)" +p03456,s107680976,Accepted,"a, b = input().split() +c = int(a + b) +ans = 1 + +if int(c ** 0.5) ** 2 == c: + print(""Yes"") +else: + print(""No"") +" +p04020,s515253937,Accepted,"N = int(input()) +A = [int(input()) for i in range(N)] + +ans = 0 +part_sum = 0 +for i in range(N): + if A[i] == 0 or i == N-1: + part_sum += A[i] + ans += (part_sum // 2) + part_sum = 0 + else: + part_sum += A[i] + +print(ans) + + + + +" +p03817,s303348287,Accepted,"N = int(input()) +print(N//11*2+(N%11+5)//6) +" +p03665,s008320174,Accepted,"import math + +def comb(n, r): + return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) + +n,p = map(int, input().split()) +a = list(map(int, input().split())) +res = 0 + +for i in range(n): + a[i] = a[i]%2 + +for i in range((a.count(1)+1)//2): + res = res + comb(a.count(1), 2*i+1) +if res == 0 and p == 0: + res = 1 +res = res * 2**a.count(0) +print(res)" +p02785,s047721520,Accepted,"n, k = map(int, input().split()) +h = list(map(int, input().split())) + +if k >= n: + print(0) +else: + h.sort() + count = 0 + for _ in range(len(h) - k): + count += h[_] + print(count)" +p03951,s394695491,Accepted,"n = int(input()) +s = input() +t = input() + +if s == t: + print(n) + exit() + +maxl = 0 +for i in range(n): + sub_s = s[n-i-1:] + sub_t = t[:i+1] + if sub_s == sub_t: + maxl = max(maxl, i + 1) + +print(2 * n - maxl) +" +p04019,s491769135,Wrong Answer,"import collections +S=list(str(input())) +cc=collections.Counter(S) + +if cc['S']*cc['N']==0: + print('No') +elif cc['E']*cc['W']==0: + print('No') +else: + print('Yes') + +" +p02726,s538461027,Wrong Answer,"N, X, Y = map(int, input().split()) + +d = [[-1 for n in range(N)] for n in range(N)] +for i in range(N): + for j in range(i + 1, N): + d[i][j] = min([abs((i + 1) - (j + 1)), abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1))]) + +answer = [0 for n in range(N - 1)] +for i in range(N): + for j in range(N): + if d[i][j] != - 1: + answer[d[i][j] - 1] += 1 +print(answer) +for i in range(len(answer)): + print(answer[i])" +p04044,s590627987,Accepted,"N, L = map(int, input().split()) +S = [input() for _ in range(N)] +S.sort() +print(''.join(S))" +p03723,s751923175,Accepted,"a,b,c = map(lambda x:int(x),input().split()) +reps = 0 +while a%2==0 and b%2==0 and c%2==0: + if (a==b==c): + reps = -1 + break + at=a + bt=b + ct=c + a = int(bt/2+ct/2) + b = int(at/2+ct/2) + c = int(at/2+bt/2) + reps += 1 +print(reps)" +p03145,s442075172,Accepted,"a,b,c=map(int,input().split()) +print(a*b//2)" +p03103,s246270893,Accepted,"N,M = map(int,input().split()) +AB = [list(map(int,input().split())) for _ in range(N)] +A = sorted(AB,key=lambda x:x[0]) +ans = 0 + +for i in range(N): + buy = min(M,A[i][1]) + ans += buy * A[i][0] + M -= buy +print(ans)" +p03494,s228634879,Accepted,"import math +n = input() +a = list(map(int, input().split())) +ans = float(""inf"") +for i in a: + ans = min(ans, len(bin(i)) - bin(i).rfind(""1"") - 1) +print(round(ans)) +" +p03030,s954198248,Accepted,"from collections import Counter +from collections import defaultdict +from collections import deque +import math +import itertools +import heapq +import sys +sys.setrecursionlimit(10**6) + +#n=int(input()) +#n,m=list(map(int,input().split())) +#a=list(map(int,input().split())) +input_list = lambda : list(map(int,input().split())) + +n=int(input()) + +a=[] +for j in range(n): + v,i=input().split() + i=int(i) + a.append([v,i,j]) +a.sort(key=lambda x:(x[0],-x[1])) +for each in a: + print(each[2]+1)" +p03328,s331314646,Accepted,"a, b = map(int, input().split()) + +N = b - a +print((N * (N + 1) // 2) - b) +" +p02696,s095399493,Wrong Answer,"#D +a,b,n = map(int,input().split()) + +print(min(n,b-1)) +" +p02748,s705322939,Accepted,"A,B,M = map(int,input().split()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +xyc = [list(map(int,input().split())) for _ in range(M)] +pay = 0 +min_pay = 0 +for i in range(M): + pay = a[xyc[i][0]-1] + b[xyc[i][1]-1] - xyc[i][2] + if i == 0: + min_pay = pay + min_pay = min(min_pay,pay) +min_pay = min(min_pay,min(a)+min(b)) +print(min_pay)" +p03862,s068359696,Wrong Answer,"N,x = map(int,input().rstrip().split("" "")) +ans = 0 +A = list(map(int,input().rstrip().split("" ""))) +for i in range(N -1): + k = max(A[i] + A[i + 1] - x,0) + ans += k + A[i+1] -= k +print(ans)" +p03077,s989356116,Accepted,"N=int(input()) +A=[0]*5 +for i in range(5): + A[i]=int(input()) + +print(-(-N//min(A))+4)" +p02729,s288294292,Wrong Answer,"n, m = map(int, input().split()) +print(n*(n-1)/2+m*(m-1)/2)" +p04012,s319015254,Wrong Answer,"S = input() +ec = 0 +c = {} +for each in S: + try: + c[each] += 1 + if c[each] % 2 == 0: + ec -= 1 + else: + ec += 1 + except: + c[each] = 1 + ec += 1 +if (ec == 0): + print(""YES"") +else: + print(""NO"") +" +p02787,s560482781,Accepted,"h,n=map(int,input().split()) +l=[list(map(int,input().split())) for _ in range(n)] +inf=10**9 +dp=[inf]*(h+10**5) +dp[0]=0 +#dp[i]=モンスターの体力をi減らすのに魔力が最低でいくつ必要か +for i in range(h): + for a,b in l: + dp[i+a]=min(dp[i+a],dp[i]+b) +ans=10**9 +for i in range(10**5): + ans=min(ans,dp[i+h]) +print(ans)" +p02694,s880729563,Wrong Answer,"x = int(input()) + +deposit = 100 +year = 0 + +while deposit < x: + deposit = int(deposit * 1.01) + year += 1 + +print(year) +" +p03073,s578255498,Wrong Answer,"def resolve(): + S = list(input()) + + ans = 0 + for i in range(1, len(S)): + if (S[i - 1] == S[i]): + ans += 1 + + if S[i] == '0': + S[i] = '1' + else: + S[i] = '0' + + print(ans)" +p02813,s697193487,Accepted,"from math import factorial +import copy +N = int(input()) +P = list(map(int, input().split())) +Q = list(map(int, input().split())) +Mp = copy.copy(P) +Mq = copy.copy(Q) +Lp = 0 +Lq = 0 +for i in range(N): + if P[i] == min(Mp) and i != N: + Mp.remove(P[i]) + else: + Lp += factorial(len(Mp)-1)*(sum(x time: + print(""Yes"") +else: + print(""No"")" +p03838,s190838619,Wrong Answer,"# coding: utf-8 +#n = int(input()) +x, y = map(int,input().split()) +#A = list(map(int,input().split())) +#ans = 0 +ans = 0 + +if x < y: + ans += abs(abs(x)-abs(y)) +else: + if x<0 and y<0: + ans += abs(abs(x)-abs(y)) + 2 + elif x>0 and y<0: + ans+=1 + ans+=abs(abs(x)-abs(y)) + elif x>0 and y>0: + ans+=1 + ans+=abs(x+y) + else: + ans = abs(x-y) +print(ans) + " +p03417,s699020544,Accepted,"n,m=map(int,input().split()) +if n>=2 and m>=2: + print((m-2)*(n-2)) +elif n==1: + if m==1: + print(1) + else: + print(m-2) +elif m==1: + if n==1: + print(1) + else: + print(n-2) +" +p03617,s799262337,Wrong Answer,"from itertools import permutations +Q, H, S, D = map(int, input().split()) +N = int(input()) + +ans = 0 +s = [(Q, 0.25), (H, 0.5), (S, 1.0), (D, 2.0)] + +ans = float(""inf"") +for x in permutations(s): + tmp = 0 + n = N + for a, b in x: + tmp += (n // b)*a + n %= b + ans = min(ans, tmp) +print(int(ans)) +" +p02595,s000063593,Wrong Answer,"import math +n, d = map(int, input().split()) +xy = [list(map(int, input().split())) for _ in range(n)] +print(xy) +count = 0 + +for i in range(n): + count = count + 1 if math.sqrt(xy[i][0]**2 + xy[i][1]**2) <= d else count + +print(count)" +p03329,s268517354,Wrong Answer,"list=[1, 1, 1, 1, 1] +for i in range(1, 7): + list.append(6**i) +for j in range(1, 7): + list.append(9**i)" +p02753,s292593559,Wrong Answer,"S=input() +if(""AAA""==S or S==""BBB""): + print(""Yes"") +else: + print(""No"") +" +p03075,s891716625,Accepted,"a=int(input()) +b=int(input()) +c=int(input()) +d=int(input()) +e=int(input()) +k=int(input()) +if e-a<=k: + print(""Yay!"") +else: + print("":("")" +p02836,s587324106,Accepted,"S = str(input()) +num = len(S) // 2 +ans = 0 + +for i in range(num): + if S[i] != S[-1-i]: + ans += 1 + else: + pass +print(ans)" +p03773,s434759319,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def main(): + A, B = map(int, input().split()) + print((A + B) % 24) + + +if __name__ == ""__main__"": + main() +" +p02613,s411336110,Accepted,"S = [input() for n in range(int(input()))] +for s in [""AC"",""WA"",""TLE"",""RE""]: + print(s,""x"",S.count(s))" +p03251,s368891382,Accepted,"n, m, x, y = map(int, input().split()) +xn = list(map(int, input().split())) +ym = list(map(int, input().split())) + +xn = max(xn) +ym = min(ym) + +for z in range(x+1,y+1): + if xn< z <=ym: + print('No War') + exit() +print('War') +" +p04005,s108359724,Accepted,"a = list(map(int,input().split())) + +a.sort() + +if a[2] == 0: + print(0) + exit() +m = a[0]*a[1] +n = a[2]//2 +print(abs(m*n-m*(a[2]-n)))" +p02924,s473191179,Wrong Answer,"n = int(input()) +if n % 2 == 1: + print(n * (n // 2)) +else: + print((n * n - n) / 2)" +p03338,s334091307,Accepted,"n = int(input()) +s = input() +x = 0 + +for i in range(1, n): + a,b = set(s[:i]), set(s[i:]) + if max(len(a),len(b))-max(len(a-b),len(b-a))>x: + x = max(len(a),len(b))-max(len(a-b),len(b-a)) + +print(x)" +p02660,s699635705,Accepted,"from math import sqrt +n=int(input()) +t=0 +i=2 +while i*i<=n: + if n%i==0: + c=0 + while n%i==0: + n//=i + c+=1 + t+=(int(sqrt(8*c+1))-1)//2 + i+=1 +if n>1: + t+=1 +print(t)" +p03107,s258180744,Wrong Answer,"S=list(input()) +s=0 #取り除いたキューブの数 +i=0 +while len(set(S))!=len(S): + if S[i]==S[i+1]==0 or S[i]==S[i+1]==1: + s=s + i+=1 + else: + s+=2 + del S[i:i+2] + i=0 +print(s)" +p02801,s679566578,Wrong Answer,"C = input() +letters = ""abcdefghijklmnopqrstuvwz"" +list_letters = list(letters) +print(list_letters[letters.find(C)]) +" +p03485,s944241270,Accepted,"import math +a,b=map(int,input().split()) +print(math.ceil((a+b)/2))" +p02608,s525932879,Wrong Answer,"from collections import Counter +n=int(input()) +cnt=0 +ans=[] +for i in range(2,int((2*n)**0.5)+1): + for j in range(2,int((2*n)**0.5)+1): + for k in range(2,int((2*n)**0.5)+1): + if (i*i + j*j + k*k)%2==0 and (i*i + j*j + k*k)<=2*n and (i+j-k>1) and (i+k-j>1) and (k+j-i>1): + ans.append((i*i + j*j + k*k)//2) +ans.sort() +A=Counter(ans) +for i in range(n): + print(A[i])" +p02700,s310885243,Wrong Answer,"a,b,c,d = map(int,input().split()) + +#高橋 → 青木 +# takahashi = a // d +# aoki = c // b + + +# if takahashi <= aoki: +# print('Yes') +# else: +# print('No') + +takahashi = a +aoki = c + +for _ in range(100): + takahashi -= d + aoki -= d + if takahashi <= 0: + print('No') + break + elif aoki <= 0: + print('Yes') + break" +p03328,s282864242,Wrong Answer,"a,b=map(int,input().split()) +A=[] +for i in range(1,1000): + A.append((i*(i+1))//2) + +for j in range(10**6): + if ((a+j) in A) and ((b+j) in A): + print(j) + exit() +" +p03380,s970968265,Wrong Answer,"from bisect import bisect_left + +n=int(input()) +a=list(map(int,input().split())) +a.sort() + +maxi=a[-1] +tmp=maxi//2 +idx=bisect_left(a,tmp) +if idx==n-1: + idx -=1 + +print(maxi,a[idx])" +p03986,s044703089,Wrong Answer,"X=input() +ans = len(X) +def chk(X,a,b): + if X[a]==""S"" and X[b]=='T': + return chk(X,a-1,b+1)+2 + else: + return 0 +for i in range(len(X)-1): + ans -= chk(X,i,i+1) +print(ans)" +p02640,s912050187,Wrong Answer,"X,Y = map(int,input().split()) + +#2z + 4(X-z) = Y +#-2z = Y - 4X +z = 2*X - 0.5*Y + +if(0 < z and z.is_integer()): + print('Yes') +else: + print('No')" +p02924,s580939627,Accepted,"n = int(input()) +ans = (n*(n-1))//2 +print(ans)" +p02729,s599257421,Accepted,"n, m = map(int, input().strip().split()) +ans = n * (n - 1) // 2 + m * (m - 1) // 2 +print(ans) +" +p02647,s229879550,Wrong Answer,"N , K =map(int,input().split()) +A_n =list(map(int,input().split())) + +zero = [0 for i in range(N)] +for i in range(min(K,41)): + B_n = zero + for j in range(N): + B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)] = map(lambda x : x+1,B_n[max(0 ,j -A_n[j]):min(N ,j + A_n[j]+1)]) + A_n = B_n +print("" "".join(map(str,B_n)))" +p03136,s886759580,Accepted,"N = int(input()) +l = list(map(int,input().split())) + +S = sum(l) + +M = max(l) + +if S - M > M: + print(""Yes"") +else: + print(""No"")" +p03041,s137198876,Accepted,"n, k = map(int, input().split()) +S = list(input()) + +S[k - 1] = S[k - 1].lower() +print("""".join(S)) +" +p02555,s833488566,Wrong Answer,"S = int(input()) +i = 0 +ans = 0 +mod = 10 ** 9 + 7 + +def comb(n, k): + de = 1 + nu = 1 + for i in range(k): + de *= (n - i) % mod + nu *= (i + 1) % mod + nu = pow(nu, -1, mod) + return de * nu + +while 1: + S -= 3 + if S <= 0: + if S == 0: + S += 1 + print(ans) + exit() + ans += comb(S+i, i) + ans = ans % mod + i += 1" +p04044,s300843216,Accepted,"n,l=map(int,input().split()) +s=sorted([input() for i in range(n)]) +print(''.join(s))" +p03262,s279373950,Accepted," +def gcd(x, y): + #assert x >= y + return gcd(y, x%y) if y else x + + +N, X = [int(i) for i in input().split()] +Xn = [int(i) for i in input().split()] + +dx =[abs(x-X) for x in Xn] + +gcd_num = dx[0] +for x in dx: + a, b = (gcd_num, x) if gcd_num > x else (x, gcd_num) + gcd_num = gcd(a, b) +print(gcd_num) + + + + + +" +p03251,s661509607,Wrong Answer,"N, M, X, Y = map(int, input().split()) +X = [int(i) for i in input().split()] +Y = [int(i) for i in input().split()] + +if min(Y) - max(X) > 1: + print(""No War"") +else: + print(""War"")" +p03624,s463770632,Wrong Answer,"S=list(input()) +l=sorted(list(set(S))) +for (i,j) in zip(range(len(l)),range(97,97+26)): + if chr(j) !=l[i]: + print(chr(j)) + exit() + elif chr(j) == 'z': + print('None') + exit() +print('None') +" +p02772,s844495484,Accepted,"N=int(input()) +A=list(map(int,input().split())) +l=[] +for i in range(N): + if A[i]%2==0: + l.append(A[i]) +flag=True +for i in range(len(l)): + if l[i]%3==0 or l[i]%5==0: + pass + else: + flag=False +if flag: + print(""APPROVED"") +else: + print(""DENIED"")" +p02623,s087462034,Wrong Answer,"from bisect import bisect + +N, M, K = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +R_B = [0]*(M+1) +i = 0 +while i < M: + R_B[i+1] = R_B[i]+B[i] + i += 1 +ans = 0 +i = 0 +while i < N and K >= A[i]: + K -= A[i] + idx = bisect(R_B, K) + ans = max(ans, i+idx) + R_B = R_B[:idx+1] + i += 1 +print(ans) + +" +p03417,s770532980,Wrong Answer,"print(2) +exit() +print(3) +" +p03160,s606716518,Wrong Answer,"def chmin(a, b): return b if a > b else a + + +def chmax(a, b): return a if a > b else b + + +""""""もらうDP"""""" +import math + +N = int(input()) +h = list(map(int, input().split())) + +dp = list([math.inf for i in range(N)]) # dpテーブル +dp[0] = 0 +for i in range(N): + dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) + if i > 1: + dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) + +print(dp[N-1]) +print(dp) +" +p03623,s211076488,Wrong Answer,"x, a, b = map(int, input().split()) +if abs(a - x) >= abs(b - x): + print('A') +else: + print('B')" +p02642,s200914647,Accepted,"n = int(input()) +a = list(map(int,input().split())) +amax = max(a) +ans = 0 +numlist = [0] * amax + +for i in range(n): + if numlist[a[i]-1] != 0: + numlist[a[i]-1] = 2 + continue + else: + for j in range(1, amax // a[i] + 1): + numlist[a[i] * j - 1] += 1 +for i in range(n): + if numlist[a[i]-1] == 1: + ans += 1 + +print(ans) +" +p02819,s138530196,Accepted,"##C +X = int(input()) +##素数かどうか判定 +from math import sqrt +def is_prime(n): + for i in range(2, int(sqrt(n))): + if n % i == 0: + return False + else: + return True + +while (not is_prime(X)): + X += 1 + +print(X) +" +p02900,s948713675,Wrong Answer,"a, b = map(int, input().split()) + +gcd_list = [] +i = 1 +while i < a ** (1/2)+1: + if a % i == 0 and b % i == 0: + j = 2 + appender = True + while j <= i ** (1/2): + + if i % j == 0: + appender = False + break + j += 1 + + if appender: gcd_list.append(i) + + i += 1 + +print(len(gcd_list))" +p02707,s508912164,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = [0]*N +for a in A: + ans[a-1] += 1 + +for i in ans: + print(i)" +p03386,s705913775,Accepted,"A, B, K = map(int, input().split()) +candidate1 = [i for i in range(A, A+K) if i <= B] +candidate2 = [i+1 for i in range(B-K, B) if i+1 >= A] + +ans = list(sorted(list(set(candidate1+candidate2)))) +ans = [str(ans[i]) for i in range(len(ans))] + +print('\n'.join(ans))" +p02771,s203744669,Accepted,"x,y,z = input().split() +if x == y and x == z: + print(""No"") +elif x == y or y == z or x == z: + print(""Yes"") +else: + print(""No"")" +p02724,s885593152,Wrong Answer,"X = int(input()) + +happiness = 0 +if X > 1000: + happiness += (X//1000)*2*1000 + X = X%1000 +happiness += (X//5)*5 + +print(happiness) +" +p03073,s458816884,Accepted,"S = input() + +ans = 0 +if S[0] == '0': + ans += S[2::2].count('1') + ans += S[1::2].count('0') +else: + ans += S[2::2].count('0') + ans += S[1::2].count('1') + +print(ans) +" +p03061,s099139148,Wrong Answer,"import fractions +n = int(input()) +l = list(map(int,input().split())) +if n == 2: + print(max(l)) + exit() +l.sort() +ans = fractions.gcd(l[0],l[1]) +for i in range(2,n): + ans1 = fractions.gcd(ans,l[i]) + if ans1 < ans: + print(ans) + exit() +print(max(fractions.gcd(l[0],l[-1]),fractions.gcd(l[1],l[-1]))) + + +" +p03555,s583073075,Accepted,"print(""YES"" if list(input())==list(reversed(list(input()))) else ""NO"")" +p02630,s441546397,Accepted,"from collections import Counter + +n=int(input()) +a=Counter(list(map(int,input().split()))) +q=int(input()) +sm=0 +for x in a: + sm+=x*a[x] + +for i in range(q): + b,c=map(int,input().split()) + if b in a: + a[c]+=a[b] + sm+=(c-b)*a[b] + a[b]=0 + print(sm) +" +p03293,s416902396,Accepted,"S=input() +T=input() +a='No' +for i in range(len(T)): + if T[i:]+T[:i]==S or T[:i]+T[i:]==S: + a='Yes' + break +print(a)" +p03013,s945637825,Accepted,"mod = 10**9 + 7 + +n, m = map(int, input().split()) +fib = [1] * (n+1) +for i in range(2, n+1): + fib[i] = (fib[i-1] + fib[i-2]) % mod +count = 1 +start = 0 +for _ in range(m): + a = int(input()) + stop = a-1 + if start > stop: + count = 0 + break + count = count * fib[stop - start] % mod + start = a+1 +stop = n +count = count * fib[stop - start] % mod +print(count)" +p02836,s218684080,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + s=input() + cnt=0 + for i in range(len(s)//2): + if s[i]!=s[-1-i]: + cnt+=1 + print(cnt) +resolve() +" +p03433,s322955643,Wrong Answer,"N = int(input()) +a = sorted(list(map(int,input().split())))[::-1] +print(sum(a[::2])-sum(a[1::2])) +" +p02613,s592825976,Wrong Answer,"N = int(input()) +for s in range(N): + s = list(input().split()) + +print('AC','x',s.count('AC')) +print('TLE','x',s.count('TLE')) +print('WJ','X',s.count('WJ')) +print('RE','X',s.count('RE')) +" +p03495,s972220644,Accepted,"from collections import Counter as C + +_, k = map(int, input().split()) +a = [int(i) for i in input().split()] + +c = C(a).values() +d = len(c) - k +if 0 < d: + print(sum(sorted(c)[:d])) +else: + print(0)" +p02912,s637594121,Accepted,"from heapq import heapify,heappop,heappush +N,M=map(int,input().split()) +A=list(map(lambda x:-int(x),input().split())) +heapify(A) +for i in range(M): + heappush(A,-(-heappop(A)//2)) +print(-sum(A))" +p03339,s514779937,Accepted," + +def main(): + N = int(input()) + S = input() + + l = [0]*N + r = [0]*N + for i in range(1, N): + l[i] = l[i-1] + (S[i-1]==""W"") + for i in range(N-1)[::-1]: + r[i] = r[i+1] + (S[i+1]==""E"") + + + ans = 10**6 + for a, b, in zip(l, r): + ans = min(a+b, ans) + print(ans) + + +if __name__ == ""__main__"": + main()" +p02707,s382405369,Accepted,"from sys import stdin + +N = int(stdin.readline().rstrip()) + +As = [int(x) for x in stdin.readline().rstrip().split()] + +kazu = [0]*N + +for i in range(N-1): + kazu[As[i]-1] += 1 + + +for i in range(N): + print(kazu[i]) +" +p02688,s801526499,Accepted,"N,K = map(int,input().split()) +cnt = [0]*(N+1) +for i in range(K): + d = int(input()) + num = list(map(int,input().split())) + for j in range(d): + cnt[num[j]]+=1 +print(cnt.count(0)-1)" +p03127,s006283002,Wrong Answer,"def main(): + n = int(input()) + a = [int(i) for i in input().split()] + a.sort() + diff = [] + for i in range(1,n): + diff.append(a[i]-a[i-1]) + Min = min(diff) + if Min==0: + print(a[0]) + exit() + tmp = 10**9 + for i in range(n): + tmp2= a[i]%Min + if tmp2>0: + tmp = min(tmp,tmp2) + print(min(a[0],tmp)) +main()" +p02779,s978404947,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +if len(a) != len(set(a)): + print(""NO"") +else: + print(""YES"")" +p03814,s116017346,Accepted,"s = input() +print(s.rfind('Z')-s.find('A')+1)" +p02645,s140572594,Accepted,"s = input() + +print(s[:3]) +" +p02552,s756916551,Accepted,"x=int(input()) +print(0 if x else 1)" +p03069,s352129411,Accepted,"n = int(input()) +s = input() + +l = [0 for i in range(n)] +r = [0 for i in range(n)] +for i in range(1,n): + rev = -(i+1) + l[i] = l[i-1] + 1 if s[i-1] == ""#"" else l[i-1] + r[rev] = r[rev+1] + 1 if s[rev+1] == ""."" else r[rev+1] + +ans = 1e+9 +for i in range(n): + ans = min(ans, l[i] + r[i]) +print(ans)" +p03239,s377461467,Accepted,"n, T = map(int, input().split()) +l = [] +for _ in range(n): + c, t = map(int, input().split()) + l.append([c, t]) + +l.sort() +for i in range(n): + if l[i][1] <= T: + print(l[i][0]) + break + if i == n-1 and l[i][1] > T: + print('TLE')" +p03408,s489861487,Accepted,"from collections import defaultdict + +b = defaultdict(int) +r = defaultdict(int) + +n = int(input()) +for i in range(n): + b[input()] += 1 +m = int(input()) +for i in range(m): + r[input()] += 1 +ans = 0 +for k, v in b.items(): + ans = max(ans, v - r[k]) +print(ans)" +p03778,s387069196,Accepted,"w, a, b = map(int, input().split()) +s=0 + +if a<=b: + s=b-(a+w) +else: + s=a-(b+w) + +if s<0: + print(0) +else: + print(s)" +p03862,s013537010,Wrong Answer,"N, x = map(int, input().split()) +A = list(map(int, input().split())) + +ans = 0 +prev = A[0] +for i in A[1:]: + if prev + i > x: + tmp = prev + i - x + ans += tmp + prev = i-tmp + else: + prev = i +print(ans)" +p03681,s075990104,Wrong Answer,"n, m = map(int, input().split()) +mod = 10**9+7 + +if abs(n - m) >= 2: + print(0) + exit() + +import math + +minx = min(n, m) +x = math.factorial(minx) % mod + +if n == m: + print(2*pow(x,2,mod)%mod) +else: + print(2*pow(x,2,mod)*(x+1)%mod) +" +p02665,s932392124,Accepted,"import sys +import itertools + +N = int(input()) +A = list(input().split()) +A = [int(A[i]) for i in range(N+1)] +MAX = [1 for i in range(N+1)] +A_inter = list(reversed(list(itertools.accumulate(reversed(A))))) + +for i in range(N+1): + if A[i] > MAX[i]: + print(-1) + sys.exit() + elif i != N: + MAX[i+1] = (MAX[i] - A[i]) * 2 + +print(sum([min(MAX[i], A_inter[i]) for i in range(N+1)]))" +p02861,s309672939,Accepted,"import itertools +N = int(input()) +xy = [[int(x) for x in input().split()] for i in range(N)] +ans = 0 +count = 0 +for city in itertools.permutations(xy,2): + ans += ((city[0][0]-city[1][0])**2 + (city[0][1]-city[1][1])**2)**0.5 + count += 1 +print(ans/N)" +p03862,s032302112,Accepted,"n,x=map(int,input().split()) +a=list(map(int,input().split())) +ans=0 +for i in range(1,n): + if a[i]+a[i-1]>x: + ans+=min(a[i]+a[i-1]-x,a[i]) + a[i]-=min(a[i]+a[i-1]-x,a[i]) + if a[i]+a[i-1]>x: + ans+=a[i-1]-x + a[i-1]-=a[i-1]-x +print(ans)" +p02697,s924721311,Accepted,"n, m = map(int, input().split()) +center1 = (m+1) // 2 +center2 = center1 + m +for i in range(m): + if i % 2 == 0: + a = center1 - i // 2 + b = center1 + i // 2 + 1 + else: + a = center2 - i // 2 + b = center2 + (i+1) // 2 + 1 + print(f""{a} {b}"") +" +p03062,s195886114,Wrong Answer,"x=int(input()) +y=list(map(int, input().split())) +t=1 +for i in range(x): + if y[i]<0: + t=t*-1 + y[i]=abs(y[i]) + +if y==1: + print(sum(y)) +else: + print(sum(y)-(min(y)*2))" +p03076,s830821879,Wrong Answer,"x = [] +x.append(int(input())) +x.append(int(input())) +x.append(int(input())) +x.append(int(input())) +x.append(int(input())) +tmp = 0 +ans = 0 + + +def a(b): + c = str(b) + if c[-1] == 0: + return b + else: + return b - int(c[-1]) + 10 + + +for i in x: + ans += a(i) + d = str(i) + tmp = max(tmp, 10 - int(d[-1])) + +print(ans - tmp) +" +p02838,s604614306,Accepted,"import numpy as np + +n = int(input()) +a = np.array(list(map(int, input().split()))) +mod = 10**9+7 + +ans = 0 +max_digit = 0 +for i in range(n): + max_digit = max(max_digit, len(bin(a[i]))) +for i in range(max_digit): + num1 = np.count_nonzero((a >> i) & 1) # 1の数 + num2 = n - num1 # 0の数 + ans += pow(2, i, mod) * (num1 * num2) % mod +print(ans % mod)" +p02664,s623400012,Accepted,"T = list(input()) + +if len(T) == 1: + print('D') + exit() + +if T[0] == '?': + if T[1] == 'P': + T[0] = 'D' + else: + T[0] = 'P' + + +for i in range(1, len(T)-1): + if T[i] == '?': + if T[i - 1] == 'D' and (T[i + 1] == 'D' or T[i + 1] == '?'): + T[i] = 'P' + else: + T[i] = 'D' + +if T[-1] == '?': + T[-1] = 'D' + +print(''.join(T)) + +" +p02786,s076270066,Accepted,"h = int(input()) +c = 0 +while True: + if(h==1): + c = c+1 + break + else: + h = h//2 + c=c+1 + c=2*c +print(c) +" +p02624,s655822900,Wrong Answer,"N = int(input()) + +sum_ = N*(N+1)//2 +for i in range(2, N//2+1): + n = N // i + sum_ += i*(n*(n+1)//2) + +sum_ += (N//2+1 + N) * (N - (N//2+1) + 1) // 2 + +print(sum_)" +p02963,s316966791,Accepted,"import math +s=int(input()) +if s<=10**9: + print(0,0,1,0,0,s) +else: + b=int(math.ceil(s/10**9)) + a=10**9*b-s + print(0,0,10**9,1,a,b)" +p03408,s058335168,Accepted," +def main(): + b = int(input()) + d = dict() + + for i in range(b): + s = input() + if s in d: + d[s] += 1 + else: + d[s] = 1 + + r = int(input()) + + for i in range(r): + s = input() + if s in d: + d[s] -= 1 + else: + d[s] = -1 + + print(max(max(d.values()),0)) + + + + + + + +if __name__ == '__main__': + main() +" +p03329,s077484759,Accepted,"N = int(input()) +A = [1, 6, 6**2, 6**3, 6**4, 6**5, 6**6, 9, 9**2, 9**3, 9**4, 9**5] +dp = [1000000] * 300000 +dp[0] = 0 + +for i in range(N): + for a in A: + d = dp[i] + 1 + dp[i + a] = min(dp[i + a], d) + +print(dp[N])" +p03485,s165609907,Accepted,"import math + +a, b = map(int, input().split()) +ans = math.ceil((a + b) / 2) +print(ans)" +p02759,s630374854,Accepted,"x = int(input()) +print((x+1)//2)" +p03494,s204375149,Wrong Answer,"n = int(input()) +a = [int(x) for x in input().split()] +ans = 0 + +for i in a: + if not i%2: + break + + else: + ans += 1 + +print(ans)" +p03835,s005929395,Accepted,"k,s=map(int,input().split()) +ans=0 +for x in range(k+1): + for y in range(k+1): + z = s - x - y + if z >=0 and z <= k: + ans+=1 +print(ans) +" +p02732,s463682041,Accepted,"N=int(input()) +m=list(map(int,input().split())) +t=[] +for i in range(N): + t.append(0) +for i in range(N): + t[m[i]-1]+=1 +total=0 +for i in range(N): + total+=(t[i]*(t[i]-1))//2 +for i in range(N): + if t[m[i]-1]<2: + print(total) + else: + print(total-(t[m[i]-1]-1))" +p03998,s782702830,Accepted,"#!/usr/bin/env python3 +S={c:list(input()) for c in ""abc""} +s=""a"" +while S[s]:s=S[s].pop(0) +print(s.upper())" +p03323,s727897420,Wrong Answer,"a,b=map(int,input().split()) + +if a>8 or b>8: + print("":("") +else : + print(""yay!"")" +p02773,s907344030,Wrong Answer,"n=int(input()) +moto=[0]*n +for k in range(0,n): + moto[k]=input() +syurui=list(set(moto)) +kosu=[0]*len(syurui) +for k in range(0,len(syurui)): + kosu[k]=moto.count(syurui[k]) +answer=[] +for k in range(0,len(syurui)): + if moto.count(syurui[k])==max(kosu): + answer.append(syurui[k]) +for k in range(0,len(answer)): + print(answer[k])" +p02642,s660883041,Accepted,"from collections import Counter + +n = int(input()) +a = list(map(int, input().split())) + +a.sort() +cnt = 0 +nmax = a[-1] +table = [True] * (nmax+1) +c = Counter(a) + +duplicate = [] +for i in c.keys(): + if c[i] > 1: + duplicate.append(i) +for i in a: + if not table[i]: + continue + if not i in duplicate: + cnt += 1 + for j in range(i*2, nmax+1, i): + table[j] = False +print(cnt)" +p02645,s547791044,Accepted,print(input()[:3]) +p02760,s892854983,Wrong Answer,"print(""Yes"")" +p02718,s922207168,Accepted,"n,m=map(int,input().split()) +a=list(map(int,input().split())) +s=sum(a) +ans=0 +for i in a: + if i>=s/(4*m): + ans+=1 +if ans>=m: + print(""Yes"") +else: + print(""No"")" +p02578,s614856232,Wrong Answer,"N=int(input()) +A=B=list(map(int,input().split())) +s=j=N+1 +sum_A=0 + +if A==sorted(A): + print(0) + exit() + +for i in range(1,N): + x=max(B[:s]) + s=B.index(x) + B[s:j]=[x]*len(B[s:j]) + j=s + if s==0: + break + +print(sum(B)-sum(A))" +p03617,s000667932,Accepted,"Q, H, S, D = list(map(int, input().split())) +Q *= 8 +H *= 4 +S *= 2 +A = min(Q, H, S, D) +B = int(min(Q, H, S) / 2) +N = int(input()) + +print(int(N//2*A+N%2*B))" +p03695,s997863280,Accepted,"from collections import defaultdict + +def readInt(): + return int(input()) +def readInts(): + return list(map(int, input().split())) +def readChar(): + return input() +def readChars(): + return input().split() + +n = readInt() +a = readInts() +rate = [0]*9 + + +for i in a: + rate[min(i//400,8)]+=1 +base = 8-rate[:-1].count(0) +ma = base+rate[-1] +print(max(base,1),ma) +" +p02660,s299630951,Wrong Answer,"import math +N = int(input()) +L = N +if L == 1: + print(0) +else: + num = 0 + if L > 100000000: + limit = int(math.sqrt(L)) + 2 + else: + limit = L + for i in range(2, limit): + if N % i == 0: + N = N / i + num = num + 1 + + if num == 0: + print(1) + else: + print(num)" +p03250,s605783519,Accepted,"A = input().split() +A.sort(reverse=True) +print(int(A[0]+A[1])+int(A[2])) +" +p03759,s367503017,Wrong Answer,"a,b,c = map(int,input().split()) + +x = b - a +y = c - b + +if x is y: + print(""YES"") + +else: + print(""NO"") " +p03379,s783042516,Accepted,"n = int(input()) +x = [(ind, int(i)) for ind, i in enumerate(input().split())] +x.sort(key=lambda x:x[1]) +ans = [None]*n +l = x[n//2-1][1] +r = x[n//2][1] +for ind, (i, _) in enumerate(x): + if ind= k else k-a)))" +p03627,s822874914,Wrong Answer,"from collections import Counter + +N = int(input()) +A = list(map(int, input().split())) + +d = Counter(A) + +tmp_2 = [] +tmp_4 = [] +for k, v in d.items(): + if v >= 4: + tmp_4.append(k) + elif v >= 2: + tmp_2.append(k) + +ans = 0 +if len(tmp_4): + ans = tmp_4[-1]**2 +if len(tmp_2) >= 2: + ans = max(ans, tmp_2[-1]*tmp_2[-2]) +print(ans)" +p03838,s744130174,Wrong Answer,"x, y = map(int, input().split()) + +if 0 <= x and x <= y: + print(y-x) +elif x < 0 and 0 <= y: + if abs(x) <= y: + print(1 + y - abs(x)) + else: + print(-y-x+1) +elif x < y and y < 0: + print(y-x) +elif 0 <= y and y <= x: + print(1-y+x+1) +elif y < 0 and 0 <= x: + print(1+abs(y+x)) +elif y < x and x < 0: + print(1-y+x+1)" +p03835,s893364134,Wrong Answer,"#import +#import math +#import numpy as np +#= int(input()) +#= input() +K, S = map(int, input().split()) +#= list(map(int, input().split())) +#= [input(), input()] +#= [list(map(int, input().split())) for _ in range(N)] +#= {i:[] for i in range(N)} + +r = 0 + +for i in range(K + 1): + for j in range(K + 1): + if S - (i + j) <= K: + r += 1 + +print(r)" +p03126,s812996887,Wrong Answer,"n,m=map(int,input().split()) +x=[] +sum=0 +for i in range(n): + s=list(map(int,input().split())) + x+=s +for i in range(1,m+1): + if x.count(i)==n: + sum+=1 +print(sum)" +p02743,s478284548,Accepted,"import numpy as np + +a, b, c = map(int, raw_input().split()) + +if b > a: + temp = a + a = b + b = temp + +res = c - a +res = res - b +temp = 4*a*b + + +if res <0: + print ""No"" +elif res**2 > temp: + print ""Yes"" +else: + print ""No"" +" +p02607,s143709162,Accepted,"n = int(input()) +A = list(map(int, input().split())) +ans = 0 +for i in range(n): + if A[i] % 2 == 1 and (i + 1) % 2 == 1: + ans += 1 +print(ans)" +p03548,s451195287,Accepted,"X,Y,Z=map(int,input().split()) +X-=Z +print(X//(Z+Y))" +p02897,s012525108,Wrong Answer,"n = int(input()) + +if n % 2 == 0: + print(n / 2) +elif n % 2 == 1: + print(n / ((n + 1) / 2))" +p03986,s728390887,Accepted,"x=list(input()) +s=0 +t=0 +ans=0 +for i in range(len(x)): + if x[i]==""S"": + s+=1 + + else: + if s==0: + ans+=1 + else: + s-=1 + +print(ans+s)" +p03254,s764241819,Accepted,"N, x = map(int, input().split()) +A = sorted(list(map(int, input().split()))) + +if x>sum(A): + print(N-1) + exit() + +if x==sum(A): + print(N) + exit() + +ans = 0 +for i in range(N): + if sum(A[:i]) <= x: + ans = i +print(ans)" +p02953,s022685597,Accepted,"N = int(input()) +H = list(map(int, input().split())) + +flg = True +for i in range(N-2, 0, -1): + if H[i] - 1 > H[i+1]: + flg = False + break + else: + if H[i] > H[i+1]: H[i] -= 1 +if flg: + print('Yes') +else: + print('No') +" +p03493,s356217522,Accepted,"a = input() +c = [int(c) for c in a] + +print(c.count(1))" +p03478,s535012730,Accepted,"N, A, B = map(int, input().split()) + +ans = 0 +for i in range(1, N+1): + k = list(str(i)) + sum_i = 0 + for j in k: + sum_i += int(j) + if A <= sum_i <= B: + ans += i + +print(ans)" +p04043,s775538061,Accepted,"a=input().split() +if a.count('5')==2 and a.count('7')==1: + print('YES') +else: + print('NO')" +p02641,s360348821,Wrong Answer,"import numpy as np +X,N=map(int,input().split()) +p=np.array(list(map(int,input().split()))) +ans=np.array([X,X]) +while True: + ans+=[-1,1] + if ans[0] not in p: + print(ans[0]) + exit() + if ans[1] not in p: + print(ans[1]) + exit() + +" +p02645,s958578366,Accepted,print(input()[:3]) +p03208,s878393226,Accepted,"n,k=map(int,input().split()) +h=list(int(input()) for _ in range(n)) +h.sort() +s=[abs(h[i+k-1]-h[i]) for i in range(n-k+1)] +print(min(s))" +p03672,s598104680,Wrong Answer,"s = list(input()) + +def check(L): + if len(L)%2 != 0: + return False + + n = int(len(L)/2) + if L[:n] == L[n:]: + #print(L[:n],L[n:]) + return True + + +#print(check(s)) + +for i in range(1,len(s)): + m = len(s) - i + if check(s[0:m]): + print(m)" +p02607,s861242625,Accepted,"N = int(input()) +A = [int(x) for x in input().split()] + +C = 0 +for i in range(0,N,2): + if A[i] % 2 == 1: + C += 1 + +print(C)" +p03672,s090111769,Wrong Answer,"s=input() +print(len(s)/2) +" +p02699,s626336842,Accepted,"inputLine = input() + +tempStr = inputLine.split(' ') + +numSheep = int(tempStr[0]) +numWolf = int(tempStr[1]) + + +print(""unsafe"" if numWolf >= numSheep else ""safe"") + + +" +p04030,s378689383,Accepted,"s = input() +ans = [] +for i in range(len(s)): + if s[i] != 'B': + ans.append(s[i]) + else: + if len(ans) == 0: + pass + else: + ans.pop() +print(''.join(ans))" +p03448,s048968981,Wrong Answer,"# A == 10 +# B == 2 +# C == 1 +#最後に50倍 + +a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +x = x / 50 +count = 0 + +for h in range(a +1): + for i in range(b +1): + for j in range(c +1): + if a + b + c == x: + count += 1 + +print(count)" +p03474,s480335681,Wrong Answer,"a,b = map(int,input().split()) +s = input() + +lst = s.split(""-"") +print(lst) +if len(lst[0]) == a and len(lst[1]) == b and len(lst) == 2: + print(""Yes"") +else: + print(""No"")" +p03103,s138700988,Accepted,"n, m = map(int, input().split()) +l = [] +c = 0 +for _ in range(n): + l += [list(map(int, input().split()))] +for i, j in sorted(l, key=lambda x: x[0]): + if j >= m: + c += m*i + print(c) + exit() + m -= j + c += i*j" +p02792,s168763750,Accepted,"from collections import defaultdict + +n = int(input()) +d = defaultdict(int) + +for i in range(1,n+1): + s = str(i) + k = (s[0],s[-1]) + d[k] += 1 + +ans = 0 +for i in range(1,n+1): + s = str(i) + k = (s[-1],s[0]) + ans += d[k] +print(ans) +" +p02576,s060668024,Wrong Answer,"N,K,T=map(int,input().split()) +if N%K==0: + print((N%K)*T) +else: + print(((N//K)+1)*T) + " +p02772,s113903191,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +flag = False +for i in range(N): + if A[i] % 2 == 0: + if (A[i] % 3 == 0) or (A[i] % 5 == 0): + flag = True + else: + flag = False + break + +if flag == True: + print(""APPROVED"") +else: + print(""DENIED"")" +p02633,s563220961,Accepted,"x = int(input()) + +kaiten=360 +while kaiten%x!=0: + kaiten+=360 + +print(kaiten//x) +" +p02910,s062599802,Accepted,"s = input() +if 'L' in s[::2] or 'R' in s[1::2]: + print('No') +else: + print('Yes')" +p03627,s175570516,Wrong Answer,"from collections import Counter + +n = int(input()) +c = Counter(map(int, input().split())) +c = sorted((e for e in c.items() if e[1] > 1), key=lambda e: -e[1]) +if len(c) < 2: + print(0) +elif c[0][1] >= 4: + print(c[0][0] ** 2) +else: + print(c[0][0] * c[1][0])" +p03456,s508218731,Wrong Answer,"#8 +a,b = input().split() +c = int(a + b) +ans = 0 + +for i in range(100+1): + if i*i == c: + ans = 1 +if ans == 0: + print('No') +else: + print('Yes')" +p02820,s769593186,Accepted,"N, K = map(int, input().split()) +R, S, P = map(int, input().split()) +T = input() +L = [0]*N +dic = dict() +dic[""r""] = P +dic[""s""] = R +dic[""p""] = S +dic[""0""] = 0 +res = 0 +for i in range(N): + if i < N-K and T[i] == T[i+K] and L[i] == 0: + L[i+K] = 1 + if L[i] == 0: + res += dic[T[i]] +print(res)" +p02624,s847418079,Accepted,"import math + +n = int(input()) +answer = 0 +c = 0 +b = 0 +for i in range(1,n+1): + b = n//i + c = i*b*(b+1)/2 + answer = answer + c +print(int(answer))" +p02678,s257816199,Wrong Answer,"from collections import deque + +n, m = map(int, input().split()) + +graph = [[] for _ in range(n+1)] +for i in range(m): + a,b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +print(graph) + +dist = [0] * (n + 1) + +d=deque() +d.append(1) + +while d: + v = d.popleft() + + for i in graph[v]: + if not dist[i]: + dist[i] = v + d.append(i) + +ans = dist[2:] +print('Yes') +print(*ans,sep='\n') + +" +p02548,s430769543,Accepted,"from functools import lru_cache +N = int(input()) +# A * B <= N - 1はいくつありますか? +count = 0 +# A ∈ {1, 2, ..., N-1} +for A in range(1, N): + # B <= (N - 1) // A + count += (N - 1) // A +print(count)" +p02790,s534757007,Accepted,"a, b = map(int, input().split()) +print(str(min(a, b)) * max(a, b)) +" +p03997,s831994458,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) +print((a + b) * h // 2)" +p02714,s906913823,Accepted,"n=int(input()) +s=input() + +r_cnt=s.count(""R"") +g_cnt=s.count(""G"") +b_cnt=s.count(""B"") + +ans=r_cnt*g_cnt*b_cnt + +for i in range(n): + for d in range(n): + j=i+d + k=j+d + if k>=n:break + if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]: + ans -= 1 + +print(ans)" +p03285,s594236630,Wrong Answer,"from math import ceil + +N = int(input()) +is_possible = False + +for i in range(ceil(N/4)): + for j in range(ceil(N/7)): + if 4*i+7*j == N: + is_possible = True + +if is_possible: + print(""YES"") +else: + print(""NO"")" +p02688,s397406651,Accepted," +def main(): + N, K = map(int, input().split()) + + ds = [] + current_members = set(range(1,N+1)) + for i in range(K): + d = int(input()) + members= map(int, input().split()) + current_members -= set(members) + + #print(current_members) + print(len(current_members)) + + +if __name__ == '__main__': + main() +" +p02767,s643334748,Accepted,"n = int(input()) +x = list(map(int, input().split())) +ans = float('inf') +energy = [] + +for i in range(1, 101): + for j in x: + energy.append((j - i) ** 2) + sum_energy = sum(energy) + if sum_energy < ans: + ans = sum_energy + energy = [] + +print(ans)" +p02571,s280521868,Accepted,"import sys +import math +S = str(input()) +T = str(input()) + + +d = 0 +for i,o in enumerate(S): + j = 0 + c = 0 + for l in S[i:i+len(T)]: + if l == T[j]: + c += 1 + j += 1 + d = max(d, c) + if i > len(S) - len(T) - 1: + break +print(len(T)-d) + " +p02963,s293850187,Accepted,"s=int(input()) +ans1=s//10**9+1 +ans2=10**9-s%10**9 +if s==10**18: + print(0,0,10**9,0,0,10**9) +else: + print(0,0,10**9,1,ans2,ans1) +" +p03282,s237407446,Wrong Answer,"s= input() +fn1 = ""-1"" +for i in range(len(s)): + if s[i] != ""1"": + fn1 = s[i] + break +print(""1"" if fn1 == ""-1"" else fn1)" +p02694,s590252243,Accepted,"X = int(input()) +amt = 100 +year = 0 +while amt < X: + amt = int(amt * 1.01) + year += 1 +print(year)" +p02658,s572643347,Wrong Answer,"n = input() +a = map(int, input().split()) +ans = 1 +for i in a: + ans *= i + if ans > 10**18: + print(-1) + exit() +print(ans)" +p02811,s350152132,Accepted,"k, x = map(int, input().split()) +if 500 * k >= x: + print(""Yes"") +else: + print(""No"") +" +p02547,s088278562,Accepted,"# coding: utf-8 + +def main(): + n = int(input()) + count = 0 + for _ in range(n): + d1, d2 = map(int, input().split()) + if d1 == d2: + count += 1 + else: + count = 0 + if count >= 3: + print('Yes') + return + print('No') + +main() + +" +p02994,s527378692,Accepted,"n,l = map(int,input().split()) + +ans = 0 +if l >= 0: + for i in range(n-1): + ans += l+i+1 +elif l <= 0 <= l+n-1: + for i in range(n): + ans += l+i +else: + for i in range(n-1): + ans += l + i +print(ans) +" +p03804,s810570502,Wrong Answer,"import sys + +n,m = map(int,input().split()) + +a_list = [[l for l in input()] for _ in range(n)] +b_list = [[l for l in input()] for _ in range(m)] + +for i in range(n-m): + for j in range(n-m): + a_list_sub = a_list.copy() + a_list_sub = a_list[i:i+m] + a_list2 = [row[j:j+m] for row in a_list_sub] + if a_list2 == b_list: + print('Yes') + sys.exit() + +print('No') " +p02957,s215347608,Accepted,"a, b = map(int, input().split()) +print((a+b)//2 if (a+b)%2 == 0 else ""IMPOSSIBLE"") +" +p03838,s883511068,Accepted,"x, y = map(int, input().split()) +ans = abs(abs(x)-abs(y)) + +if abs(y) > abs(x): + if x < 0: + ans += 1 + if y < 0: + ans += 1 + +else: + if x > 0: + ans += 1 + if y > 0: + ans += 1 +print(ans) + + +" +p02706,s162204000,Wrong Answer,"# AtCoder +N, M = map(int, input().split()) +A = list(map(int, input().split())) + +sm = sum(A) +count = N - sm +print(count) +" +p02572,s607489819,Wrong Answer,"N = int(input()) +nums = list(map(int,input().split())) +sum = 0 + +for i in range(N): + for j in range(N): + if i == j or i > j : + continue + else: + sum += nums[i]*nums[j] + +print(sum%10**9+7)" +p02702,s439626468,Accepted,"s = str(input()) +n = len(s) +x = [0]*2019 +x[0] = 1 +m = 0 +j = 1 +for i in range(n): + m = (m + int(s[-i-1])*j)%2019 + x[m] += 1 + j = (j*10)%2019 +ans = 0 +for i in range(2019): + ans += (x[i]*(x[i]-1))//2 +print(ans)" +p03360,s793861885,Wrong Answer,"a,b,c=map(int,input().split()) +k=int(input()) + +kazu=[a,b,c] +kazu.sort() +#print(kazu) +print(a+b+kazu[2]*2**k)" +p04045,s110690821,Accepted,"n,k=map(int,input().split()) +d=list(input().split()) +for j in range(n, 100000): + flg=False + for s in set(str(j)): + if s in d: + flg=True + break + if flg==False: + print(j) + break" +p02707,s627872685,Accepted,"num_sub = int(input()) +sub_boss = input().split() + +num_boss = [0]*(num_sub) + +for i in sub_boss: + i = int(i) + num_boss[i-1] = num_boss[i-1] + 1 + +for i in num_boss: + print(i)" +p02786,s943128721,Wrong Answer,"a = int(input()) +b = int(1) + +for i in range(114514): + a = a // 2 + b = b + 1 + if a == 1: + break + else: + pass + +print(2 ** b - 1)" +p03633,s726226009,Wrong Answer,"n = int(input()) +t = [int(input()) for _ in range(n)] +ans = t[0] + +for v in t: + if ans < v: + if v % ans != 0: + ans *= v + else: + ans = v + +print(ans)" +p03803,s902607129,Accepted,"a,b = map(int, input().split()) +poker = [2,3,4,5,6,7,8,9,10,11,12,13,1] +if poker.index(a) == poker.index(b): + print(""Draw"") +elif poker.index(a) > poker.index(b): + print(""Alice"") +else: + print(""Bob"")" +p02995,s600005332,Accepted,"import math + +def main(): + A, B, C, D = map(int, input().split()) + lcm = C * D // math.gcd(C, D) + C_div = B // C - (A - 1) // C + D_div = B // D - (A - 1) // D + C_D_div = B // lcm - (A - 1) //lcm + print(B - A + 1 - C_div - D_div + C_D_div) + + +if __name__ == '__main__': + main() +" +p03030,s792080230,Accepted,"from operator import itemgetter +n = int(input()) +s = [] +p = [] +b = [] +cnt = 1 +while True: + try: + ts,tp = map(str,input().split()) + s.append(ts) + p.append(int(tp)) + b.append((ts,int(tp),cnt)) + cnt +=1 + except: + break + +data = sorted(b, key=itemgetter(1), reverse=True) +data = sorted(data, key=itemgetter(0), reverse=False) + +for i in data: + print(i[2])" +p02706,s545246879,Accepted,"n,m = map(int, input().split()) +x = n-sum(list(map(int, input().split()))) + +if x < 0: + print(-1) +else: + print(x) +" +p03001,s537395760,Accepted,"import bisect,collections,copy,itertools,math,string +import sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip.split()) +def main(): + w,h,x,y = LI() + area = w * h + ans1 = area /2 + ans2 = 0 + if w == 2*x and h == 2*y: + ans2 = 1 + + print(ans1,ans2) + +main()" +p03105,s271509817,Wrong Answer,"x, y, z = map(int,input().split()) +print(max(int(y//x), z))" +p02787,s744309788,Accepted,"h, n = map(int, input().split()) +ab = [list(map(int, input().split())) for _ in range(n)] +max_a = max(a for a, _ in ab) +dp = [10 ** 18 for _ in range(h + max_a)] +dp[0] = 0 +for i in range(1, h + max_a): + dp[i] = min(dp[i-a] + b for a, b in ab) +print(min(dp[h:])) +" +p02820,s804875810,Accepted,"N, K = map(int, input().split()) +points = {c: p for c, p in zip(""spr"", map(int, input().split()))} +strings = [[] for _ in range(K)] +counts = [1] * K +ans = 0 +for i, c in enumerate(list(input()) + [""""] * K): + idx = i % K + if strings[idx]: + last = strings[idx][-1] + if c == last: + counts[idx] += 1 + else: + ans += ((counts[idx] + 1) >> 1) * points[last] + counts[idx] = 1 + strings[idx].append(c) +print(ans)" +p02973,s063796690,Accepted,"import bisect +n = int(input()) +colors = [-1]*(n+1) +for _ in range(n): + a = int(input()) + idx = bisect.bisect_left(colors, a)-1 + colors[idx] = a +print(n-bisect.bisect_left(colors, 0)+1) +" +p03017,s717644791,Accepted,"def main(): + N, a, b, c, d = (int(i) for i in input().split()) + S = input() + if ""##"" in S[a:c] or ""##"" in S[b:d]: + return print(""No"") + if c < d: + return print(""Yes"") + # d < c + if ""..."" in S[b-2:d+1]: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + main() +" +p03623,s451218142,Accepted,"x,a,b = map(int,input().split()) +if abs(x - a) < abs(x - b): + print('A') +else: + print('B')" +p03380,s408723545,Accepted,"#!/usr/bin/env python3 + +N = int(input()) +A = sorted(list(map(int, input().split())))[::-1] + +h = A[0]/2 +r = 10**9 +v = 0 +for a in A[1:]: + if r > abs(a-h): + r = abs(a-h) + v = a + +print(str(A[0]) + ' ' + str(v)) +" +p03385,s138256906,Wrong Answer,"def readints(): + return list(map(int, input().split())) + + +s = str(input()) +t = ['a', 'b', 'c'] +print(sorted(s)) +# print(t) +sum = 0 +for i in range(3): + if s[i] == t[i]: + sum += 1 +if sum == 3: + print(""Yes"") +else: + print(""No"") +" +p02909,s993782895,Accepted,"S = input() +if S == ""Sunny"": + print('Cloudy') +elif S == 'Cloudy': + print('Rainy') +else: + print('Sunny')" +p02987,s609272194,Accepted,"# Python3 (3.4.3) +import sys +input = sys.stdin.readline + +# ------------------------------------------------------------- +# function +# ------------------------------------------------------------- + + +# ------------------------------------------------------------- +# main +# ------------------------------------------------------------- +S = list(input().rstrip()) + +S.sort() +print(""Yes"" if S[0]==S[1] and S[2]==S[3] and S[0]!=S[-1] else ""No"")" +p02640,s763308364,Accepted,"x, y = map(int, input().split()) + +max = 4*x +min = 2*x + +if y % 2 == 0 and min <= y <= max: + print(""Yes"") +else: + print(""No"") +" +p03360,s266584849,Accepted,"a=list(map(int,input().split())) +k=int(input()) +for i in range(k): + a[a.index(max(a))]*=2 +print(sum(a))" +p02548,s507549444,Accepted," +def main(): + n = int(input()) + cnt = 0 + same = 0 + + for a in range(1, n): + for b in range(a, n): + if a * b >= n: + break + + cnt += 1 + if a == b: + same += 1 + + print((cnt - same) * 2 + same) + + + +main() +" +p02696,s003778390,Accepted,"a, b, n = map(int, input().split()) + + +def f(x): + return (a * x // b) - a * (x // b) + +print(f(min(b - 1, n))) +" +p03556,s965318943,Accepted,"import math +n = int(input()) +x = math.sqrt(n) +print (int(x)**2) +" +p04019,s627163762,Wrong Answer,"from collections import Counter +s = str(input()) +s = Counter(s).most_common() +if len(s)%2 == 0: + print('Yes') +else: + print('No')" +p03472,s731127187,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 7) +input = sys.stdin.readline + +n, h = map(int, input().split()) + +a = [0]* n +b = [0]* n +for i in range(n): + a[i], b[i] = map(int, input().split()) + +amax = max(a) +ans = 0 + +b.sort(reverse=True) + +for attack in b: + + if attack < amax: break + h -= attack + ans += 1 + if h <= 0: + exit() + +ans += -(-h//amax) + +print(ans) +" +p02987,s659567053,Wrong Answer,"S = input() +cnt = 0 +for i in range(len(S)-1): + for j in range(1, len(S)): + if S[i] == S[j]: + cnt += 1 + +if cnt == 2: + print(""Yes"") + +else: + print(""No"")" +p03997,s305942699,Accepted,print((int(input())+int(input()))*int(input())//2) +p03339,s350121575,Accepted,"n = int(input()) +s = input() +l = [0] +ans = 10**6 +for i,si in enumerate(s): + l.append(l[i]+(si==""W"")) +for i in range(n): + ans = min(ans,l[i]+(n-1-i)-(l[-1]-l[i+1])) + #print(i,f""W{l[i]} E{(n-1-i)-(l[-1]-l[i+1])}"",s[:i],s[i+1:]) +print(ans)" +p02622,s205900866,Accepted,"S = input() +T = input() + +ans = 0 + +if S == T: + ans = 0 +else: + for i, j in zip(S, T): + if i != j: + ans += 1 + +print(ans) +" +p02861,s764530561,Wrong Answer,"from math import factorial, sqrt + +def dist(x1, y1, x2, y2): + return sqrt((x1 - x2)**2 + (y1 - y2)**2) + + +N = int(input()) +x, y = [0]*N, [0]*N +for i in range(N): + x[i], y[i] = map(int, input().split()) + +ans = 0 +count = N * (N-1) / 2 + +for i in range(N-1): + for j in range(i+1, N): + ans += dist(x[i], y[i], x[j], y[j]) * count + +ans = ans / factorial(N) + +print(ans) +" +p02730,s662207759,Accepted,"def kalin(s): + N=len(s) + for i in range(N//2): + if s[i]!=s[-1-i]: + return False + return True + +def strong(s): + N=len(s) + tail = (N-1)//2 + s0=s[0:tail] + head = (N+3)//2 + s1=s[head-1:] + # print('s0={} s1={}'.format(s0,s1)) + return kalin(s0) and kalin(s1) and kalin(s) + +if strong(input()): + print('Yes') +else: + print('No')" +p03208,s788957843,Accepted," +N, K = map(int, input().split()) +X = [int(input()) for _ in range(N)] + +X.sort() +res = 10 ** 9 + 7 +for i in range(N - K + 1): + res = min(res, X[i + K - 1] - X[i]) +print(res) +" +p03998,s625884631,Wrong Answer,"import sys + +S = {} +S[""a""] = list(sys.stdin.readline().strip()) +S[""b""] = list(sys.stdin.readline().strip()) +S[""c""] = list(sys.stdin.readline().strip()) + +target = ""a"" +while True: + next_target = S[target].pop() + if len(S[target]) == 0: + break + target = next_target + +print(target.upper())" +p03457,s801696783,Accepted,"n = int(input()) + +t=[] +x=[] +y=[] + +for i in range(n): + a,b,c = map(int,input().split()) + t.append(a) + x.append(b) + y.append(c) + + +ans = True +move=(x[0]+y[0]) +time = t[0] - 0 +if move > time:ans = False +if (time - move)%2 ==1:ans = False + +for i in range(1,n): + move =x[i] + y[i] - x[i-1] - y[i-1] + time =t[i] - t[i-1] + if move > time:ans = False + if (time - move)%2 ==1:ans = False + +if ans: + print(""Yes"") +else: + print(""No"") + +" +p03371,s440424433,Accepted,"a, b, c, x, y = map(int, input().split()) + +ans = 0 + +if a + b >= c * 2: + ans += min(x, y) * c * 2 + x, y = x - min(x, y), y - min(x, y) + if [a, b][y > x] >= c * 2: + ans += max(x, y) * c * 2 + else: + ans += [a, b][y > x] * max(x, y) +else: + ans += a * x + b * y + +print(ans) +" +p03076,s918949862,Accepted,"from itertools import permutations +import math +menu=5 +times=[int(input()) for i in range(menu)] +orders=list(permutations(times,menu)) +minimum=sum(math.ceil(time/10)*10 for time in times) +for order in orders: + total=order[0] + for i in range(1,menu): + total+=math.ceil(order[i]/10)*10 + minimum=min(minimum,total) +print(minimum)" +p04043,s534952516,Wrong Answer,"form = input() +form = form.split() + +if form == [5,7,5]: + print(""YES"") +else: + print(""NO"") +" +p02719,s995125406,Wrong Answer,"#!/usr/bin/env python3 +import collections +import itertools as it +import math +import numpy as np + +# = input() +# = int(input()) +N, K = map(int, input().split()) +# = list(map(int, input().split())) +# = [int(input()) for i in range(N)] +# +# c = collections.Counter() + +if N > K: + seimin = N - (N//K) * K + print(min(seimin, abs(seimin-K))) +else: + print(N) +" +p02699,s773923049,Wrong Answer,"x, y = input().split() +if x <= y: + print(""unsafe"") +else: + print(""safe"")" +p03042,s856106690,Wrong Answer,"s = input() +if (int(s[:2]) > 12)&(int(s[2:]) <= 12)&(""00"" not in s): + print(""YYMM"") + +elif (int(s[:2]) <= 12)&(int(s[2:]) > 12)&(""00"" not in s): + print(""MMYY"") + +elif (int(s[:2]) <= 12)&(int(s[2:]) <= 12)&(""00"" not in s): + print(""AMBIGUOUS"") + +else: + print(""NA"")" +p04005,s606242772,Wrong Answer,"A, B, C = map(int,input().split()) + +if A % 2 != 0 and B % 2 != 0 and C % 2 != 0: + tmp1 = A * B + tmp2 = C // 2 + tmp3 = C - tmp2 + ans = tmp1 * tmp3 - tmp1 * tmp2 + print(ans) +else: + print(0)" +p02744,s907913770,Accepted,"ans = [] +type = [[1]] +que = [] +N = int(input()) +for i in range(N-1): + que = type + type = [] + while len(que) != 0: + t = que.pop() + ma = max(t) + for j in range(1,ma+2): + type.append(t + [j]) +type.sort() +char = "" abcdefghijklmnopqrstuvwxyz"" +for a in type: + print("""".join(map(lambda x: char[x], a))) +" +p02548,s783227884,Wrong Answer,"N = int(input()) + +count = 0 + +for a in range(N + 1): + for b in range(N + 1): + c = N - a * b + + if c >= 0: + count += 1 + +print(count) +" +p02860,s937019210,Accepted,"N = int(input()) +S = input() + +if N % 2 == 0: + n = N // 2 + if S[0:n] == S[n:N]: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p03241,s625719176,Wrong Answer,"def main(): + N, M = map(int, input().split()) + search = M//N + 1 + for s in range(search, 0, -1): + sum_array = s * N + remain = M - sum_array + if remain % s == 0: + print(s) + return + +if __name__ == ""__main__"": + main() +" +p04029,s610032257,Accepted,"N=int(input()) +ans=0 +for i in range(N+1): + ans+=i +print(ans)" +p04044,s986851269,Accepted,"n,l=map(int,input().split()) +s=sorted(list(input() for i in range(n))) +ans=' ' +for i in range(n): + ans+=s[i] +print(ans)" +p03069,s935673303,Wrong Answer,"from itertools import accumulate +N = int(input()) +S = list(input()) +kuro = [0]*N +shiro = [0]*N +ans = N + +for i in range(N): + if S[i] == ""#"": + kuro[i] = 1 + else: + shiro[i] = 1 +shiro.reverse() +shiro = list(accumulate(shiro)) +kuro = list(accumulate(kuro)) + +for i in range(N-1): + ans = min(ans, kuro[i]+shiro[N-i-2]) + +ans = min(ans, kuro[N-1]) + +print(ans) +" +p03495,s894075493,Accepted,"N, K = [int(x) for x in input().split()] +A_lst = [int(x) for x in input().split()] +dict = {} +for i in A_lst: + if not i in dict.keys(): + dict[i] = 1 + else: + dict[i] += 1 + +lst = [] +for i in dict.keys(): + lst.append(dict[i]) +lst.sort() +k = len(lst) +cnt = 0 + +for i in lst: + if k <= K: + break + else: + k -= 1 + cnt += i + +print(cnt) +" +p03730,s703364771,Accepted,"A,B,C=list(map(int,input().split())) +for i in range(1,B+1): + if A*i%B==C: + print(""YES"") + exit() +print(""NO"")" +p04030,s639123516,Wrong Answer,"li = list(input()) +ans = """" +for i in range(len(li)): + if li[i] == 0: + ans = ans + ""0"" + elif li[i] == 1: + ans = ans + ""1"" + elif li[i] == ""B"": + ans = ans[:len(ans)-1] +print(ans)" +p02957,s621032637,Accepted,"a,b=map(int,input().split()) +if (a+b)%2==0: + print((a+b)//2) +else: + print('IMPOSSIBLE')" +p03639,s645185817,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +count = 0 +count2 = 0 +for i in range(N): + if a[i]%4 == 0: + count += 1 + elif a[i]%2 == 0: + count2 += 1 +if count2 == 0: + if N//2 <= count + 1: + print(""Yes"") + else: + print(""NO"") +else: + if N-count2 <= count*2: + print(""Yes"") + else: + print(""NO"")" +p02706,s130035288,Accepted,"#!/usr/bin/env python3 + +from pprint import pprint +import sys + +sys.setrecursionlimit(10 ** 6) +input = sys.stdin.buffer.readline + +n, m = map(int, input().split()) +a = [] +a = list(map(int, input().split())) + +if sum(a) > n: + print('-1') +else: + print(n - sum(a)) +" +p03239,s008543854,Wrong Answer,"N,T=list(map(int,input().split())) +minCos = 10000 +ans = 0 +for i in range(N): + c,t=list(map(int,input().split())) + if t < T: + if min(minCos,c) == c: + ans = i+1 + minCos = c +if ans == 0: + print(""TLE"") +else: + print(ans)" +p03494,s519247458,Accepted,"n = int(input()) +nums = [int(x) for x in input().split()] +ops = 0 +cont = 1 +while cont: + for x in range(n): + if nums[x] % 2 == 0: + nums[x] = nums[x]/2 + else: + cont = 0 + break + ops += cont +print(ops)" +p03208,s346157104,Accepted,"N, K = map(int, input().split()) +h = [int(input()) for _ in range(N)] + +h.sort() + +ans = 10**10 + +for i in range(N-K+1): + ans = min((h[i+K-1] - h[i]), ans) +print(ans)" +p03478,s634310910,Accepted,"n, a, b = map(int, input().split()) +ans = 0 +for i in range(1, n + 1): + c = 0 + t = i + for j in range(5): + c += t % 10 + t //= 10 + if a <= c and c <= b: + ans += i +print(ans) +" +p02820,s995850890,Accepted,"n, k = map(int, input().split()) +s, p, r = map(int, input().split()) +t = input() +pre = ""0"" +ans = 0 + +for i in range(k): + for j in t[i::k]: + if j != pre: + if j == ""s"": + ans += s + elif j == ""p"": + ans += p + elif j == ""r"": + ans += r + pre = j + else: + pre = ""0"" + pre = ""0"" + +print(ans)" +p02612,s097771349,Wrong Answer,"def main(): + N = int(input()) + print(1000 - (N % 1000)) + + +if __name__ == ""__main__"": + main() +" +p02792,s743593317,Wrong Answer,"# 整数の入力 +A = int(input()) +cnt = 0 +for i in range(1, A): + for j in range(1, A): + x = str(i) + y = str(j) + + first_x = x[0] + last_x = x[-1] + first_y = y[0] + last_y = y[-1] + + if(first_x == last_y and last_x == first_y): + cnt = cnt + 1 + continue + +print(cnt)" +p02973,s103858301,Accepted,"n=int(input()) +a=[int(input()) for _ in range(n)] +ans=[-a[0]] +ansl=1 +from bisect import bisect_right +for ai in a[1:]: + tmp=bisect_right(ans,-ai) + if tmpN: + print(count) + break + " +p02657,s579626882,Accepted,"a,b=map(int,input().split()) +print(a*b)" +p03087,s383049921,Accepted,"N, Q = map(int, input().split()) +S = input() +LR = [tuple(map(int, input().split())) for _ in range(Q)] + +cum = [0]*(N+1) + +cnt = 0 +for i in range(1,N): + if S[i-1] == 'A' and S[i] == 'C': + cnt += 1 + cum[i] = cnt + +ans = [] +for l, r in LR: + result = cum[r-1] - cum[l-1] + ans.append(result) + +print(*ans, sep='\n') +" +p02583,s381414104,Accepted,"N = int(input()) +L = list(map(int, input().split())) + +ans = 0 +for i in range(N): + for j in range(i+1,N): + for k in range(j+1,N): + if (L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and L[i]+L[j]+L[k] > 2*max(L[i],L[j],L[k])): + ans+=1 +print(ans)" +p03861,s518741938,Accepted,"a, b, x = map(int, input().split()) + +cnta = max((a - 1) // x + 1, 0) +cntb = b // x + 1 + +print(cntb - cnta)" +p03250,s596688990,Wrong Answer,"# input +ABC = list(map(int, input().split())) + +# check +ABC.sort() +X = 10 * ABC[0] + ABC[1] +Y = ABC[2] +print(X + Y) +" +p02647,s990572851,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +for i in range(K): + new = [0] * (N+1) + for j in range(N): + new[max(0, j-A[j])] += 1 + if j+A[j]+1 <= N-1: + new[j+A[j]+1] -= 1 + A[0] = new[0] + for j in range(1, N): + new[j] += new[j-1] + A[j] = new[j] + for ai in A: + if ai != N: + break + else: + break + +print(' '.join([str(ai) for ai in A])) +" +p03145,s957731937,Accepted,"a,b,c=map(int,input().split()) +print(int(a*b/2))" +p03759,s377158337,Accepted,"a,b,c = map(int,input().split()) + +if b-a == c-b: + print(""YES"") +else: + print(""NO"")" +p03319,s350171616,Accepted,"n, k = [int(i) for i in input().split()] +a = [int(i) for i in input().split()] + +for i in range(n): + if a[i] == 1: + break + +print((n+k-3)//(k-1))" +p02608,s898998826,Wrong Answer,"def fx(n): + cnt = 0 + + for i in range(1,10000): + if (i+1+1)**2 - i*1 - 1*1 - 1*i > n: break + for j in range(1, 10000): + if (1+j+1)**2 - 1*j - j*1 - 1*1 > n : break + for k in range(1, 10000): + formula = (i+j+k)**2 - i*j - j*k - k*i + if formula == n: + cnt+=1 + if formula >= n: + break + + return cnt + + +n = int(input()) +for i in range(1,n): + print(fx(i)) + +" +p02923,s513525107,Accepted,"n = int(input()) +h = list(map(int,input().split())) + +ans = 0 +height = h[0] +count = 0 +i = 1 +while i < n: + if h[i] <= height: + count += 1 + height = h[i] + i += 1 + else: + ans = max(ans,count) + count = 0 + height = h[i] + i += 1 +print(max(ans,count)) +" +p03474,s444613603,Wrong Answer,"a,b=map(int,input().split()) +s=str(input()) +c=0-b +if s[:a-1].isdecimal()==True and s[c:].isdecimal()==True and s[a]==""-"": + print(""Yes"") +else: + print(""No"")" +p03137,s128476997,Wrong Answer,"if __name__ == '__main__': + n,m = map(int,input().split()) + A = list(map(int,input().split())) + A.sort() + + B = [] + for i in range(m-1): + #差分を求める + B.append(A[i+1] - A[i]) + B.sort() + + print(sum(B[:m-n]))" +p03059,s022747991,Accepted,"def main(): + A, B, T = map(int, input().split()) + + ans = int(((T + 0.5) // A) * B) + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03555,s971148759,Wrong Answer,"c1 = input() +c2 = input() + +print(""Yes"" if c1 == c2[::-1] else ""No"")" +p02744,s322431328,Accepted,"N = int(input()) + +lst = [['a']] +for i in range(N - 1): + n = len(lst) + tmp_lst = [] + tmp_append = tmp_lst.append + for j in range(n): + tmp = lst[j] + count = len(set(tmp)) + for k in range(count + 1): + tmp_append(tmp + [chr(k + 97)]) + lst = tmp_lst +lst.sort() + +for tmp in lst: + print (*tmp, sep = '')" +p03456,s951044727,Accepted,"a,b=input().split() +c=int(a+b) +for i in range(1,1000): + if i*i==c: + print(""Yes"") + exit() +print(""No"")" +p02862,s325572544,Accepted,"def nCr(n_, r_, m_): + c = min(r_ , n_ - r_) + bunshi = 1 + bunbo = 1 + for i in range(1,c+1): + bunshi = bunshi * (n_+1-i) % m_ + bunbo = bunbo * i % m_ + return bunshi * pow(bunbo, m_-2, m_) % m_ + + +x,y = map(int,input().split()) +s = max(x,y) +t = min(x,y) +u = 2*t-s +if u%3 != 0 or u < 0: + print(0) +else: + a = u//3 + b = a + s - t + ans = nCr(a+b,b,10**9+7) + print(ans)" +p03457,s606395617,Wrong Answer,"N = int(input()) +xy=[] +try : + while True: + t = input().split() + t = list(map(int,t)) + if t: + xy.append(t) + else : + break +except EOFError: + pass +loc = [0,0] +time = 0 +for i in range(N): + a = xy[i] + time = a[0]-time + dis = abs(loc[0]-a[1])+abs(loc[1]-a[2]) + if (time-dis)<0 : + print(""No"") + exit() + elif (time-dis)%2 == 1: + print(""No"") + exit() + + else : + loc = [a[1],a[2]] + + +else : + print(""Yes"")" +p02900,s806795172,Accepted,"from math import sqrt +from fractions import gcd + +A, B = map(int, input().split()) + +ans = 1 + +g = gcd(A, B) + +for i in range(2, 1 + int(sqrt(g))): + + if g % i == 0: + ans += 1 + + while g % i == 0: + g //= i + +if g != 1: + ans += 1 + +print(ans) +" +p02730,s256117621,Accepted,"S = input() +S1, S2 = S[:(len(S) - 1) // 2], S[(len(S) + 3) // 2 - 1:] +print(""Yes"" if S[::-1] == S and S1[::-1] == S1 and S2[::-1] == S2 else ""No"") +" +p02866,s317295568,Accepted,"import collections +mod = 998244353 + +N = int(input()) +D = list(map(int,input().split())) + +if D[0] != 0 or 0 in D[1:]: + print(0) + exit() + +Dep = collections.Counter(D) +values, counts = zip(*Dep.most_common()) +#print(values) +#print(counts) +#print(Dep) +ans = 1 +for i in range(1,len(values)): + if Dep[i-1] == 0: + ans = 0 + ans *= pow(Dep[i-1],Dep[i], mod) + #print(i,Dep[i]) + ans %= mod +print(ans) +" +p03679,s340404192,Accepted,"x, a, b = map(int, input().split()) + +if b <= a: + print('delicious') +elif a < b <= a + x: + print('safe') +else: + print('dangerous')" +p03262,s575791299,Accepted,"import fractions + +N,X = map(int, input().split()) +S = list(map(int, input().split())) +S = [abs(s-X) for s in S] + +gcd = S[0] +for k in range(N-1): + gcd = fractions.gcd(gcd, S[k+1]) +print(gcd)" +p02917,s406635971,Accepted,"n = int(input()) +b = list(map(int, input().strip("""").split("" ""))) + +sum = 0 + +for i in range(n-2): + if b[i+1] > b[i]: + sum += b[i] + else: + sum += b[i+1] + +ans = sum + b[0] + b[n-2] + +print(ans)" +p04031,s487743113,Wrong Answer,"n = int(input()) +arr = list(map(int, input().split())) + +mini = min(arr) +maxi = max(arr) +cost = 10000 + +for i in range(mini, maxi+1): + add = 0 + for j in range(n): + add = add + (arr[j] - i)**2 + cost = min(cost, add) +print(cost)" +p03013,s940453330,Accepted,"import sys +input = sys.stdin.readline + + +n, m = map(int, input().split()) +a = [0] * m +dp = [0] * (n + 1) +mod = 10 ** 9 + 7 +for i in range(m): + a[i] = int(input()) +a = set(a) +dp[:2] = 1, 1 if 1 not in a else 0 + +for i in range(2, n + 1): + if i not in a: + dp[i] = (dp[i - 1] + dp[i - 2]) % mod +print(dp[-1]) +" +p04019,s849930366,Wrong Answer,"s = input() + +N,W,S,E = s.count(""N""),s.count(""W""),s.count(""S""),s.count(""E"") + +if (N > 0 and S == 0) or (N == 0 and S > 0) or (S > 0 and W == 0) or (S == 0 and W > 0): + print(""No"") +else: + print(""Yes"")" +p03455,s549992780,Accepted,"x1 = input().split("" "") +x2 = [int(i) for i in x1] + + +x3 = x2[0]*x2[1] + +if x3 % 2 == 0: + print(""Even"") +elif x3 % 2 == 1: + print(""Odd"") +" +p02553,s313578443,Wrong Answer,"a,b,c,d=map(int,input().split()) +ans=[a*b,a*c,a*d,b*c,b*d,c*d,0] +print(max(ans))" +p03379,s695756555,Accepted,"N = int(input()) +X = list(map(int, input().split())) + +mid1, mid2 = sorted(X)[N//2-1:N//2+1] +print('\n'.join(str(mid1) if xi>mid1 else str(mid2) for xi in X)) +" +p02759,s769351393,Accepted,"n = int(input()) +print(((n % 2 == 0) and (n // 2)) or (n // 2 + 1))" +p03998,s344042473,Accepted,"p=['a','b','c'] +l=[list(input()) for _ in range(3)] +x=0 +while True: + if l[x]==[]:break + x=p.index(l[x].pop(0)) +print(p[x].upper())" +p02958,s361388370,Accepted,"N = int(input()) +p = list(map(int, input().split())) +check = 0 +for i in range(N): + if i+1 != p[i]: + check += 1 +print(""YES"" if check <= 2 else ""NO"")" +p02731,s981506951,Accepted,"l = int(input()) +print(l ** 3 / 27)" +p03773,s449579155,Accepted,"a,b=map(int,input().split()) +print((a+b)%24)" +p02939,s517235863,Accepted,"# A - Dividing a String +def count_substrings(first_substring): + + arr = [first_substring] + i = len(first_substring) + + while i < len(S): + s = S[i] + + if s == arr[-1]: + if i + 1 < len(S): + i += 1 + s += S[i] + else: + arr[-1] += s + break + + arr.append(s) + i += 1 + + return len(arr) + + +S = input() + +ans1 = count_substrings(S[:1]) +ans2 = count_substrings(S[:2]) + +print(max(ans1, ans2))" +p04031,s758090505,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = 10**9 +for i in range(-100, 101): + cost = 0 + for j in a: + cost += (j-i)**2 + ans = min(ans, cost) +print(ans)" +p03625,s696127681,Accepted,"from collections import Counter + +n = int(input()) +A = list(map(int, input().split())) + +C = Counter(A) +C = [[k, v] for k, v in C.items() if v >= 2] +C.sort(key=lambda x:x[0], reverse=True) + +ans = 0 +if len(C) >= 1: + if C[0][1] >= 4: + ans = C[0][0] * C[0][0] + elif len(C) >= 2: + ans = C[0][0] * C[1][0] + +print(ans)" +p03284,s460044095,Accepted,"n,k=map(int,input().split()) +if n%k: + print(1) +else: + print(0)" +p02899,s906414830,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +ans = [0] * n +i = 1 +for j in a: + ans[j-1] = i + i += 1 +print(ans)" +p02627,s179802083,Wrong Answer,"import string +# print(string.ascii_letters) +# print(string.ascii_lowercase) +# print(string.ascii_uppercase) + +n = input() +# print(n) + +if n in string.ascii_lowercase: + print(""B"") +elif n in string.ascii_uppercase: + print(""A"")" +p02780,s487230055,Wrong Answer,"n,k=map(int,input().split()) +p=list(map(int,input().split())) +x=sum(p[:k]) +idx=0 +for i in range(k,n): + dx=x+p[i]-p[i-k] + if x= cnt_1: + print('Yes') +else: + if cnt_2 == 0 and cnt_1 - cnt_4 == 1: + print('Yes') + else: + print('No') +" +p03131,s927947272,Accepted,"K, A, B = map(int, input().split()) +ans = 0 +if B - A <= 2: + print(K + 1) + +else: + K -= A - 1 + ans += (K//2) * (B - A) + A + ans += K % 2 + print(ans) + +" +p03617,s564223135,Wrong Answer,"q,h,s,d = map(int, input().split()) +n = int(input()) + +cost_2000 = min(8*q,4*h,2*s,d) +cost_1000 = min(4*q,2*h,s) +cost_500 = min(2*q,h) +cost_250 = q + +c = [cost_2000,cost_1000,cost_500,cost_250] +amo = [2,1,0.5,0.25] +ans = 0 +for i in range(4): + uni,mod = divmod(n,amo[i]) + ans += c[i] * uni + n = mod + +print(int(ans))" +p02690,s252315526,Accepted,"x = int(input()) + +flag = False +for a in range(-118, 120): + if(flag): break + for b in range(-118, 119): + if(flag): break + if pow(a, 5) - pow(b, 5) == x: + print(a,b) + flag = True + break +" +p02785,s090925617,Accepted,"n,k = map(int,input().split()) +oppo = list(input().split()) +for i in range(len(oppo)): + oppo[i] = int(oppo[i]) + +oppo = sorted(oppo) +attack = 0 + +if k >= n: + print(0) +else: + for i in range(0,len(oppo)-k): + attack = attack + oppo[i] + print(attack) +" +p03109,s076853130,Wrong Answer,"s = input() +if int(s[5])>=5: print('TBD') +else: print('Heisei')" +p03136,s738642887,Wrong Answer,"n = int(input()) +l = list(map(int,input().split())) +m = max(l) +s = sum(l) +if m < s: + print(""Yes"") +else: + print(""No"")" +p02958,s593844441,Accepted,"import numpy as np +n = int(input()) +p = np.array(list(map(int,input().split()))) + +a = np.arange(1, n+1) +tmp = p - a +cnt = np.count_nonzero(tmp != 0) + +flg = False +if cnt == 0 or (cnt == 2 and tmp.sum() == 0): + flg = True + +print('YES') if flg else print('NO')" +p02647,s547406377,Accepted,"n,k,*a=map(int,open(0).read().split()) +for _ in range(k): + b=[0]*n + for i,q in enumerate(a): + b[max(0,i-q)]+=1 + if i+q+1=0 and b>=0: + f1,f2=1,1 + for i in range(a+1,a+b+1): + f1*=i + f1%=M + for i in range(1,b+1): + f2*=i + f2%=M + ans=f1*pow(f2,M-2,M) + +print(ans%M) +" +p03435,s440103208,Accepted,"c=[list(map(int,input().split())) for i in range(3)] +x=c[0][2]-c[0][1] +y=c[0][1]-c[0][0] +for i in range(1,3): + if c[i][1]-c[i][0]!=y: + print(""No"") + break + if c[i][2]-c[i][1]!=x: + print(""No"") + break +else: + print(""Yes"")" +p03639,s649466219,Accepted,"N=int(input()) +*A,=map(int,input().split()) + +i1=len([i for i in A if i%2!=0]) +i4=len([i for i in A if i%4==0]) +i2=min(1,N-i1-i4) + +# print(i1,i2,i4) +print('Yes' if (i1+i2-1)<=i4 else 'No')" +p03407,s592883209,Wrong Answer,"a, b, c = (int(i) for i in input().split()) +print('Yes') if a+b <= c else print('No')" +p02647,s626699327,Accepted,"N,K,*A=map(int,open(0).read().split()) +for _ in range(K): + B=[0]*(N+1) + for i in range(N): + B[max(0,i-A[i])]+=1 + B[min(N,i+A[i]+1)]-=1 + for i in range(N):B[i+1]+=B[i] + if A==B:break + A=B +print(*A[:-1])" +p03162,s024885922,Accepted,"N = int(input()) +l = [] + +for _ in range(N): + a, b, c = map(int, input().split()) + l.append([a,b,c]) + +dp = [[0]*3 for _ in range(N+1)] + +for i in range(N): + for j in range(3): + for k in range(3): + if j != k: + dp[i+1][k] = max(dp[i+1][k], dp[i][j] + l[i][k]) +ans = 0 +for i in range(3): + ans = max(ans, dp[N][i]) +print(ans)" +p02700,s260996127,Accepted,"#!/usr/bin/env python3 + +A, B, C, D= map(int, input().split()) +while A > 0 or C > 0: + C -= B + if C <= 0: + ans = ""Yes"" + break + A -= D + if A <= 0: + ans = ""No"" + break +print(ans)" +p02627,s979097781,Wrong Answer,"a = input() +if a.isupper: + print('A') +else: + print('a')" +p02707,s462532253,Accepted,"#import math +#import collections +#n,m = map(int, input().split( )) +n = int(input()) +A = list(map(int, input().split( ))) +arr = [0]*n +for a in A: + arr[a-1] += 1 +for a in arr: + print(a)" +p03001,s275337127,Accepted,"w,h,x,y=map(int,input().split()) +ans1=(w*h)/2.0 +ans2=0 +if (w/2==x)and(h/2==y): + ans2=1 +print('%f %d'%(ans1,ans2))" +p02859,s101162350,Wrong Answer,"import math +r=int(input()) +s=(r*r) * math.pi +b=int(s//math.pi) +print(b)" +p02989,s294604793,Accepted,"n = int(input()) +D = sorted(list(map(int,input().split()))) +print(D[n//2]-D[n//2-1])" +p03524,s680202981,Accepted,"from collections import Counter +from collections import defaultdict + +S = list(map(str, input().rstrip())) + +s = Counter(S) +d = defaultdict(int) + +for i in [""a"", ""b"", ""c""]: + d[i] = 0 + +for l, n in s.items(): + d[l] += n + +d = list(d.values()) + +print(""YES"" if max(d) - min(d) <= 1 else ""NO"")" +p03073,s123277572,Accepted,"s=input() +n=len(s) +d=[] +for i in range(n): + d.append(int(s[i])) +s1=[0] +s2=[1] +for i in range(1,n): + if s1[i-1]==0: + s1.append(1) + else: + s1.append(0) + if s2[i-1]==1: + s2.append(0) + else: + s2.append(1) +a,b=0,0 +for i in range(n): + if d[i]!=s1[i]: + a+=1 + if d[i]!=s2[i]: + b+=1 +print(min(a,b))" +p03241,s948484121,Accepted,"n,m = map(int, input().split()) +d = m//n +ans = [] +for i in range(1,min(d+1,int(m**0.5)+1)): + if (m % i == 0): + ans.append(i) + if (m//i<=d): + ans.append(m//i) +print(max(ans))" +p03030,s613194518,Accepted,"def resolve(): + N = int(input()) + ls = [] + for i in range(N): + tmp = input().split() + tmp.append(i+1) + ls.append(tmp) + + ls = sorted(ls, key=lambda x: (x[0], -int(x[1]))) + + for l in ls: + print(l[2]) + return + +resolve()" +p02861,s738553507,Wrong Answer,"n = int(input()) +xy_list = [] +for i in range(n): + xy_list.append(list(map(int, input().split()))) + +import itertools +import math +comb = list(itertools.permutations(xy_list)) +ans = 0 +for s in comb: + #print(ans) + for zyun in range(len(s)-1): + ans += math.sqrt((s[zyun][0] - s[zyun+1][0])**2 + (s[zyun][1] - s[zyun+1][1])**2) +print(round(ans/n/(len(s)-1), 12))" +p02684,s037386536,Accepted,"n,k = map(int,input().split()) +a = list(map(int,input().split())) +t=[[0 for i in range(n)] for j in range(64)] +for i in range(64): + for j in range(n): + if i == 0: + t[i][j]=a[j] + else: + t[i][j]=t[i-1][t[i-1][j]-1] +ans=1 +for i in range(64): + r = k%2 + k = k//2 + if r == 1: + ans = t[i][ans-1] + if k == 0: + print(ans) + exit() +" +p02595,s952941350,Accepted,"import math + +N, D = map(int, input().strip().split(' ')) +count = 0 +for i in range(N): + X, Y = map(int, input().strip().split(' ')) + if math.sqrt(X**2 + Y**2) <= D: + count += 1 + else: + pass + +print(count)" +p03524,s208705423,Accepted,"S = input() + +a = S.count(""a"") +b = S.count(""b"") +c = S.count(""c"") + +if max(a, b, c) - min(a, b, c) >= 2: + print(""NO"") +else: + print(""YES"")" +p02578,s248910629,Accepted,"n=int(input()) +lst=list(map(int,input().split())) +_max=lst[0] +st=0 +for i in lst: + if i>=_max: + _max=i + else: + st=st+(_max-i) +print(st)" +p02724,s887268682,Accepted,"x = int(input()) + +a = x // 500 +x = x - a*500 +b = x // 5 +print(a*1000+b*5)" +p04044,s014486618,Accepted,"N,L = map(int, input().split()) +S = [] +for i in range(N): + s = input() + S.append(s) +S.sort() +print(''.join(S))" +p03435,s592321272,Accepted,"import numpy as np + +c = np.array([list(map(int, input().split())) for i in range(3)]) + +flag = True +for a1 in range(c.max()+1): + b1 = c[0][0] - a1 + b2 = c[0][1] - a1 + b3 = c[0][2] - a1 + if (c[1][0] - b1 != c[1][1] - b2 or c[1][0] - b1 != c[1][2] - b3): + flag = False + + if (c[2][0] - b1 != c[2][1] - b2 or c[2][0] - b1 != c[2][2] - b3): + flag = False + +print(""Yes"" if flag else ""No"")" +p02947,s573250460,Accepted,"n = int(input()) +D=dict() +for i in range(n): + s= input() + s=sorted(s) + S=''.join(s) + if S in D: + D[S]+=1 + else: + D[S]=1 + +cnt=0 +for s in D: + cnt+=D[s]*(D[s]-1)//2 +print(cnt)" +p03339,s348107683,Accepted,"n = int(input()) +s = input() + +l = [0]*n +r = [0]*n +for i in range(1,n): + l[i] = l[i-1]+(s[i-1]==""W"") +for i in range(n-1)[::-1]: + r[i] = r[i+1]+(s[i+1]==""E"") + +ans = 10**6 +for a,b in zip(l,r): + ans = min(a+b,ans) +print(ans)" +p02701,s414871867,Wrong Answer,"import collections + +N=int(input()) +P=[input() for i in range(N)] +print(P) +c=collections.Counter(P) +print(len(c))" +p03338,s033800256,Accepted,"n = int(input()) +s = list(input()) +ans = 0 +for i in range(n): + l = list(set(s[:i])) + r = list(set(s[i:])) + cnt = 0 + for j in range(len(l)): + if l[j] in r: + cnt += 1 + ans = max(ans,cnt) +print(ans) +" +p02708,s761220730,Accepted,"N,K = map(int,input().split()) +ans = 0 +for k in range(K,N+2): + ans += N*k-k*(k-1)/2-k*(k-1)/2+1 +ans %= 10**9+7 +print(int(ans))" +p03994,s600516185,Wrong Answer,"def main(): + s = list(input()) + k = int(input()) + + ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' + D = dict(zip(ascii_lowercase,list(range(0,len(ascii_lowercase))))) + + n = len(ascii_lowercase) + + for i in range(0,len(s)): + j = D[s[i]] + if j != 0 and 26 -j <= k: + k -= (26-j) + s[i] ='a' + print(''.join(s)) + +main()" +p03778,s759463114,Accepted,"w,a,b = map(int,input().split()) +if b>=a: + print(max(0,b-(a+w))) +else: + print(max(0,a-(b+w)))" +p02924,s643759087,Accepted,"n = int(input()) +print(n * (n-1) // 2)" +p02681,s588975696,Wrong Answer,"S = input() +T = input() + +if S in T: + print(""Yes"") +else: print(""No"") +" +p02696,s150091794,Accepted,"a, b, n = map(int, input().split()) +if b > n: + x = n +else: + x = b - 1 +print(int(a * x / b) - a * int(x / b))" +p02693,s667226351,Accepted,"k = int(input()) +a,b = map(int,input().split()) +chk = False + +for i in range(a,b+1): + if i % k == 0: + chk = True + break + +print(""OK"") if chk else print(""NG"")" +p03448,s525527311,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) +count=0 + +for s in range(a+1): + if s*500 == x: + count += 1 + for t in range(b+1): + if s*500 + t*100 == x: + count += 1 + for u in range(c+1): + if s*500 + t*100 + u*50 == x: + count += 1 + +print(count)" +p02731,s382780230,Wrong Answer,"L=int(input()) +ans=0 +tmp=0 +d=10 +L_=int(L**(1/3)) +for i in range(max(0,int(L_-10)*d),int(L_+10)*d): + for j in range(max(0,int(L_-10)*d-i),int(L_+1)*d-i): + tmp=(i/d)*(j/d)*(L-(i/d)-(j/d)) + ans=max(ans,tmp,0) +print(ans)" +p02924,s750477475,Accepted,"n = int(input()) +print(n * (n - 1) // 2)" +p02676,s166953317,Accepted,"k = int(input()) +s = input() +ls = len(s) + +if ls <= k: + print(s) +else : + print(s[0:k]+""..."")" +p03323,s793999224,Accepted,"a,b=map(int,input().split()) +if a<9 and b<9: + print(""Yay!"") +else: + print("":("")" +p03986,s019306684,Wrong Answer,"def main(): + s = input().rstrip() + cnt_t, cnt_s = 0, 0 + for i in range(len(s)): + if s[i] == ""S"": + cnt_t = i + break + for i in range(len(s)): + if s[len(s)-1-i] == ""T"": + cnt_s = i + break + print(2*max(cnt_t, cnt_s)) + +if __name__ == ""__main__"": + main()" +p03681,s537216357,Accepted,"N, M = map(int, input().split()) + +MOD = 10**9 + 7 +ans = 0 +if abs(N-M) < 2: + A, B = max(N, M), min(N, M) + res = 1 + if A == B: + for i in range(1, A+1): + res = (i**2 % MOD) * res % MOD + ans = res * 2 % MOD + else: + for a in range(1, A+1): + res = res * a % MOD + for b in range(1, B+1): + res = res * b % MOD + ans = res % MOD + +print(ans) +" +p02602,s684944796,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +print(*['Yes' if a[i] < a[k + i] else 'No' for i in range(n - k)], sep='\n')" +p02897,s629060430,Wrong Answer,"N = int(input()) +if N == 1: + print(1) +elif N%2 != 0: + print((N-2)/5) +else: + print(N/2)" +p02948,s675509612,Wrong Answer,"import heapq +n,m=map(int,input().split()) +t=[[0] for _ in range(m)] +for i in range(n): + a,b=map(int,input().split()) + if a>m: + continue + t[a-1].append(b) +h=[] +for i in range(m): + t[i].sort(reverse=True) + for j in range(min(len(t[i]),m-i)): + h.append(-t[i][j]) +heapq.heapify(h) +ans=0 +for i in range(m): + ans+=-heapq.heappop(h) +print(ans)" +p03592,s213595261,Accepted,"import sys +input = sys.stdin.readline + +def main(): + N,M,K = map(int,input().split()) + + for i in range(N+1): + for j in range(M+1): + b = N*M-(i*j+(N-i)*(M-j)) + if b == K: + print(""Yes"") + exit() + + print(""No"") + +if __name__ == ""__main__"": + main() +" +p03352,s440344688,Wrong Answer,"X=int(input()) +n=1 +for b in range(2,X): + p=2 + while(True): + x=b**p + print(x) + if x<=X: + n=x + p+=1 + else: + break + +print(n)" +p02888,s661164499,Wrong Answer,"n = int(input()) +l = list(map(int, input().split())) +l.sort() +triangle = 0 +for i in range(n-2): + min_l = l[i] + for j in range(i+1, n-1): + sum_l = min_l + l[j] + inf = j + sup = n + while sup - inf > 1: + x = (inf + sup) // 2 + if l[x] < sum_l: + sup = x + else: + inf = x + triangle += n - sup +print(triangle)" +p03645,s687962663,Accepted,"import sys + +input = sys.stdin.readline +n, m = map(int, input().split()) +x = set() +y = set() +for _ in range(m): + a, b = map(int, input().split()) + if a == 1: + x.add(b) + if b == n: + y.add(a) +print((""POSSIBLE"", ""IMPOSSIBLE"")[len(x & y) == 0]) +" +p03607,s901176689,Accepted,"n = int(input()) +al = list(int(input()) for _ in range(n)) + +s = set() + +for a in al: + s ^= {a} + +print(len(s)) + +" +p03803,s425540055,Accepted,"a = input().split(' ') +a[0] = int(a[0]) +a[1] = int(a[1]) + +if (a[0] == 1): a[0] += 99 +if (a[1] == 1): a[1] += 99 + +if (a[0] == a[1]): print(""Draw"") +elif (a[0]) > a[1]: print(""Alice"") +else: print(""Bob"") +" +p03555,s135537312,Accepted,"a = input() +b = input() +if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: + print('YES') +else: + print('NO') +" +p03962,s500025011,Accepted,"def paint(): + s = input() + slist = s.split(' ') + + a = int(slist[0]) + b = int(slist[1]) + c = int(slist[2]) + count = 1 + if a != b: + count += 1 + if a != c and b != c: + count += 1 + + print(count) + +paint()" +p03699,s662887007,Wrong Answer,"n = int(input()) +s = [] +for i in range(n): + s.append(int(input())) +for i in range(n): + if sum(s)%10 != 0: + print(sum(s)) + break + else: + s.remove(min(s)) + if s == []: + print(0) + break" +p03474,s637580766,Accepted,"a,b = map(int,input().split()) +s = str(input()) + +if len(s)== a+b+1 \ + and s[a:a+1] =='-' \ + and str.isdecimal(s[0:a]) \ + and str.isdecimal(s[a+1:a+1+b]): + print('Yes') +else: + print('No')" +p03264,s346900892,Accepted,"K = int(input()) +print((K // 2) * ((K + 1) // 2)) + +" +p02796,s883526611,Accepted,"from operator import itemgetter +X = [] +L = [] + +n = int(input()) +for i in range(n): + x, l = map(int, input().split()) + X.append(x) + L.append(l) + +robo = sorted([(X[i]-L[i], X[i]+L[i]) for i in range(n)], key=itemgetter(1)) + +ans = 0 +end = -float(""inf"") +for i in range(n): + if end <= robo[i][0]: + ans += 1 + end = robo[i][1] + +print(ans) +" +p03274,s189425595,Wrong Answer,"n,k = map(int, input().split()) +al = list(map(int, input().split())) + +res= 10**6 + +for i in range(n-k+1): + st = al[i] + en = al[i+k-1] + if st *en <0: + temp = min(abs(st),abs(en))*2+max(abs(st),abs(en)) + else: + temp = max(abs(st),abs(en)) + res = min(temp,res) + +print(res)" +p03814,s269289738,Wrong Answer,"s = input() + +sl = list(s) + +for i in range(0,len(sl)-1): + if sl[i] == ""A"": + st = i + +for j in range(len(sl),0,-1): + if sl[j-1] ==""Z"": + en = j-1 + + +print (en-st+1)" +p03095,s377138001,Accepted,"from collections import Counter + +n = int(input()) +s = list(input()) +mod = 10**9 + 7 + +cnt = Counter(s) + +ans = 1 +for k, v in cnt.items(): + ans *= (v + 1) % mod + +print((ans - 1) % mod) +" +p02705,s627319930,Accepted,"from math import pi +print(2*int(input())*pi)" +p03455,s727069899,Accepted,"a, b = map(int, input().split()) + +if (a * b) % 2 == 1: + ans = 'Odd' +else: + ans = 'Even' + +print(ans)" +p03385,s304199749,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + if set(input())=={'a','b','c'}: + print('Yes') + else: + print('No') +resolve()" +p04044,s658843038,Wrong Answer,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + N, L = map(int, readline().split()) + S = [readline().strip() for _ in range(L)] + + S.sort() + ans = ''.join(S) + print(ans) + return + + +if __name__ == '__main__': + main() +" +p02818,s658937424,Accepted,"a,b,k = (int(w) for w in input().split()[:3]) + +if a > k: + print(a-k, b) + exit() +else: + k -= a + +if b > k: + print(0, b-k) +else: + print(0, 0)" +p02859,s093702937,Wrong Answer,"r = int(input()) +S = r * r +print('半径{}の円の面積は半径1の円の面積の{}倍です'.format(r,S))" +p02957,s336988510,Accepted,"a,b = map(int,input().split()) +print((a+b)//2 if (a+b)%2==0 else 'IMPOSSIBLE')" +p02982,s741677031,Accepted,"n,d = map(int, input().split()) +a = [list(map(int,input().split())) for _ in range(n)] +cnt = 0 +for i in range(n-1): + for j in range(i+1,n): + s = 0 + for k in range(d): + s+=(abs(a[i][k]-a[j][k]))**2 + if s**0.5==int(s**0.5): + cnt+=1 +print(cnt)" +p03075,s132777939,Accepted,"A=[int(input()) for i in range(5)] +k=int(input()) +for i in range(5): + for j in range(i,5): + if abs(A[i]-A[j])>k: + print("":("") + exit() +print(""Yay!"")" +p03796,s530963064,Accepted,"n = int(input()) + +power = 1 +for i in range(1, n + 1): + power = power * i % 1000000007 + +print(power) +" +p03208,s240817304,Accepted,"# -*- coding: utf-8 -*- + +N, K = [int(i) for i in input().split()] +H = [int(input()) for i in range(N)] + +sorted_H = sorted(H) +distance = 1000000000 +for i in range(N-K+1): + if sorted_H[i+K-1] - sorted_H[i] < distance: + distance = sorted_H[i+K-1] - sorted_H[i] +print(distance) +" +p02880,s904041808,Accepted,"n = int(input()) +count = 0 +for i in range(10): + for j in range(10): + if i*j == n: + count = 1 + break + +if count == 1: + print('Yes') +else: + print('No')" +p03061,s696804343,Wrong Answer,"from fractions import gcd + +N = int(input()) +A = list(map(int, input().split())) +L = [A[0]] +R = [A[-1]] + +for i in range(N-1): + L.append(gcd(L[-1], A[i+1])) + R.append(gcd(R[-1], A[N-i-1])) +ans = max(L[-2], R[-2]) +for i in range(1, N-1): + ans = max(ans, gcd(L[i-1], R[-i-1])) + +print(ans)" +p02793,s772716150,Wrong Answer,"#a,bの最大公約数 +def gcd(a, b): + while b: + a, b = b, a % b + return a +def lcm(x, y): + return x / gcd(x, y) * y +n=int(input()) +a=list(map(int,input().split())) +mod = 10**9+7 +lc=1 +for i in range(n): + lc = lcm(lc,a[i]) +a = list(map(lambda x : (lc/x)%mod,a)) +print(sum(a)%mod) + +" +p03286,s356093649,Wrong Answer,"s="""" +n=int(input()) +while n!=0:s=str(n%2)+s;n=-(n//2) +print(s)" +p02924,s371143905,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Created: Jul, 14, 2020 11:34:55 by Nobody +# $Author$ +# $Date$ +# $URL$ +__giturl__ = ""$URL$"" + + +from sys import stdin +input = stdin.readline + + +def main(): + N = int(input()) + + print((N-1)*N//2) + + +if(__name__ == '__main__'): + main() +" +p03289,s254454454,Accepted,"s=str(input()) +if s[0] == ""A"" and s[2:-1].count(""C"") == 1: + if s[1].islower() and s[-1].islower(): + print(""AC"") + else: + print(""WA"") +else: + print(""WA"")" +p02707,s042112686,Accepted,"N = int(input()) +A = [int(i) for i in input().split()] +ans = [0 for i in range(N)] +for i in A: + ans[i-1] += 1 +for i in ans: + print(i)" +p02789,s204070362,Accepted,"N,M=map(int,input().split()) + +if N==M: + print(""Yes"") +else: + print(""No"")" +p02613,s999319102,Accepted,"n = int(input()) +s = [input() for i in range(n)] + +print('AC x ' + str(s.count('AC'))) +print('WA x ' + str(s.count('WA'))) +print('TLE x ' + str(s.count('TLE'))) +print('RE x ' + str(s.count('RE'))) +" +p03745,s179506867,Accepted,"n = int(input()) +A = list(map(int, input().split())) + +ans = 1 +sq = 0 +a = A[0] +for i in range(1,n): + #print(a,A[i], sq) + if sq == 0 and A[i] < a: + sq = -1 + elif sq == 0 and A[i] > a: + sq = 1 + elif (sq == 1 and A[i] < a) or (sq == -1 and A[i] > a): + #print('---') + ans += 1 + sq = 0 + a = A[i] + +print(ans) + +" +p03407,s588261084,Accepted,"A, B, C = map(int, input().split()) +if A + B < C: + print(""No"") +else: + print(""Yes"")" +p02676,s486651099,Accepted,"K = int(input()) +S = input() + +if len(S) <= K: + print(S) +else: + print(S[:K]+""..."")" +p02664,s704532612,Accepted,"T = list(input()) +ans = [] +for i in T: + if i == ""?"": + ans.append(""D"") + else: + ans.append(i) +print("""".join(ans))" +p02742,s807071201,Accepted,"h, w = map(int, input().split()) + +a = h * w + +if h == 1 or w == 1: + print(""1"") +else: + if a % 2 == 0: + print(a // 2) + else: + print((a // 2) + 1) + " +p03137,s828041756,Accepted,"def main(): + + N, M = (int(_) for _ in input().split()) + X = sorted([int(_) for _ in input().split()]) + if N >= M: + print(0) + return + Y = sorted([X[i] - X[i-1] for i in range(1, M)]) + print(sum(Y[:M-N])) + return + +if __name__ == '__main__': + main()" +p03632,s984832471,Accepted,"A, B, C, D = [int(x) for x in input().split()] +ans = min(B, D)-max(A, C) +if ans < 0: + ans = 0 +print(ans) +" +p02584,s157177000,Accepted,"X, K, D = map(int, input().split()) + +if abs(X) // D > K: + print(abs(X) - K * D) + exit() + +mod = abs(X) % D +if (K - (abs(X) // D)) % 2 == 0: + print(mod) +else: + print(abs(mod - D)) +" +p03087,s156305414,Wrong Answer,"N, Q = map(int, input().split()) +S = list(input()) +L = [0] +cnt = 0 + +for i in range(1, N): + if S[i-1] == ""A"" and S[i] == ""C"": + cnt += 1 + L.append(cnt) + +print(L) + +for _ in range(Q): + l, r = map(int, input().split()) + print(L[r-1] - L[l-1])" +p02554,s222255735,Wrong Answer,"n = int(input()) + +if (n == 1)or(n==0): + print(0) +else: + xn = n-2 + a10 = 2*10**xn + + if n != 2: + a9 = (9**(n-2)*(n-1)*2) + else: + a9 = 0 + + ans = (a10+a9)%((10**9)+7) + print(ans) +" +p02953,s689158818,Wrong Answer,"n = int(input()) +H = list(map(int,input().split())) +print (""Yes"") if H[0] < H[-1] or n == 1 else print (""No"") +" +p03076,s542062722,Accepted,"import itertools +def permutation_all(seq, choice): + return list(itertools.permutations(seq, choice)) + +a = [] +for i in range(5): + a.append(int(input())) +p = permutation_all(a,5) +ans = 1000000000 +for i in range(len(p)): + point = p[i] + tot = 0 + for j in range(5): + if j != 4: + tot += (point[j]+9)//10 * 10 + else: + tot += point[j] + ans = min(ans,tot) +print(ans) + +" +p02700,s283205412,Accepted,"a, b, c, d = map(int, input().split()) + +l = c // b +if c % b !=0: + l += 1 + +m = a // d +if a % d !=0: + m += 1 + +if l == m: + print(""Yes"") +elif l < m: + print(""Yes"") +else: + print(""No"")" +p03696,s254642004,Wrong Answer," + +n = int(input()) + +s = input() + +now =0 +right = 0 +for i in range(n): + if(s[n-1-i]=='('): + now+=1 + else: + now-=1 + if(right=level: + cnt+=1 + if cnt>=m: + print('Yes') + else: + print('No') +if __name__=='__main__': + solve()" +p02862,s715824900,Accepted,"M=10**9+7;x,y=map(int,input().split());d,m=divmod(x+y,3) +if m or y>2*x or x>2*y:print(0);exit() +x-=d;y-=d;s=t=1 +for i in range(min(x,y)):s=s*(x+y-i)%M;t=t*(i+1)%M +print(s*pow(t,M-2,M)%M)" +p02996,s360141969,Accepted,"n = int(input()) +jobs = [list(map(int,input().split())) for i in range(n)] + +time = 0 +jobs.sort(key = lambda x:x[1]) + +result = 'Yes' + +for job in jobs: + time += job[0] + if time > job[1]: + result = 'No' + break + +print(result)" +p02726,s956287090,Wrong Answer,"N, X, Y=map(int,input().split()) +List=[] +i=1 +for j in range(2,N+1): + while 0 1: + al[c] += i * (i-1) / 2 + c += 1 + +for i in range(n): + f = a[i] + t = a_2[f-1] - 1 + #print(int(sum(al)-(al[f-1]-t*(t-1)/2))) + +" +p04019,s474552210,Accepted,"S = input() +n = 0 +w = 0 +s = 0 +e = 0 + +for i in range(len(S)): + if S[i] == ""N"": + n += 1 + elif S[i] == ""W"": + w += 1 + elif S[i] == ""S"": + s += 1 + else: + e += 1 +if n > 0 and w > 0 and s > 0 and e > 0: + print(""Yes"") +elif n > 0 and s > 0 and w == 0 and e == 0: + print(""Yes"") +elif w > 0 and e > 0 and s == 0 and n == 0: + print(""Yes"") +else: + print(""No"") +" +p02947,s325036308,Accepted,"N = int(input()) +a = [''.join(sorted(list(input()))) for _ in range(N)] +import collections +c = collections.Counter(a) +c_ls = list(c.values()) +ans = 0 +for i in range(len(c_ls)): + ans += c_ls[i] * (c_ls[i]-1)//2 +print(ans) +" +p03211,s686270467,Accepted,"s=input() +res=[] +for i in range(len(s)-2): + res += [abs(int(s[i:i+3])-753)] +print(min(res))" +p02791,s594916757,Wrong Answer,"n=int(input()) +plist=list(map(int,input().split())) + +a=max(plist) +cnt=0 + +for p in plist: + if p == plist[0]: + a = p + cnt +=1 + else: + if p <= a: + a = p + cnt += 1 + +print(a) + +" +p02723,s198909101,Accepted,"N = input() +if N[-4] == N[-3] and N[-2] == N[-1] : + print(""Yes"") +else : + print(""No"")" +p03437,s811398634,Accepted,"def L(): + return list(map(int, input().split())) + +[x,y]=L() + +if x%y==0: + print(-1) +else: + print(x) +" +p03433,s743437492,Wrong Answer,"n = int(input()) +a = int(input()) +print(""Yes"" if (n%500) N: + break + e = 0 + while N % i == 0: + e += 1 + N //= i + if e > 0: + for j in range(1, 10): + if e >= j: + e -= j + ans += 1 + else: + break +if N > 1: + ans += 1 + +print(ans) +" +p02747,s990794619,Accepted,"S = input() + +if len(S) % 2 > 0: + print('No') +else: + if S[0::2].count('h') == len(S) // 2 and S[1::2].count('i') == len(S) // 2: + print('Yes') + else: + print('No')" +p02742,s655703225,Wrong Answer,"h, w = map(int, input().split()) + +ans = 0 +if h == 0 or w == 0: + ans = 0 +else: + r, c = h//2, w//2 + ans = r * c + if h%2 == 1: + r = h//2 + 1 + + if w%2 == 1: + c = w//2 + 1 + + ans += r * c + +print(ans)" +p03448,s526945691,Accepted,"a=int(input()) +b=int(input()) +c=int(input()) +x=int(input()) +ans=0 + +for i in range(a+1): + for j in range(b+1): + for k in range(c+1): + tmp = 500*i+100*j+50*k + if tmp==x: + ans+=1 + +print(ans)" +p03723,s026623963,Accepted,"a, b, c = map(int, input().split()) + +if(a == b and b == c and a % 2 == 0): + print(-1) +else : + cnt = 0 + while True: + if(a % 2 != 0 or b % 2 != 0 or c % 2 != 0): + break + A = b//2 + c//2 + B = c//2 + a//2 + C = a//2 + b//2 + a = A + b = B + c = C + cnt += 1 + print(cnt) +" +p02601,s575037245,Wrong Answer,"a, b, c = map(int, input().split()) +k = int(input()) +n = 0 +if a+1 > b: + i = 1 + while b*(2**i) < a+1: + i += 1 + n += i + #print(n,i) +if a+2 > c: + i = 1 + while c*(2**i) < a+2: + i += 1 + n += i + #print(n,i) + +if k >= n: + print('Yes') +else: + print('No') +" +p02842,s370330846,Accepted,"taxed_price = int(input()) +raw_price = taxed_price // 1.08 + +if int(raw_price * 1.08) == taxed_price: + print(int(raw_price)) +elif int((raw_price + 1) * 1.08) == taxed_price: + print(int(raw_price + 1)) +else: + print(':(') +" +p03721,s435573553,Wrong Answer,"N,K=map(int,input().split()) +listA=[0]*10**5 +for z in range(N): + a,b=map(int,input().split()) + listA[a-1]+=b + +count=0 +y=0 +while count<10**5-1: + y+=listA[count] + if y>=K: + print(count+1) + break + else: + count+=1 +" +p02796,s250769094,Wrong Answer,"N = int(input()) +XL = [tuple(map(int,input().split())) for i in range(N)] +XL.sort(key=lambda x: x[0]) +right = -float('inf') +ans = 0 +for x,l in XL: + s,t = x-l+1, x+l-1 + if s > right: + right = t + ans += 1 +print(ans) +" +p03545,s955081048,Accepted,"def main(): + from itertools import product, zip_longest + + s = input() + + for prod in product(['+', '-'], repeat=3): + formula = '' + for x, op in zip_longest(s, prod, fillvalue=''): + formula += x + op + if eval(formula) == 7: + print(formula + '=7') + return + + +if __name__ == '__main__': + main() +" +p03075,s017098322,Accepted,"n=[int(input()) for i in range(5)] +m=int(input()) +if max(n)-min(n)>m: + print(':(') +else: + print('Yay!')" +p03037,s496780988,Wrong Answer,"n,m = map(int,input().split()) +left = 0 +right = n +for i in range(m): + l,r = map(int,input().split()) + left = max(left,l) + right = min(right,r) +print(right-left+1)" +p02603,s017093033,Accepted,"n = int(input()) +a = list(map(int,input().split())) +m = 1000 +stocks = 0 +drops = [False]*(n-1) +for i in range(n-1): + if a[i] > a[i+1]: + drops[i] = True +for i in range(n-1): + if drops[i]: + m+=stocks*a[i] + stocks = 0 + else: + stocks+=m//a[i] + m -= (m//a[i])*a[i] +print(m + stocks*a[-1])" +p03456,s833458585,Accepted,"a, b = input().split() +ans = 'No' +for i in range(1000): + if i*i == int(a+b): + ans = 'Yes' +print(ans)" +p02723,s003327961,Accepted,"S = str(input()) + +if S[2] == S[3] and S[4] == S[5]: + print('Yes') +else: + print('No')" +p03126,s976078283,Wrong Answer,"N,M = map(int,input().split()) +K = [] +sum = 0 +for i in range(N): + W=list(map(int,input().split())) + W.pop(0) + K+=W +for T in range(1,len(K)+1): + B=K.count(T) + if B == N: + sum+=1 +print(sum)" +p02624,s601507926,Accepted,"n=int(input()) +ans=0 +for i in range(1,n+1): + up=n//i + ans+=up*(up+1)*i//2 +print(ans)" +p02547,s976640080,Accepted,"n = int(input()) + +count_max = 0 +count = 0 +for i in range(n): + d1, d2 = map(int, input().split()) + if d1 == d2: + count += 1 + count_max = max(count_max, count) + else: + count = 0 +print(""Yes"" if count_max >= 3 else ""No"")" +p03456,s769322844,Accepted,"a, b = map(str, input().split()) +c = int(a + b) + +if (c ** .5).is_integer(): + print(""Yes"") +else: + print(""No"")" +p03309,s348257149,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +for i in range(N): + A[i] -= i + 1 +m = min(A) +for i in range(N): + A[i] -= m +g = sum(A) // N +print(min(sum(abs(i - g + 1) for i in A), sum(abs(i - g) for i in A), sum(abs(i - g - 1) for i in A)))" +p02993,s555929770,Accepted,"S = input() + +if S[0] == S[1] or S[1] == S[2] or S[2] == S[3] : + print(""Bad"") +else : + print(""Good"") +" +p02831,s735017845,Accepted,"import fractions +A, B = map(int, input().split()) +print((A * B) // fractions.gcd(A, B))" +p03435,s428652932,Accepted,"import numpy as np + +c = [list(map(int,input().split())) for i in range(3)] +c = np.array(c) +flg = True + +for i in range(2): + if not c[0,i]-c[0,i+1] == c[1,i]-c[1,i+1] == c[2,i]-c[2,i+1]: + flg = False + break + if not c[i,0]-c[i+1,0] == c[i,1]-c[i+1,1] == c[i,2]-c[i+1,2]: + flg = False + break +print('Yes') if flg else print('No')" +p02823,s792195521,Wrong Answer,"N,A,B = map(int,input().split()) +if (A - B) % 2 == 0: + print(int((B - A)/2)) +else: + print(min(A - 1,N - B) + 1 + (B - A - 1)//2)" +p02732,s159923843,Accepted,"from collections import Counter + +n = int(input()) +a = list(map(int, input().split())) +c = Counter(a) +base = 0 +for i in c.values(): + base += i*(i-1)//2 + +ans = [] +for ai in a: + k = c[ai] + tmp = base - k*(k-1)//2 + (k-1)*(k-2)//2 + ans.append(tmp) + +print(*ans, sep=""\n"") +" +p03449,s019167084,Accepted,"N = int(input()) +list_A1 = [int(x) for x in input().split()] +list_A2 = [int(x) for x in input().split()] + +ans = 0 + +for i in range(N) : + total = sum(list_A1[:i+1]) + sum(list_A2[i:]) + ans = max(ans, total) + +print(ans) +" +p02778,s646241951,Wrong Answer,"x=input() +list1=[] +for o in list(x): + if o!=x: + list1.append(x) + else: + list1.append(x) +str="""".join(list1) +print(str)" +p03339,s047706496,Accepted,"n = int(input()) +s = input() +dp_L = [0]*(n+1) +dp_R = [0]*(n+1) + +for i in range(n): + dp_L[i+1] = dp_L[i]+[0, 1][s[i] == 'W'] + +for i in reversed(range(n)): + dp_R[i] = dp_R[i+1]+[0, 1][s[i] == 'E'] + +print(min(L+R for L, R in zip(dp_L, dp_R))) +" +p02813,s710880923,Wrong Answer,"import itertools +n = int(input()) +a = [int(i) for i in input().split()] +b = [int(i) for i in input().split()] + +l = list(itertools.permutations(range(1,n+1))) + +A, B = 0, 0 +for i, p in enumerate(l): + if p == a: + A = i + if p == b: + B = i + +print(abs(A-B)) + + + +" +p02993,s261312237,Accepted,"# ABC131A + +s = input() +if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]: + print('Bad') +else: + print('Good') +" +p02897,s055322941,Accepted,"a=int(input()) +if a%2==0: + print(0.5) +else: + print((a+1)/2/a)" +p03419,s218105946,Wrong Answer,"N, M = map(int,input().split()) + +if N == 1 and M == 1: + print(1) +elif N == 1 and M != 1: + print(M-2) +else: + print((N-2)*(M-2)) +" +p02582,s343285847,Wrong Answer,"s=input() +ans=0 +if s[1]==""S"": + if s[0]==""R"" or s[2]==""R"": + print(1) + else: + print(0) +else: + if s[0]!=""R"" or s[2]!=""R"": + print(2) + else: + print(3)" +p03693,s407013652,Accepted,"a,b,c = map(int,input().split()) + +if (10*b + c) % 4 == 0: + print(""YES"") + +else: + print(""NO"") + " +p03997,s811564096,Accepted,"#ABC045 A +a,b,h = [int(input()) for i in range(3)] +print((a+b)*h//2)" +p02787,s139681400,Accepted,"(h, n), *m = [[*map(int, i.split())] for i in open(0)] +dp = [0] + [10**9] * h +for i in range(1, h + 1): + for a, b in m: + dp[i] = min(dp[i], dp[max(i-a,0)]+b) +print(dp[-1]) +" +p02899,s163147547,Wrong Answer,"n = int(input()) +l = list(input().split()) +#print(l) + +x = [] +for i in range(len(l)): + j = str(l[i]) + str(i+1) + x.append(j) +#print(x) +x.sort() +#print(x) +for k in x: + print(k[1], end = ' ')" +p03131,s188503596,Accepted,"# Problem C - When I hit my pocket... + +import math + +# input +K, A, B = map(int, input().split()) + +# initialization +koho_1 = 1 + K +koho_2 = 0 +if B-A>2: + koho_2 = A + K -= A - 1 + if K%2==1: + koho_2 += 1 + K -= 1 + koho_2 += (B - A) * (K // 2) + +# calc +ans = max(koho_1, koho_2) + +# output +print(ans) +" +p03852,s975826374,Accepted,"if input() in list('aeiou'): + print('vowel') +else: + print('consonant')" +p02796,s656767073,Wrong Answer,"N = int(input()) +D = [] +for i in range(N): + x, l = map(int, input().split()) + D.append([x-l, x+l]) +from operator import itemgetter +D = sorted(D, key = itemgetter(0)) +u = -10**10 #最小値:x = 0, l = 10**10の時 +cnt = 0 +for a, b in D: + if u < a: + cnt += 1 + u = b #つぎのロボットの範囲の下限に置きかえる +print(cnt) +" +p03379,s956315962,Accepted,"n = int(input()) +x = list(map(int, input().split())) +s = sorted(x) +for i in x: + if i < s[n // 2]: + print(s[n // 2]) + else: + print(s[n // 2 - 1]) +" +p02724,s818524634,Wrong Answer,"x=int(input()) +x-=(x//500)*500 +y=x//5 +print((x//500)*1000+5*y) +" +p02754,s103871223,Accepted,"n, a, b = map(int, input().split()) + +if n%(a+b) >a: + print(int(n//(a+b))*a +a) +else: + print(int(n//(a+b))*a +n%(a+b))" +p03131,s558985143,Accepted,"K,A,B = map(int,input().split()) +if B-A <= 2: + print(1+K) + exit() +time = K - A + 1 +print(A + time//2*(B-A) + time%2)" +p03417,s080325836,Wrong Answer,"a,b=map(int,input().split()) +if min(a,b)==1: + print(max(a,b)-2) +else: + print((a-2)*(b-2))" +p02623,s702196928,Accepted,"N, M, K = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +a = [0] +b = [0] +T = 0 +ans = 0 + +for i in range(N): + a.append(a[i] + A[i]) + +for i in range(M): + b.append(b[i] + B[i]) + +j = M + +for i in range(N+1): + if a[i] > K: + break + while a[i] + b[j] > K: + j -= 1 + ans = max(ans, i + j) + + +print(ans)" +p02953,s308951467,Accepted,"n = int(input()) +h = list(map(int,input().split())) +ans = 'Yes' +for i in range(n-1,0,-1): + if h[i-1]-h[i]>1: + ans = 'No' + break + elif h[i-1]-h[i]==1: + h[i-1]-=1 +print(ans)" +p03448,s860361998,Accepted,"A = int(input()) +B = int(input()) +C = int(input()) +X = int(input()) + +count=0 + +for i in range(A+1): + for j in range(B+1): + for k in range(C+1): + if 500*i + 100*j + 50*k == X: + count +=1 + +print(count)" +p03524,s349443100,Wrong Answer,"from collections import defaultdict +def main(): + dd = defaultdict(int) + dd[""a""]=0; + dd[""b""]=0; + dd[""c""]=0; + s = input() + for i in range(len(s)): + dd[s[i]]+=1 + + res = list(dd.values()) + if max(res)-min(res)>1: + print(""No"") + else: + print(""Yes"") + +if __name__ == ""__main__"": + main() +" +p02994,s204210757,Wrong Answer,"n,l=map(int,input().split()) +s=0 +list=[] +for i in range(1,n+1): + s+=i + list.append(abs(l+i-1)) +sum=n*(l-1)+s +if l-1<-n: + print(sum+min(list)) +elif l-1<=0<=l-1+n: + print(sum) +else: + print(sum-min(list))" +p02729,s250441177,Accepted,"#!/usr/bin/env python3 +import math + +n, m = map(int, input().split()) + +nans = (n * (n - 1)) // 2 +mans = (m * (m - 1)) // 2 + +print(nans + mans) +" +p02783,s131886979,Accepted,"[H,A] = list(map(int,input().split())) + +output = H//A+1 +if H%A==0: + output += -1 +print(output) +" +p03479,s658320621,Accepted,"def solve(): + min_number, max_number = list(map(int, input().split())) + + current_number = min_number + answer = 1 + + while True: + next_number = current_number * 2 + if next_number <= max_number: + current_number = next_number + answer += 1 + else: + break + + print(answer) + + +solve()" +p02645,s374524274,Wrong Answer,"import random + +def name(): + S = input(""S:"") + if len(S) > 20: + return name() + if len(S) < 3: + return name() + if S.isupper() == True: + return name() + if S.isalpha() == False: + return name() + else: + l = list(S) + x = random.randint(0, len(S) - 3) + y = l[x] + z = l.index(y) + print(y + l[z+1] + l[z+2])" +p02701,s455345404,Accepted,"import itertools + +def solve(): + n = int(input()) + s = [] + for i in range(n): + s.append(input()) + print(len(set(s))) + return 0 + +if __name__ == ""__main__"": + solve() +" +p03612,s107274665,Accepted,"import sys +import heapq, math +from itertools import zip_longest, permutations, combinations, combinations_with_replacement +from itertools import accumulate, dropwhile, takewhile, groupby +from functools import lru_cache +from copy import deepcopy + +N = int(input()) +A = list(map(lambda x: int(x) - 1, input().split())) + +cnt = 0 +for i in range(N - 1): + if A[i] == i: + cnt += 1 + A[i], A[i + 1] = A[i + 1], A[i] + +if A[N - 1] == N - 1: + cnt += 1 + +print(cnt)" +p03623,s304151783,Accepted,"x,a,b=map(int,input().split());print('AB'[abs(x-a)-abs(x-b)>=0])" +p03910,s783408334,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 5 + 10) +def input(): return sys.stdin.readline().strip() + +def resolve(): + n=int(input()) + + ans=0 + i=0 + while ans= b: + b *= 2 + if i == k: + print('No') + sys.exit() + else: + i += 1 + +while b >= c: + c *= 2 + if i == k: + print('No') + sys.exit() + else: + i += 1 + +print('Yes')" +p02923,s607956975,Wrong Answer,"n=int(input()) +h=list(map(int,input().split())) +ct=0 +ans=0 +flag=0 +for i in range(n-1): + ct+=1 + if h[i] 0: + print(cnt[i])" +p02918,s244071513,Accepted,"# LRRRRRRL, LRL は同じ(不幸な人は3人) +# L, R で分割してやると一回の操作でLRL -> LLL -> で不幸な人が2人へる LR の時は LLで1人減る +n, k = list(map(int, input().split(' '))) +s = input() + +# LLRRRLL -> 1,1,1に変換して合体させていく +old = '' +converted = [] +for c in s: + if old != c: + converted.append(1) + old = c +temp = max(len(converted) - 2*k, 1) # 必ず一人は犠牲になる +print(n - temp)" +p02597,s631365393,Wrong Answer,"n = int(input()) +c= input() + +ans1=c.count(""R"") +ans2=c.count(""W"") + +ans3=0 +for i in range(n//2): + if c[i]==""W"": + ans3+=1 + +print(min([ans1,ans2,ans3]))" +p03327,s934275263,Accepted,"N=int(input()) +if N<=999: + print(""ABC"") +else: + print(""ABD"")" +p02832,s800294959,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +i = 1 +j = 0 +cnt = 0 +while j <= N-1: + if i == A[j]: + i += 1 + j += 1 + else: + j += 1 + cnt += 1 + +print(cnt if cnt < N-1 else ""-1"")" +p02731,s999661938,Wrong Answer,"l=int(input()) +if l%3==0: + k=l/3 + print(k**3) +else: + n=int(l/3) + m=l-2*n + print(n*n*m)" +p03071,s961674471,Accepted,"x,y=map(int,input().split()) +m=max(x,y) +mm=min(x,y) +print(m+max(m-1,mm)) +" +p02683,s088159675,Accepted,"N, M, X = map(int,input().split()) +A = [[int(x) for x in input().split()] for _ in range(N)] + +INF = float('inf') +ans = INF + +for i in range(2**N): + tmp = [0 for _ in range(M+1)] + b = bin(i)[2:].zfill(N) + + for n in range(N): + for m in range(M+1): + tmp[m] += A[n][m] * int(b[N-1-n]) + + if min(tmp[1:]) >= X: + ans = min(ans, tmp[0]) + +if ans == INF: + ans = -1 +print(ans)" +p02953,s773603113,Accepted,"import sys + + +inint = lambda: int(sys.stdin.readline()) +inintm = lambda: map(int, sys.stdin.readline().split()) +inintl = lambda: list(inintm()) +instrm = lambda: map(str, sys.stdin.readline().split()) +instrl = lambda: list(instrm()) + +n = inint() +H = inintl() + +h = H[0] + +for i in range(1,n): + if H[i]+1 < h: + print(""No"") + exit() + if H[i] > h: + h = H[i] + +print(""Yes"") +" +p03127,s845609426,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +count = 0 +countb = 0 +min = min(A) +for i in A: + if i % 2 == 0: + count += 1 + + if i % min == 0: + countb += 1 + +if countb == N: + print(min) +elif count == N: + print(2) +else: + print(1)" +p03309,s894249857,Accepted,"import math +import statistics +N = int(input()) +L = [i for i in map(int,input().split())] +Q = [] +for i in range(len(L)): + Q.append(L[i] - (i+1)) +b = statistics.median(Q) +a = b - 1 +c = b + 1 +res = 0 +res2 = 0 +res3 = 0 +for i in range(N): + res += abs(L[i] - (i+1) - b) + res2 += abs(L[i] - (i+1) - a) + res3 += abs(L[i] - (i+1) - c) +print(int(min(res,res2,res3)))" +p03351,s882519747,Accepted,"a, b, c, d = map(int, input().split()) +if abs(c - a) <= d or (abs(b - a) <= d and abs(c - b) <= d): + print('Yes') +else: + print('No')" +p03997,s154774779,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) +print( (a + b) * h // 2)" +p03328,s071702271,Wrong Answer,"a, b = map(int, input().split()) +x = [i *(i + 1) // 2 for i in range(1, 1000)] +for i in x: + if a < i: + print(i - a) + break" +p03705,s842327571,Accepted,"N, A, B = map(int, input().split()) + +if A > B: + print(0) +elif N == 1 and A != B: + print(0) +elif N == 1 and A == B: + print(1) +else: + print(A+B*(N-1)-(N-1)*A-B+1) + +" +p03037,s905008875,Accepted,"n, m = map(int, input().split()) +start = 1 +end = n +for i in range(m): + l, r = map(int, input().split()) + if start < l: + start = l + if r < end: + end = r +print(max(end - start + 1, 0))" +p03632,s440533929,Accepted,"a, b, c, d = map(int, input().split()) +ans = 0 if (b <= c) or (d <= a) else min(b, d) - max(a, c) +print(ans) +" +p02897,s480500764,Accepted,"n=int(input()) +if n==0: + p=0 + print(""%.9f""%p) +elif n&1: + p=(n//2)+1 + print(""%.9f""%(p/n)) +else: + p=n//2 + print(""%.9f""%(p/n)) " +p03623,s737846063,Wrong Answer,"x,a,b = map(int,input().split()) +print(min(abs(a-x),abs(b-x)))" +p02603,s412501170,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +prev = a[0] +up = False +staks = 0 +money = 1000 +for i in a[1:]: + if i > prev and not up: + staks = money//prev + money = money % prev + up = not up + if i < prev and up: + money += prev*staks + stacks = 0 + up = not up + prev = i +if staks: + money += prev*staks + +print(money) +" +p02848,s264087756,Accepted,"n = int(input()) +s = list(input()) +ans = [] +for i in range(len(s)): + if (ord(s[i])+n)<=ord('Z'): + ans.append(chr(ord(s[i])+n)) + else: + ans.append(chr(ord(s[i])+n-26)) +print(''.join(ans)) +" +p02819,s090483358,Accepted,"import math +ans=int(input().strip('\n')) +if ans!=2: + flag=True + while flag: + for i in range(2,math.ceil(math.sqrt(ans))+1): + if ans%i==0: + flag=False + break + if flag: + break + else: + flag=True + ans+=1 +print(ans)" +p03127,s151313931,Accepted,"def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) + +from fractions import gcd +n = ii() +A = iil() +cd = A[0] +for item in A: + cd = gcd(cd,item) +print(cd)" +p02989,s066334501,Accepted,"N=int(input()) +*D,=map(int,input().split()) +D.sort() +print((D[N//2]-D[N//2-1])*(N%2==0))" +p03239,s451088149,Wrong Answer,"N, T = map(int, input().split()) +List = [] +List2 = [] +min = 1000 + +for i in range(N): + M, B = map(int, input().split()) + List.append([M,B]) + M, B = 0, 0 + +for k in range(N): + if int(List[k][1]) <= T: + List2.append(List[k]) + +for n in range(len(List2)): + if List2[n][0] <= min: + min = List[n][0] + +if min == 1000: + print('TLE') +else: + print(min)" +p02951,s229260925,Accepted,"a, b, c = map(int,input().split()) +l = b+c +ans = l - a +if ans <0: + print(0) +else: + print(ans)" +p02731,s089351609,Accepted,"print((int(input())/3)**3) +" +p04034,s669293519,Accepted,"n, m = map(int, input().split()) + + +A = [[1, 1]] + [[0, 1] for _ in range(n-1)] + +for _ in range(m): + x, y = map(lambda x: int(x) - 1, input().split()) + A[x][1] -= 1 + A[y][1] += 1 + if A[x][0]: + A[y][0] = 1 + + if A[x][1] == 0: + A[x][0] = 0 + +print(sum(a[0] for a in A))" +p02701,s481145746,Accepted,"s=set() +for i in range(int(input())): + s.add(input()) +print(len(s))" +p03860,s714435878,Accepted,"a, s, c = map(str, raw_input() .split()) +print a[0]+s[0]+c[0] +" +p04012,s660050275,Accepted,"w = str(input()) +List = [w[i] for i in range(len(w))] +lis = sorted(List) +#print(lis) +uni = list(set(lis)) +#print(uni) +ans = [] +q = 0 +for i in range(len(uni)): + p = lis.count(uni[i]) + ans.append(p) +for j in range(len(ans)): + q += ans[j]%2 +if q == 0: + print(""Yes"") +else: + print(""No"") +" +p02578,s720087665,Accepted,"import sys +readline = sys.stdin.buffer.readline + +N = int(readline()) +A = list(map(int, readline().split())) + +ans = 0 +height = A[0] +for i in range(1, N): + h = A[i] + if h < height: + ans += height - h + + height = max(height, h) + + +print(ans) +" +p02615,s160609703,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +A.sort(reverse=True) +P=A[0] +for i in range(2,N): + P+=min(A[i-1],A[i-2]) +print(P) +" +p03797,s646165870,Accepted,"import math +N, M = map(int, input().split()) + +ans = 0 + +if N > math.floor(M / 2): + ans = math.floor(M / 2) +else: + ans = N + math.floor((M - N * 2) / 4) + +print(ans)" +p03041,s209269978,Accepted,"N,K=map(int,input().split()) +S=input() +s=list(S) +s[K-1]=s[K-1].lower() +a=''.join(s) +print(a)" +p02595,s199788549,Accepted,"import math +source = input().split() +N, D = int(source[0]), int(source[1]) +X = [] +Y = [] +validPoints = 0 +for i in range(N): + point = input().split() + X.append(int(point[0])) + Y.append(int(point[1])) + +for j in range(len(X)): + distance = math.sqrt(pow(X[j], 2) + pow(Y[j], 2)) + if distance <= D: + validPoints += 1 +print(validPoints)" +p03637,s260090390,Accepted,"n = int(input()) +a = list(map(int, input().split())) +c4 = 0 +ce = 0 +for i in a: + if i%4 == 0: + c4 += 1 + elif i%2 == 0: + ce += 0.5 +if (c4+int(ce)) >= n//2: + print (""Yes"") +else: + print (""No"") +" +p02861,s149320402,Wrong Answer,"import math +n = int(input()) +x = [] +y = [] +z = [] + +for i in range(n): + z.append(list(map(int, input().split()))) + x.append(z[i][0]) + y.append(z[i][1]) + +D = 0 +for i in range(n): + for j in range(n): + if i < j: + continue + D += math.sqrt((x[i]-x[j])**2 + (y[i] - y[j])**2) + +print(D*(n-1)/n)" +p02888,s242533880,Accepted,"import bisect +N=int(input()) +L=list(map(int,input().split())) +L.sort() +ans=0 +for i in range(N-2): + for j in range(i+1,N-1): + a=bisect.bisect_left(L,L[i]+L[j]) + ans+=(a-j-1) +print(ans)" +p03448,s679481106,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +ans = 0 + +for i in range(a+1): + for j in range(b+1): + for k in range(c+1): + if (500*i)+(100*j)+(50*k) == x: + ans += 1 + +print(ans)" +p03076,s797470823,Accepted," +list_1 = [int(input()) for i in range(5)] +list_2 = [] + +for k in list_1: + num_to_10 = 0 + if k % 10 == 0: + list_2.append(0) + continue + while k % 10 != 0: + k += 1 + num_to_10 += 1 + list_2.append(num_to_10) + +last_dish_ind = list_2.index(max(list_2)) +last_dish_time = list_1[last_dish_ind] +del list_1[last_dish_ind] +del list_2[last_dish_ind] +time = sum(list_1) + sum(list_2) + last_dish_time +print(time)" +p02702,s961476305,Wrong Answer,"mod=2019 +n=1 +A=[1] +for k in range(1, 400): + n=n*10%mod + if n in A: + break + else: + A.append(n) +S=input() +count=0 +mod2=len(A) +B=[0] +B.append(int(S[-1])) +if len(S)>3: + for k in range(2,len(S)+1): + if (B[-1]+int(S[-k])*A[(k-1)%mod2])%mod in B: + count+=1 + B.append((B[-1]+int(S[-k])*A[(k-1)%mod2])%mod) + + +print(count) +" +p02854,s437548422,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = [0] +for i in range(N): + S.append(A[i] + S[i]) +ans = float('inf') +for i in range(1, N): + ans = min(ans, abs((S[i] - S[0]) - (S[N] - S[i]))) +print(ans) +" +p02817,s886795770,Accepted,"s,t = list(map(str, input().split())) +print("""".join([t,s]))" +p02646,s259972677,Accepted,"a,v = map(int,input().split()) +b,w = map(int,input().split()) +t = int(input()) +if abs(a-b) <= t*(v-w): + print(""YES"") +else: + print(""NO"")" +p03109,s821998543,Accepted,"d = input() +if int(d[5] + d[6]) <= 4: + print(""Heisei"") +else: + print(""TBD"")" +p03469,s695667847,Accepted,"S = input() +S = S.replace('2017', '2018') +print(S)" +p03860,s542940421,Accepted,"names = input().split() +print("""".join([a[0] for a in names]))" +p02982,s187783293,Accepted,"n,d=map(int,input().split()) +x = [list(map(int, input().split())) for _ in range(n)] + +ans=0 + +for i in range(n): + for j in range(i+1,n): + wrk=0 + for k in range(d): + #print(i,j,k) + wrk+=(x[i][k]-x[j][k])**2 + #print(wrk**0.5) + if wrk**0.5%1==0: + ans+=1 +print(ans)" +p02711,s383088160,Wrong Answer,"n = input() +for ni in n: + if ni == '7': + print('YES') + quit() +print('NO') +" +p02854,s132320943,Accepted,"N=int(input()) +A=list(map(int,input().split())) +import itertools +ACU=itertools.accumulate(A) +B=list(ACU) +MAX=B[-1] +tmp=10**10 +for i in B: + tmp=min(tmp,abs(2*i-MAX)) +print(tmp)" +p02553,s998152304,Accepted,"a, b, c, d = map(int, input().split()) + +lst = [a * c, a * d, b * c, b * d] + +print(max(lst))" +p02935,s881265051,Wrong Answer,"def main(): + import sys + from collections import deque + n=int(input()) + v=list(map(int,sys.stdin.read().split())) + w=deque(sorted(v)) + ans=(w.popleft()+w.popleft())/2 + for i in range(n-2): + ans+=w.popleft()/2 + print(ans) +if __name__==""__main__"": + main()" +p03457,s356841629,Accepted,"n = int(input()); +told,xold,yold = 0,0,0; +ans = 'Yes'; +for i in range(n) : + tnew,xnew,ynew = [int(x) for x in input().split()]; + dis = abs(xnew-xold) + abs(ynew-yold); + diff = tnew - told; + if (diff - dis)%2 == 1 or diff < dis : + ans = 'No'; + break; + else : + told,xold,yold = tnew,xnew,ynew; + +print(ans);" +p02606,s444604276,Accepted,"a,b,c = map(int, input().split()) +ans = 0 +for i in range(a,b+1): + if i % c == 0: + ans += 1 +print(ans) +" +p03035,s479200955,Wrong Answer,"a, b = map(int, input().split()) + +if a >= 13: + print(b) +elif 6 <= a <= 12: + print(b/2) +else: + print(0) +" +p02582,s730586722,Wrong Answer,"S = input() +r = 0 +s = 0 +ans = 0 +for i in range(3): + if S[i] == 'R': + r = r + 1 + else: + if r > ans: + ans = r +print (ans)" +p03250,s061772369,Accepted,"a,b,c = sorted(map(int,input().split())) +print(c*10+b+a)" +p02754,s681650255,Wrong Answer,"n, a, b = map(int, input().split()) + +NumberOfRotations = int(n/(a+b)) +surplus = n%(a+b) + +ans = 0 + +if NumberOfRotations == 0: + if a > n: + print(surplus) + exit + else: + print(a) + exit + +ans = a*NumberOfRotations +if a > n - ((a+b)*NumberOfRotations): + print(ans+surplus) +else: + print(ans+a)" +p02694,s387132091,Accepted,"X = int(input()) +i = 0 +deposit = 100 +while deposit < X: + deposit = int(deposit * 1.01) + i += 1 + +print(i)" +p02836,s965726283,Wrong Answer,"s=input() +c=0 +d=0 +t=len(s) +if t%2==0: + for i in range(int(t/2)): + if s[i]!=s[t-i-1]: + c+=1 + print(c) +else: + for _ in range(int((t-1)/2)): + if s[_]!=s[t-2-_]: + d+=1 + print(d)" +p03730,s140088937,Accepted,"a,b,c = map(int, input().split()) +for x in range(10000): + if (a*x)%b == c: + print('YES') + exit() +print('NO')" +p02631,s937005268,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +total = 0 + +for num in a: + total = total ^ num + +for num in a: + print(total ^ num,end="" "") + +print('') +" +p03657,s340956027,Accepted,"a, b = map(int, input().split()) +print(""Possible"" if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else ""Impossible"")" +p03487,s663666956,Accepted,"import sys +input = sys.stdin.readline +N = int(input()) +a = [int(x) for x in input().split()] + +from collections import Counter +asz = Counter(a) + +ans = 0 +for i in asz : + if i < asz[i] : + ans += asz[i] - i + elif i > asz[i] : + ans += asz[i] + +print(ans) +" +p02779,s214976284,Accepted,"n = int(input()) +a = list(map(int, input().split())) +if len(a) != len(set(a)): + print(""NO"") +else: + print(""YES"")" +p03317,s240019516,Accepted,"import math + +n, k = map(int, input().split()) +a = list(map(int, input().split())) + +print(math.ceil((n-1)/(k-1)))" +p03644,s541330449,Accepted,"n = int(input()) +if n == 1: + print('1') +else: + for i in range(n): + if 2**i <= n and 2**(i+1) > n: + print(2**i) + break" +p02813,s177196433,Wrong Answer,"import itertools +n=int(input()) +p=tuple(map(int,input().split())) +q=tuple(map(int,input().split())) +per=list(itertools.permutations(range(1,n+1))) +a=0 +b=0 +for num,i in enumerate(per): + if i==p: a=num + elif i==q: b=num +print(abs(a-b)) +" +p02789,s814417753,Accepted,"N, M = [int(x) for x in input().split("" "")] +print(""Yes"" if N == M else ""No"") +" +p03095,s343788956,Accepted,"from collections import Counter + +n=int(input()) +s=input() + +mod=10**9+7 + +ans=1 + +c=Counter(s) + +for v in c.values(): + ans*=v+1 + ans%=mod + +print(ans-1)" +p02767,s560530673,Accepted,"N=int(input()) +X = list(map(int, input().split())) +X.sort() +p = X[0] +min_power = float('inf') +while p <= X[-1]: + power = 0 + for x in X: + power += pow((x-p),2) + min_power = min(min_power, power) + p += 1 +print(min_power)" +p03485,s858002999,Wrong Answer,"import sys +input = sys.stdin.readline +a, b = map(int,input().split()) +print((a+b)//2+1)" +p02717,s632444061,Accepted,"x,y,z = map(int, input().split()) +print(z,x,y)" +p02909,s494943267,Accepted,"S=input() +if S==""Sunny"": + print(""Cloudy"") +if S==""Cloudy"": + print(""Rainy"") +if S==""Rainy"": + print(""Sunny"")" +p03485,s588367573,Accepted,"a, b = map(int, input().split()) +print(int((a+b)/2) if (a+b)%2==0 else int((a+b+1)/2))" +p03625,s122227811,Accepted,"import sys +input = sys.stdin.readline + +n = int(input()) +a = list(map(int, input().split())) +cnt = 0 +check = 0 +ans = 1 + +a.sort(reverse=True) +for i in range(n - 1): + if a[cnt] == a[cnt + 1]: + check += 1 + ans *= a[cnt] + cnt += 2 + if check == 2: + print(ans) + exit() + else: + cnt += 1 + + if cnt == n - 1: + break +print(0) +" +p04020,s696192432,Wrong Answer,"n = int(input()) +cnt = [0]*n +for i in range(n): + a = int(input()) + cnt[i] += a + +ans = 0 +# 塔子 +for i, j in zip(range(n-1), range(1, n)): + x, y = cnt[i], cnt[j] + z = min(x, y) + ans += z + cnt[i] -= z + cnt[j] -= z + +# 対子 +for i in range(n): + z = cnt[i] // 2 + ans += z +print(ans) +" +p02729,s461086077,Accepted,"N, M = map(int, input().split()) + +a = N * (N-1) // 2 +b = M * (M-1) // 2 + +print(a+b)" +p03377,s538446824,Accepted,"a, b, x = map(int, input().split()) + +if (x < (a + b) and x >= a): + print('YES') +else: + print('NO') +" +p03698,s192931060,Wrong Answer,"s = input() +print('yes' if list(s) == set(s) else 'no')" +p02546,s872628706,Wrong Answer,"word = input() +if word[-1] == ""s"": + word_new =word[:-1] + ""es"" + print(word_new) +else: + print(word + ""s"")" +p02786,s684721869,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + h=int(input()) + cnt=0 + while h>1: + h=h//2 + cnt+=1 + print(2**(cnt+1)-1) +resolve()" +p04044,s021841285,Accepted,"n, l = map(int, input().split()) +lst = [] +for i in range(n): + si = input() + lst.append(si) +lst.sort() + +ans = '' +for i in range(n): + ans += lst[i] +print(ans)" +p02994,s770198907,Accepted,"n, l = map(int, input().split()) +ans = (l+(l+n-1))*n//2 +if l > 0: + ans -= l +if l+n-1 < 0: + ans -= l+n-1 +print(ans)" +p03251,s593054640,Accepted,"n, m, x, y = map(int,input().split()) +xList = list(map(int,input().split())) +yList = list(map(int,input().split())) + +judge = sorted(xList,reverse=True)[0]+1 + +if judge <= sorted(yList)[0] and x < judge <= y: + print(""No War"") +else: + print(""War"") +" +p03474,s180825692,Accepted,"import sys +a, b = map(int, input().split()) +s = input() + +if s[:a].isdigit() and s[a] == '-' and s[a+1:].isdigit(): + print(""Yes"") +else: + print(""No"") +" +p03319,s003608028,Accepted,"def main(): + N,K = map(int,input().split()) + A = input() + from math import ceil + print(1+ceil((N-K)/(K-1))) +main()" +p03319,s460657747,Accepted,"n, k =map(int, input().split()) +a = list(map(int, input().split())) + +ans = int((n-1)/(k-1)) + +if ((n-1) % (k-1)) == 0: + print(ans) +else: + print(ans+1)" +p03284,s970786995,Accepted,"n,k=list(map(int,input().split())) +print(-(-n//k)-(n//k))" +p02939,s796646606,Accepted,"s=input() +if len(s)<=2: + print(len(set(list(s))));exit() +dp=[0]*(len(s)+ 1) +dp[0]=0 +dp[1]=1 +dp[2]=(len(set(list(s[:2])))) + +for i in range(3,1+len(s)): + dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2) +print(dp[-1])" +p02759,s843898142,Wrong Answer,"import math + +N = int(input()) + +if N % 2 == 0: + M = N/2 + print(M) +else: + M = N/2 + 1 + print(math.floor(M))" +p02773,s156942751,Wrong Answer,"box={} +n=int(input()) +for i in range(n): + v=input() + if v in box: + box[v]+=1 + else: + box[v]=1 +m=max(box.values()) +f=[k for k,v in box.items() if v==m] +print('\n'.join(f))" +p02713,s164558125,Accepted,"from math import gcd +k = int(input()) +sum = 0 +for a in range(k): + for b in range(k): + gcd_ab = gcd(a + 1, b + 1) + for c in range(k): + sum += gcd(gcd_ab, c + 1) +print(sum)" +p02743,s123316167,Wrong Answer,"import math as m +def int_sqrt(n): + def f(prev): + while True: + m = (prev + n / prev) / 2 + if m >= prev: + return prev + prev = m + return f(int(m.sqrt(n) * (1 + 1e-10))) + +if __name__ == ""__main__"": + a,b,c = map(int,input().split()) + if(int_sqrt(a)+int_sqrt(b) < int_sqrt(c)): + print(""Yes"") + else: + print(""No"")" +p02771,s121431852,Accepted,"a,b,c=map(int,input().split()) + +def hantei(n1,n2,n3): + ans=""Yes"" + if n1==n2 and n2==n3: + ans=""No"" + if n1!=n2 and n2!=n3 and n3!=n1: + ans=""No"" + return ans + +print(hantei(a,b,c))" +p02923,s795986371,Wrong Answer,"import math +import copy + +neko = 0 +nuko = 0 +inu = 0 +n = int(input()) +h = [int(x) for x in input().split()] +nya = h[0] +for i in h: + if nya >= i: + neko += 1 + else: + neko = 0 + if neko > inu: + inu = neko + if nya <= i: + nuko += 1 + else: + nuko = 0 + if nuko > inu: + inu = neko + nya = i +print(inu)" +p02823,s791507211,Wrong Answer,"#!/usr/bin/env python3 + +n, a, b = map(int, input().split()) + +ans = 0 +if (b-a)%2 == 0: + ans = int((b-a)/2) +else: + if a-1 >= n-b: + ans = n-a + else: + ans = b-1 + +print(ans) +" +p02900,s958980278,Wrong Answer,"from math import sqrt +from fractions import gcd +A, B = map(int,input().split()) +Y = gcd(A, B) +ans = 1 +if Y != 1: + for i in range(2, min(Y+1,int(sqrt(Y))+2)): + tmp = 0 + while True: + if Y%i == 0: + Y //= i + tmp += 1 + else: + if tmp > 0: + ans += 1 + break + if ans == 1: + ans += 1 +print(ans)" +p03086,s272419038,Accepted,"s = input() +ans = 0 +total = 0 +for i in range(len(s)): + if s[i] == ""A"" or s[i] == ""G"" or s[i] == ""C"" or s[i] == ""T"": + total += 1 + else: + ans = max(ans, total) + total = 0 +print(max(ans, total)) +" +p03127,s281820715,Wrong Answer,"import math +from functools import reduce +import itertools + +def solve(): + n = int(input()) + a = list(map(int, input().split())) + bit = 0 + for i in range(n): + if a[i] % 2 != 0: + bit = 1 + break + if bit == 0: + print(min(a)) + else: + print(1) + return 0 + +if __name__ == ""__main__"": + solve() +" +p03387,s168094914,Wrong Answer,"number = list(map(int, input().split())) +number.sort() +ans = 0 +while number[2] != number[1]: + number[1] += 1 + number[0] += 1 + ans += 1 +diff = number[2] - number[0] +if diff % 2 == 0: + ans += diff//2 +else: + ans += max(1, diff//2) + 1 +print(ans) +" +p03211,s559108761,Accepted,"# 初期入力 +import sys +input = sys.stdin.readline #文字列では使わない +S =input().strip() +dif =[] +for i in range(len(S)-2): + x =abs(int(S[i:i+3]) -753) + dif.append(x) +print(min(dif))" +p02706,s887610668,Accepted,"N, M = map(int, input().split()) +A = input().split() +if sum(int(i) for i in A) > N: + print(-1) +else: + print(N - sum(int(i) for i in A))" +p03469,s278345873,Accepted,"s=input() +print('2018'+s[4:])" +p03471,s468442859,Accepted,"N, Y = [int(i) for i in input().rstrip().split(' ')] + +cnt = [int(-1)for i in range(3)] +for A in range(N+1): + for B in range(N+1 - A): + C = N - A - B + calc = A*10000 + B*5000 + C*1000 + if calc == Y: + cnt = [A, B, C] + break + else: + continue + break +print(' '.join(map(str,cnt))) +" +p02761,s299787795,Accepted,"N,M=map(int,input().split()) +A=[0 for i in range(N)] +flg=0 + +for i in range(M): + s,c=map(int,input().split()) + if A[s-1]!=0 and A[s-1]!=c: + flg=1 + if s==1 and c==0 and N!=1: + flg=1 + if flg==0: + A[s-1]=c + +if flg==1: + print(-1) +else: + if A[0]==0: + if N!=1: + A[0]=1 + print(''.join(map(str,A)))" +p02838,s609132358,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +mod = 10**9+7 +ans = 0 +for i in range(60): + cnt = 0 + for j in range(n): + if a[j]>>i & 1 == 0: cnt += 1 + ans += pow(2,i,mod)*cnt*(n-cnt) +print(ans%mod)" +p02556,s820851792,Accepted,"n = int(input()) +a, b = [], [] +for _ in range(n): + x, y = map(int, input().split()) + a.append(x+y) + b.append(x-y) + +a.sort() +b.sort() + +ans = max(a[-1]-a[0], b[-1]-b[0]) +print(ans)" +p03017,s588191376,Wrong Answer,"def main(): + N, A, B, C, D = (int(i) for i in input().split()) + S = input() + if ""##"" in S[A-1:C] or ""##"" in S[B-1:D]: + return print(""No"") + if D < C and ""..."" not in S[B-1:D]: + return print(""No"") + print(""Yes"") + + +if __name__ == '__main__': + main() +" +p03673,s361504596,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +odd = [] +even = [] +ans = [] + +for i in range(n): + if i % 2 == 0: + odd.append(a[i]) + else: + even.append(a[i]) + +if n == 1: + print(a[0]) + exit() +else: + if n % 2 == 0: + even.reverse() + ans = even + odd + else: + odd.reverse() + ans = odd + even + +print(ans) +" +p03557,s029684251,Wrong Answer,"import itertools +import bisect +n = int(input()) +a=sorted(list(map(int, input().split()))) +b=sorted(list(map(int, input().split()))) +c=sorted(list(map(int, input().split()))) +cnt=0 + +for i in range(0,len(c)): + b_index=bisect.bisect_left(b,c[-i-1]) + print(b_index) + for u in range(b_index): + cnt+=bisect.bisect_left(a,b[b_index-1-u]) + +print(cnt)" +p03360,s798250579,Wrong Answer,"ds = list(map(int, input().split())) +k = int(input()) +sorted(ds) +print(sum(ds[:-1]) + ds[-1]*(2**k))" +p02608,s907824084,Wrong Answer,"def main(): + n = int(input()) + f = [0 for i in range(n+1)] + Max = n**0.5 + Max = int(Max//1) + for x in range(1,Max): + for y in range(1,Max): + for z in range(1,Max): + tmp = x**2+y**2+z**2+x*y+y*z+x*z + if tmp=3: + print(""Yes"") +else: + print(""No"")" +p02546,s558523220,Accepted,"s = str(input()) +if s[-1] =='s': + print(s+'es') +else: + print(s+'s')" +p02726,s790711476,Wrong Answer,"n,x,y = [int(i) for i in input().split()] +ans = [] +for i in range(1,n): + for j in range(i+1,n+1): + chk = j-i + if i<=xx: + ans += A[0]-x + A[0] = x + for i in range(1,N): + if A[i]+A[i-1]>x: + ans += A[i]+A[i-1]-x + A[i] = x-A[i-1] + return ans +print(solve())" +p02681,s240311494,Accepted,"#!/usr/bin/env python3 + +s = str(input()) +t = str(input()) + +if s == t[:-1]: + print(""Yes"") +else: + print(""No"") +" +p02767,s425399066,Accepted,"N = int(input()) +Xlist = list(map(int, input().split())) +Xlist.sort() + +a = sum(Xlist)/N + +a_m = int(a) +a_p = a_m + 1 + +if a - a_m < a_p - a: + p = a_m +else: + p = a_p + +ans = 0 +for i in range(N): + ans += (Xlist[i] - p)**2 + +print(ans)" +p03328,s861388363,Accepted,"a,b=map(int,input().split()) +c=b-a + +d=0 + +for i in range(c): + d+=i + +print(d-a)" +p03659,s451002375,Accepted,"n = int(input()) +a = list(map(int, input().split())) +cum = [0] +for i in range(n): + cum.append(cum[i] + a[i]) +#print(cum) + +ans = int(1e10) +for i in range(1,n): + dif = abs(cum[i] - (cum[n]- cum[i])) + if ans > dif: + ans = dif +print(ans)" +p03815,s737192007,Accepted,"x = int(input()) + +divided_11 = x // 11 +check_num = divided_11 * 11 +ans = divided_11 * 2 + +if x % 11 == 0: + print(ans) +else: + while True: + check_num += 6 + ans += 1 + if check_num >= x: + print(ans) + break + check_num += 5 + ans += 1 + if check_num >= x: + print(ans) + break +" +p03105,s924848982,Wrong Answer,"A, B, C = map(int, input().split()) +print(min(A*C, B))" +p03471,s215530844,Accepted,"N,Y = map(int,input().split()) +flg = 0 +x = -1 +y = -1 +z = -1 +for i in range(Y//10000+1): + for j in range(min(N-i,Y//5000)+1): + k = N-i-j + if k>=0 and 10000*i+5000*j+k*1000==Y: + flg = 1 + x = i + y = j + z = k + break + if flg==1:break +print(x,y,z) + " +p03250,s678116035,Accepted,"L = list(map(int,input().split())) +L.sort() +print(L[2] * 10 + L[1] + L[0])" +p03761,s348889753,Accepted,"alp=[chr(i) for i in range(97, 97+26)] +inf=10000000 +check=[inf]*26 + +n=int(input()) +for i in range(n): + s=input() + ls=len(s) + check_sub=[0]*26 + for j in range(ls): + #print(s[j]) + check_sub[alp.index(s[j])]+=1 + for k in range(26): + check[k]=min(check[k],check_sub[k]) + #print(check_sub) +ans="""" +for i in range(26): + #print(check[i]) + ans+=check[i]*alp[i] +print(ans) +" +p03611,s860187646,Accepted,"n = int(input()) +a = list(map(int,input().split())) +lis = [0]*(10**5+2) + +for i in a: + lis[i-1]+= 1 + lis[i] +=1 + lis[i+1] +=1 +print(max(set(lis)))" +p02970,s502506288,Accepted,"N, D = map(int,input().split()) + +reach = D*2+1 +import math +minimum = math.ceil(N/reach) +print(minimum) +" +p03962,s154923833,Accepted,"#ABC046 +s = input().split() +print(len(set(s)))" +p03852,s326785776,Wrong Answer,"c = str(input()) +l = [""a"", ""e"", ""i"", ""o"", ""u""] +if c in l: + print(""vowel"") + +else: + print(""constant"")" +p02570,s240735502,Accepted,"INPUT = input().split() +D = int(INPUT[0]) +T = int(INPUT[1]) +S = int(INPUT[2]) + +if D/S <= T: + print(""Yes"") +else: + print(""No"")" +p04033,s514884137,Accepted,"a, b = map(int, input().split()) + + +def f(x): + if x < 0: + return -1 + elif x > 0: + return 1 + else: + return 0 + + +if f(a) == 0 or f(b) == 0: + ans = ""Zero"" +elif f(a) == -1 and f(b) == -1: + diff = b - a + if (diff + 1) % 2 == 0: + ans = ""Positive"" + else: + ans = ""Negative"" +elif f(a) == 1 and f(b) == 1: + ans = ""Positive"" +else: + ans = ""Zero"" + +print(ans) +" +p03162,s549146663,Accepted,"N = int(input()) +S = [] +for _ in range(N): + D = list(map(int, input().split())) + S.append(D) + +dp = [[0 for _ in range(3)] for _ in range(N+1)] + +for i in range(1,N+1): + for j in range(3): + for k in range(3): + if j != k: + happy = dp[i-1][k] + S[i-1][j] + if dp[i][j] < happy: + dp[i][j] = happy + +print(int(max(dp[N])))" +p02753,s513759086,Wrong Answer,"s = input().split() +n = 0 +for i in range(len(s) - 1): + if s[i] != s[i + 1]: + n += 1 +if n >= 1: + print('Yes') +else: + print('No')" +p02861,s469430331,Wrong Answer,"n=int(input()) +l=[list(map(int,input().split())) for _ in range (n)] + +a=0 + +for i in range (n): + for j in range (n): + a+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**(1/2) + +print (a*2/n)" +p02594,s152598009,Wrong Answer,"X = int(input()) +if 40 >= X >= -40: + print('yes') +else: + print('no')" +p03206,s798226399,Accepted,"D = int(input()) +ans = ['Christmas'] + ['Eve'] * (25 - D) +print(' '.join(ans)) +" +p03371,s017410373,Accepted,"A,B,C,X,Y = map(int,input().split()) + +cost = A*X + B*Y +a = X +b = Y +c = 0 +N = max(X,Y) + +for i in range(N): + c += 2 + if a > 0: + a -= 1 + if b > 0: + b -= 1 + cost = min(cost,A*a + B*b + c*C) +print(cost)" +p03639,s207940272,Accepted,"N = int(input()) +A = list(map(int,input().split())) +C = {0:0,2:0,4:0} +for i in range(N): + a = A[i] + if a%2==1: + C[0] += 1 + elif a%4==0: + C[4] += 1 +C[2] = N-C[0]-C[4] +if C[4]==C[0]-1: + if C[2]<=C[4]-1: + print(""Yes"") + else: + print(""No"") +elif C[4]>=C[0]: + print(""Yes"") +else: + print(""No"") +" +p03286,s614048811,Wrong Answer,"n = int(input()) +ansl = [] +while n != 0: + if n % 2 == 1: + ansl.append(""1"") + n -= 1 + else: + ansl.append(""0"") + n //= -2 +print("""".join(ansl)[::-1])" +p03827,s920657673,Accepted,"n=input();s=input(); +x=0 +max_num=0 +for i in s: + if i=='I': + x+=1 + else: + x-=1 + max_num=max(max_num,x) +print(max_num)" +p03795,s263079407,Accepted,"n=int(input()) +x=800*n +y=200*(n//15) +print(x-y) +" +p04020,s054932780,Accepted,"N=int(input()) +A=[int(input()) for _ in range(N)] +cnt=0 +buf=0 +#print(A) +if N==1: + print(A[0]//2) +else: + for i in range(N-1): + su=A[i]+A[i+1] + cnt=cnt+su//2 + buf=(su//2)*2 + if buf>A[i]: + A[i+1]=A[i+1]-(buf-A[i]) + A[i]=0 + else: + A[i]=A[i]-buf + #print(A,cnt) + print(cnt)" +p03206,s378047444,Accepted,"d=int(input()) +c=""Christmas"" +e=""Eve"" +if d==25: + print(c) +elif d==24: + print(c,e) +elif d==23: + print(c,e,e) +elif d==22: + print(c,e,e,e)" +p02843,s081275292,Wrong Answer,"import itertools +x = int(input()) +if x>=2000: + print(1) + exit() +else: + l = list() + for nums in itertools.product(l,repeat=6): + if (nums[0]*100+nums[1]*101+nums[2]*102+nums[3]*103+nums[4]*104+nums[5]*105)==x: + print(1) + exit() +print(0)" +p03417,s259013312,Wrong Answer,"n,m = map(int,input().split()) +mx = max(n,m) +mn = min(n,m) + +if mn == 1: + if mx == 1: + print(1) + else: + print(m - 2) +elif mn >= 2: + print((mx - 2) * (mn - 2)) +" +p02880,s389630383,Accepted,"n = int(input()) +ans = 'No' +for i in range(1,10): + for j in range(i,10): + if i*j == n: + ans = 'Yes' +print(ans)" +p02596,s312837669,Wrong Answer,"k = input() +flag = True +for i in k: + if i != '7': + flag = False + break +if flag: print(len(k)) +else: + k = int(k) + for i in range(1,k+1): + a = pow(10,i,k) - 1 + if a%9 == 0: + print(i) + flag = True + break + if not flag: print(""-1"") +" +p03835,s107708910,Accepted,"if __name__ == '__main__': + K, S = map(int, input().split()) + + ans = 0 + for x in range(K+1): + for y in range(K+1): + z = S - x - y + if 0 <= z and z <= K: + ans += 1 + + print(ans)" +p02832,s748218718,Wrong Answer,"n = int(input()) +a = [int(i) for i in input().split()] +c = 0 +d = 0 +for i in range(n): + for j in range(c, n): + if i + 1 == a[j]: + c = j + d += 1 + break + if c == n - 1: + break +if 1 not in a: + print(-1) +else: + print(n - d)" +p03061,s489523576,Accepted,"import fractions +from functools import reduce + +n = int(input()) +a = list(map(int,input().split())) + +#累積GCD +left = [0] * (n + 1) +right = [0] * (n + 1) +for i in range(n): + left[i + 1] = (fractions.gcd(left[i],a[i])) + right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i])) + +ans = 0 +for i in range(n): + ans = max(ans,fractions.gcd(left[i],right[i + 1])) +print(ans) " +p03495,s501788267,Accepted,"from collections import Counter +N,K = map(int, input().split()) +A = Counter(input().split()) +B = A.values() +k = len(B) - K +if k <= 0: + print(0) +else: + print(sum(sorted(B)[0:k]))" +p03239,s841705239,Accepted,"n,tt=map(int,input().split()) +ans=1001 +for i in range(n): + c,t=map(int,input().split()) + if t<=tt and c price: + low_p = price + share = cash // price + + if low_p < price: + cash += (price - low_p) * share + low_p = price + +print(cash)" +p02881,s745174227,Accepted,"def main(): + N = int(input()) + + ans = N - 1 + + d = 1 + while d * d <= N: + if N % d == 0: + ans = min(ans, d + N // d - 2) + d += 1 + + print(ans) + + +if __name__ == '__main__': + main() +" +p02606,s986861949,Accepted,"L, R, d = map(int, input().split()) + +x = L +ans = 0 + +while x<=R: + if x % d == 0: + ans += 1 + x += 1 + +print(ans) +" +p03612,s311155533,Accepted,"N = int(input()) +p = list(map(int,input().split())) +cnt = 0 +flag = True +for i in range(N): + if p[i] == i+1: + if flag: + cnt += 1 + flag = False + else: + flag = True + else: + flag = True +print(cnt) + " +p02897,s618284408,Accepted,"n = float(input()) + +print(float((n//2+(n-n//2*2))/(n//2*2+(n-n//2*2)))) +" +p03471,s941767244,Wrong Answer,"def resolve(): + + N,Y=map(int,input().split()) + for i in range(N+1): + for j in range(N+1-i): + if 10000*i+5000*j+1000*(N-i-j)==Y: + print(i,end=' ') + print(j,end=' ') + print(N-i-j) + +resolve()" +p03239,s831375878,Accepted,"def main(): + N, T = map(int, input().split()) + path = [[int(a) for a in input().split()] for i in range(N) ] + minc = 10000 + for [c, t] in path: + if t <= T : + if minc > c: + minc = c + if minc == 10000: + print(""TLE"") + else: + print(minc) +main()" +p03657,s008914804,Wrong Answer,"a, b = map(int, input().split()) +print('Possible' if (a // 3) == 0 or (b // 3) == 0 or ((a + b) // 3) == 0 else 'Impossible') +" +p03632,s900696837,Wrong Answer,"a, b, c, d = map(int,input().split()) + +# 2次関数の最大値を求める感じの場合分け +if a >= d or b <= c: + print(0) + exit() + +if d >= a and c <= a: + print(d-a) + exit() + +if c >= a and b >= d: + print(d-c) + exit() + +if d >= b and c <= b: + print(b-c) + exit() + +if a >= c and d >= b: + print(b-a) + exit()" +p02683,s054144842,Accepted,"n,m,x=map(int,input().split()) +c=[list(map(int,input().split())) for _ in range(n)] +import itertools +sum_min=10**7 +for i in itertools.product([0,1],repeat=n): + level=[0]*m + for j in range(m): + level[j]=sum(i[k]*c[k][j+1] for k in range(n)) + for l in range(m): + if level[l]= 2) + +if len(edge) < 2: + ans = 0 +elif edge[-1][1] >= 4: + ans = edge[-1][0] ** 2 +else: + ans = edge[-1][0] * edge[-2][0] + +print(ans) +" +p03136,s847847929,Accepted,"n = int(input()) +l = list(map(int, input().split())) + +if max(l) < sum(l)-max(l): + print('Yes') +else: + print('No')" +p03611,s963251088,Wrong Answer,"import collections +n = int(input()) +a = list(map(int,input().split())) +p = [0 for i in range(max(a)+2)] + +for i in range(n): + p[a[i]] += 1 + p[a[i] + 1] += 1 + p[a[i] - 1] += 1 + +print(max(p))" +p04031,s478488556,Accepted,"N = int(input()) +lst = list(map(int, input().split())) +avg = round(sum(lst) / N) + +result = 0 +for i in lst: + result += (i - avg)**2 + +print(result) +" +p02712,s538755355,Wrong Answer,"n=int(input()) +total=0 +for i in range(0,n+1): + if (i%3==0 and i%5==0) or i%3==0 or i%5==0: + total+=0 + else: + print(i) + total+=i +print(total)" +p02622,s951604894,Accepted,"S = list(input()) +T = list(input()) +ans = 0 + +for i in range(len(S)): + if S[i] == T[i]: + pass + else: + ans += 1 +print(ans)" +p03487,s837600752,Wrong Answer,"from collections import Counter +n = int(input()) +a = map(int, input().split()) +counter = Counter(a) +ans = 0 +for i, j in counter.items(): + ans += min(abs(j - i), j) +print(ans) +" +p02708,s091194746,Accepted,"n, k = map(int, input().split()) +ans = 0 +mod = 10**9+7 +for i in range(k, n+2): + ans += i*(2*n-i+1)//2 - i*(i-1)//2 + 1 + ans %= mod +print(ans)" +p02818,s506851071,Wrong Answer,"A, B, K = map(int, input().split()) + +if A - K >= 0: + A = A - K + print(A, B) +else: + B = B - (K - A) + A = 0 + print(A, B)" +p03773,s030803629,Wrong Answer,"a, b = [int(i) for i in input().split()] +tmp = a + b +if tmp >= 24: + print(tmp // 24) +else: + print(tmp)" +p03836,s049478273,Accepted,"sx,sy,tx,ty = map(int, input().split()) +ans = [] +for _ in range(ty-sy): + ans.append(""U"") +for i in range(tx-sx): + ans.append(""R"") +for i in range(abs(sy-ty)): + ans.append(""D"") +for i in range(abs(sx-tx)): + ans.append(""L"") + +ans.append(""L"") +for i in range(ty-sy+1): + ans.append(""U"") +for i in range(tx-sx+1): + ans.append(""R"") +ans.append(""D"") +ans.append(""R"") +for i in range(abs(sy-ty)+1): + ans.append(""D"") +for i in range(abs(sx-tx)+1): + ans.append(""L"") +ans.append(""U"") + +print("""".join(ans))" +p02618,s047804766,Wrong Answer,"t_list = [i % 26 for i in range(365)] +for i in range(365): + print(t_list[i]) +" +p03317,s218394396,Wrong Answer,"N, K = map(int, input().split()) +l = list(map(int, input().split())) +index = l.index(1) + +ans = 0 +if index != 0: + p = (index + 1) - K + ans += 1 + if p < 0: + index = K - 1 + + while p > 0: + p = p - K + ans += 1 + +while index < (N - 1): + index = index + K - 1 + ans += 1 + +print(ans)" +p03627,s071451988,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int, input().split())) + +c = Counter(a) + +e = [] +for k, v in c.items(): + if v > 3: + e.append(k) + e.append(k) + elif v > 1: + e.append(k) +e.sort(reverse=True) + +if len(e)<2: + print(0) +else: + print(e[0]*e[1])" +p03061,s055975051,Accepted,"from fractions import gcd +n = int(input()) +a = [int(i) for i in input().split()] +gcd_ = [0] * n +L, R = [0] * (n + 1), [0] * (n + 1) +for i in range(n): + L[i + 1] = gcd(L[i], a[i]) + R[n - (i + 1)] = gcd(R[n - i], a[(n - 1) - i]) +for i in range(n): + gcd_[i] = gcd(L[i], R[i + 1]) +print(max(gcd_))" +p02612,s525372072,Accepted,"n = int(input()) + +c = n % 1000 + +if c == 0: + print(0) +else: + print(1000 - c) +" +p03457,s873129278,Wrong Answer,"n = int(input()) + +tp = 0 +xp = 0 +yp = 0 +flag = 0 +for i in range(n): + t, x, y = map(int,input().split()) + dt = t-tp + dx = abs(xp-x) + dy = abs(yp-y) + if dx+dy==dt: + flag=1 + elif dt%2==0 and dx%2==0 and dy%2==0: + flag=1 + elif dt%2==0 and dx%2==1 and dy%2==1: + flag=1 + elif dt%2==1 and dx%2==0 and dy%2==1: + flag=1 + elif dt%2==1 and dx%2==1 and dy%2==0: + flag=1 + tp=t + xp=x + yp=y + +if flag==1: + print(""Yes"") +else: + print(""No"") + " +p03076,s826295245,Wrong Answer,"menu=[] +total=10 +c=0 +for i in range(5): + a=int(input()) + b=a%10 + if 0b: + total=b + menu.append(a) + else: + menu.append(a+10-b) + else: + menu.append(a) +print(sum(menu))" +p03208,s371581993,Accepted,"n,k=map(int,input().split()) +h=[int(input()) for _ in range(n)] +h.sort() +ans=[0]*(n-k+1) +for i in range(n-k+1): + ans[i]=h[k+i-1]-h[i] +print(min(ans)) +" +p02993,s832326057,Accepted,"S = input() +n = len(S) + +answer = 0 +for i in range(n - 1): + if S[i] == S[i + 1] : + answer = 1 + +if answer == 1: + print(""Bad"") +else: + print(""Good"")" +p02747,s680279372,Wrong Answer,"s = input() +n = len(s) +pr =s[0] +ls = [""h"",""i""] +cnt = 0 +for i in range(n): + pr = s[i] + if pr == ls[cnt]: + pass + cnt = (cnt+1)%2 + else: + print(""No"") + break +else: + print(""Yes"") +" +p03625,s216590589,Wrong Answer,"n = int(input()) +d = {} +for ai in input().split(): + ai = int(ai) + if ai not in d: + d[ai] = 0 + d[ai] += 1 + +n2 = [k for k in d if d[k] > 1] +n4 = [k for k in d if d[k] > 3] + +n2.sort(reverse = True) +n4.sort(reverse = True) + +ans = 0 + +if n4: + ans = n4[0] ** 2 + +if len(n2) > 1: + max(ans, n2[0] * n2[1]) + +print(ans) +" +p04029,s801948469,Accepted,"n=int(input()) +print(int(n*(n+1)/2))" +p02731,s283799069,Accepted,"L = int(input()) +l = L/3 +print(l**3) +" +p03971,s581061783,Accepted,"n, a, b = map(int, input().split()) +S =input() + +x = 1 +y = 1 +for i in range(len(S)): + if S[i] == ""a"": + if x <= a + b: + print(""Yes"") + x += 1 + else: + print(""No"") + elif S[i] == ""b"": + if (x <= a + b) and (y <= b): + print(""Yes"") + x += 1 + y += 1 + else: + print(""No"") + else: + print(""No"")" +p03494,s821362697,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +B = [] +for i in A: + cnt = 0 + while i%2 == 0: + if i%2 == 0: + cnt += 1 + i = i/2 + B.append(cnt) +print(min(B)) +" +p03524,s892868789,Wrong Answer,"import collections +s = list(input()) + +c = collections.Counter(s).most_common() +if c[0][1] >= c[-1][1] + 2: + print('NO') +else: + print('YES') +" +p03795,s953911743,Wrong Answer,"N=int(input()) +print(N*800 - N%15*200)" +p03767,s164173511,Wrong Answer,"N = int(input()) +a = list(map(int, input().split())) +a.sort() + +ans = 0 +for i in range(N): + ans += a[len(a)-2-i] +print(ans)" +p02773,s094037766,Wrong Answer,"#C-Poll +import collections +n=int(input()) +words = [input() for _ in range(n)] +count = collections.Counter(words) +leng = len(count) +ansallay = [] +#抽出用に何回出てればansに出すかを変数に突っ込む +record = count.most_common()[0][1] +for num in range(leng-1): + if(count.most_common()[num][1] == record): + ansallay.append(count.most_common()[num][0]) + else: + break +ansallay.sort() +for word in ansallay: + print(word)" +p02866,s153050166,Wrong Answer,"from collections import Counter +n = int(input()) +d = list(map(int, input().split())) +mod = 998244353 +if d[0] != 0: + print(0) +else: + a = Counter(d) + ans = 1 + for i in range(1, max(d)+1): + ans *= a[i-1]**a[i] + ans %= mod + print(ans) + +" +p02768,s162717423,Accepted,"n, a, b = map(int, input().split()) +mod = 10**9+7 + +ans = pow(2, n, mod)-1 + +def choose(n, r): + res = 1 + fac = 1 + for i in range(r): + res *= n-i + res %= mod + fac *= i+1 + fac %= mod + return res*pow(fac, mod-2, mod)%mod + +ans -= choose(n, a) +ans -= choose(n, b) + +print(ans%mod)" +p02748,s028237732,Accepted,"A, B, M = [int(i) for i in input().split()] +a = [int(i) for i in input().split()] +b = [int(i) for i in input().split()] +mi = min(a) + min(b) + +for i in range(M): + c1, c2, c3 = [int(j) for j in input().split()] + m = a[c1-1] + b[c2-1] - c3 + if mi > m: + mi = m + +print(mi)" +p02628,s992431745,Accepted,"n, k = map(int, input().split()) + +p = sorted(list(map(int, input().split()))) +print(sum(p[:k])) + +" +p02765,s108354120,Accepted,"#!/usr/bin/env python3 +# %% +stdin = open(0) + +# %% +N,R = map(int, stdin.read().split()) +if N >= 10: + answer = R +else: + answer = R + 100 * (10-N) + +# %% +print(answer) + +# %% +" +p03665,s824876799,Wrong Answer,"n, p = map(int, input().split()) +a = list(map(int, input().split())) + +if n == 1 and a[0] % 2 == 0: + if p == 0: + print(2) + else: + print(0) +elif n == 1 and a[0] % 2 == 1: + print(1) +else: + print(2 ** n // 2)" +p03611,s930658211,Wrong Answer,"from math import* +from bisect import* +import copy + +n=int(input()) +arr=list(map(int,input().split())) +arr.sort() +brr=copy.deepcopy(arr) +brr=list(set(brr)) +#print(arr) +ans=0 +#print(bisect_right(arr,6)) +for i in range(len(brr)): + d=bisect_left(arr,brr[i]) + c=bisect_right(arr,brr[i]+2) + if ans=k-a%k: + ans=""OK"" +else: + ans=""NG"" +print(ans)" +p02731,s482342814,Accepted,"L=int(input()) +print((L**3)/27) +" +p03836,s961298046,Accepted,"sx,sy,tx,ty = map(int,input().split()) +x_move = tx - sx +y_move = ty - sy +ans = """" +for i in range(x_move): + ans += ""R"" +for j in range(y_move): + ans += ""U"" +for a in range(x_move): + ans += ""L"" +for b in range(y_move): + ans += ""D"" +ans += ""L"" +for i in range(y_move + 1): + ans += ""U"" +for i in range(x_move + 1): + ans += ""R"" +ans += ""D"" +ans += ""R"" +for i in range(y_move + 1): + ans += ""D"" +for i in range(x_move + 1): + ans += ""L"" +ans += ""U"" +print(ans)" +p03417,s215109546,Wrong Answer,"def main(): + n, m = map(int, input().split()) + if n == 1 and m == 1: + print(1) + if n == 1 or m == 1: + print(max(n-2, m-2)) + else: + print(n*m-2*(n+m)+4) +if __name__ == ""__main__"": + main()" +p02946,s079033590,Accepted,"k, x = map(int, input().split()) +for i in range(x-(k-1), x+(k-1)+1): + print(i, end=' ') +print() +" +p02711,s400697568,Accepted,"N = int(input()) +N = str(N) +if ""7"" in N: + print(""Yes"") +else: + print(""No"")" +p02795,s825829726,Accepted," +def f(t, _ans, length): + for _ in range(length): + t += length + _ans += 1 + + if t >= n: + print(_ans) + exit() + + return _ans + +h = int(input()) +w = int(input()) +n = int(input()) +t = 0 +ans = 0 + +if h > w: + f1, f2 = h, w +else: + f1, f2 = w, h + +ans = f(t, ans, f1) +f(t, ans, f2) +" +p02970,s241208309,Wrong Answer,"from math import * +n,k=map(int,input().split()) +print(ceil(n/k))" +p03478,s770122529,Accepted,"N,A,B = map(int,input().split()) +cnt = 0 +sum = 0 +i = 0 +for i in range(N+1): + j = 0 + tmpsum = 0 + l = list(str(i)) + for j in l: + tmpsum += int(j) + if tmpsum>=A and tmpsum <=B: + sum += i +print(sum)" +p02628,s478027014,Wrong Answer,"n,k=map(int,input().split()) +p=list(map(int,input().split())) +pnew=sorted(p) +sums=0 +for i in range(k): + sums=sums+pnew[i] + +print(pnew) +print(sums)" +p02970,s274465421,Accepted,"#!/usr/bin/python3 +import sys +input = lambda: sys.stdin.readline().strip() +n, d = [int(x) for x in input().split()] +l = 2 * d + 1 +print((n + l - 1) // l)" +p03261,s750963792,Accepted,"n = int(input()) +w_list = [input() for _ in range(n)] + +flag = True + +for i in range(1, n): + if w_list[i-1][-1] != w_list[i][0]: + flag = False + elif w_list[i] in w_list[:i-1]: + flag = False +if flag == True: + print(""Yes"") +else: + print(""No"")" +p03043,s220691422,Wrong Answer,"n,k = map(int,input().split()) +coin = [0]*n +while k > 1: + for i in range(min(int(k-1/1e10),n)): + coin[i] += 1 + k /= 2 +ans = 0 +print(coin) +for i in range(n): + ans += 1 / (2**coin[i] * n) +print(ans) +" +p02900,s551808860,Accepted,"A, B = map(int, input().split()) + +def fact(n): + k = 2 + l = [] + temp=n + while pow(k, 2)<=n: + if temp%k==0: + l.append(k) + while temp%k==0: + temp//=k + k+=1 + if temp!=1: + l.append(temp) + return l + +if A==1 and B==1: + print(1) +elif A==B: + print(len(set(fact(A)))+1) +else: + print(len(set(fact(A))&set(fact(B)))+1)" +p03696,s391397082,Accepted,"N = int(input()) +S = input().strip() +while True: + lv = 0 + lmin = len(S) + for i in range(len(S)): + if S[i]==""("": + lv += 1 + else: + lv -= 1 + lmin = min(lmin,lv) + if lmin<0: + S = ""(""*(-lmin)+S + else:break +lv = 0 +for i in range(len(S)): + if S[i]==""("": + lv += 1 + else: + lv -= 1 + +if lv>0: + S = S+"")""*lv +print(S)" +p02775,s845783578,Accepted,"s = input()[::-1] +size = len(s) +s += ""4"" + +a, b = 0, 0 + +for i in range(size): + v1, v2 = int(s[i]), int(s[i+1]) + if v1+b>=6 or (v1+b>=5 and v2>=5): + a += 10-v1-b + b = 1 + else: + a += v1+b + b = 0 + +print(a+b) +" +p03427,s787564146,Accepted,"n=int(input()) +k=len(str(n)) +if k==1: + print(n) +else: + a=str(n) + array=list(map(int,list(a))) + print(max(int(a[0])-1+9*(k-1),sum(array)))" +p02755,s174212616,Wrong Answer,"a, b = map(int, input().split()) + +a_min = -(-a*100//8) +a_max = int((a+1)*100/8) +b_min = -(-b*100//10) +b_max = int((b+1)*100/10) + +if a_max >= b_min and b_max >= a_min: + print(max([a_min, b_min])) +else: + print(-1)" +p02784,s802194584,Wrong Answer,"h, n = map(int, input().split()) +a = list(map(int, input().split())) +hp = 0 + +for i in range(n): + h -= a[i] + +if h < 0: + print('Yes') +else: + print('No')" +p04033,s132606102,Accepted,"#AGC002-A +a,b = map(int,input().split()) +if a > 0: + print('Positive') +elif a <= 0 and b >= 0: + print('Zero') +else: + if (b - a + 1) % 2 == 0: + print('Positive') + else: + print('Negative') +" +p04020,s467298556,Wrong Answer,"N,*A=map(int, open(0).read().split()) +acc=A[0] +ans=0 +for a in A[1:]: + b=min(acc,a) + acc-=b + ans+=b+acc//2 + acc=a-b +print(ans)" +p02697,s684767980,Wrong Answer,"N, M = map(int, input().split()) + +i = 1 +j = N +if N % 2 == 1: + for k in range(M): + print(i, j) + i += 1 + j -= 1 + +else: + for k in range(M//2+1): + print(i, j) + i += 1 + j -= 1 + j -= 1 + for k in range(M//2): + print(i, j) + i += 1 + j -= 1" +p02732,s926651033,Accepted,"from collections import Counter +# from scipy.special import comb +from scipy.misc import comb +n = int(input()) +a = [int(x) for x in input().split()] +aa = Counter(a) +cnt = [] +for i in range(1, n + 1): + cnt.append(comb(aa[i], 2, exact=True)) +s = sum(cnt) +for i in range(n): + print(s - comb(aa[a[i]], 2, exact=True) + comb(aa[a[i]] - 1, 2, exact=True))" +p03289,s853570166,Accepted,"S = input() + +flag = 1 +c_count = 0 +if S[0] == 'A': + for i in range(1,len(S)): + if 2 <= i <= len(S)-2: + if S[i] == 'C': + c_count += 1 + else: + if S[i].islower() == False: + flag = 0 +else: + flag = 0 +if c_count == 1 and flag == 1: + print('AC') +else: + print('WA')" +p02657,s377794965,Wrong Answer,"a,b=map(float,input().split()) +ans=a*100+b*100 +print(int(ans//100)) +" +p03997,s835462619,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) +print(int(1/2*(a+b)*h))" +p02700,s561102242,Accepted,"A, B, C, D = map(int,input().split()) +print(""Yes"" if (A-1) // D >= (C-1) // B else ""No"") " +p03386,s685681727,Accepted,"def main(): + a,b,k = map(int, input().split()) + + array = range(a,b+1) + ans = list(set(array[:k]) | set(array[-k:])) + ans.sort() + for val in ans: + print(val) + + +if __name__ == '__main__': + main() +" +p03471,s382038665,Accepted,"n,y=map(int,input().split()) + +res=(-1,-1,-1) + +for i in range(n+1): + for j in range(n-i+1): + k = 10000*i + 5000*j + 1000*(n-i-j) + if k==y: + res=(i,j,n-i-j) + break +print(*res)" +p02771,s178192381,Wrong Answer,"a, b, c = map(int, input().split()) + +if (a == b and a == c) or (a != b and a != c): + print(""No"") +else: + print(""Yes"") + " +p03627,s398768625,Accepted,"import collections + +n = int(input()) +lens = list(map(int,input().split())) +lens = collections.Counter(lens) +lens = sorted(lens.items(), key=lambda x:x[0], reverse = True) +cnt = 0 +for j in lens: + if j[1] >= 4 and cnt == 0: + print(j[0]**2) + break + elif j[1] >= 2 and cnt == 0: + cnt = j[0] + elif j[1] >= 2 and cnt != 0: + print(cnt * j[0]) + break +else: + print(0)" +p02729,s064541534,Accepted,"n,m = [int(i) for i in input().split()] +p = ['P']*n +k = ['I']*m +al = p+k +ans = 0 +for i in range(len(al)): + for j in range(i+1,len(al)): + if al[i] == 'I' and al[j]=='I':ans+=1 + if al[i] == 'P' and al[j] == 'P': ans+=1 +print(ans) +" +p02909,s390445511,Accepted,"l=(""Sunny"", ""Cloudy"", ""Rainy"", ""Sunny"") +print(l[l.index(input())+1])" +p03695,s258527117,Accepted,"import collections + +N = int(input()) +A = list(map(int, input().split())) + +B = [] +cnt = 0 +for i in range(N): + if A[i] >= 3200: + cnt += 1 + else: + B.append(A[i]//400) + +c = collections.Counter(B) + +small = len(c) if len(c) != 0 else 1 +big = len(c)+cnt + +print(small, big)" +p03633,s379849233,Accepted,"import math + +num = 1 +for i in range(int(input())): + a = int(input()) + cnt = math.gcd(a, num) + num = (a * num) // cnt +print(num)" +p03136,s617822509,Wrong Answer,"n=int(input()) +l=list(map(int,input().split())) + +if max(l)*2 >sum(l): + print(""No"") + exit() +print(""Yes"")" +p03524,s167797805,Accepted,"s=list(input()) + +a=s.count(""a"") +b=s.count(""b"") +c=len(s)-a-b + +M=max(a, b, c)-min(a, b, c) + +if M<=1: + print(""YES"") +else: + print(""NO"")" +p03289,s072806137,Accepted,"s = input() +ans = True +if s[0]!='A': + ans = False +if s[2:-1].count('C')!=1: + ans = False +upper = 0 +for i in s: + if i.isupper(): + upper += 1 + +if upper != 2: + ans = False + +if ans: + print('AC') +else: + print('WA') +" +p03252,s047407006,Accepted,"S,T = input(),input() + +d = [None]*26 +flag = True +for s,t in zip(S,T): + s = ord(s)-ord('a') + t = ord(t)-ord('a') + if d[s] is None: + d[s] = t + elif d[s] != t: + flag = False + break + +if not flag: + print('No') +elif len(set(v for v in d if v is not None)) != sum(int(v is not None) for v in d): + print('No') +else: + print('Yes')" +p03478,s584403439,Accepted,"N, A, B = map(int,input().split()) + +result = 0 +for n in range(1,N+1): + sm = 0 + for i in range(len(str(n))): + sm += int(str(n)[i]) + if A<=sm<=B: + result += n + +print(result)" +p02786,s699094916,Accepted,"from math import log2 +h = int(input()) +print((1 << int((log2(2 * h + 1)))) - 1)" +p03434,s693321311,Accepted,"N = int(input()) +lst = list(map(int, input().split())) +alice = [] +bob = [] +lst.sort(reverse=True) +for i in range(N): + if i%2 == 0: + alice.append(lst[i]) + else: + bob.append(lst[i]) + +dif = sum(alice) - sum(bob) +print(dif)" +p02963,s337684715,Accepted,"n=int(input()) +a = n//(10**9)+1 +b = 10**9-(n%(10**9)) +if n%(10**9) == 0: + print(0,0,10**9,0,1,a-1) +else: + print(0,0,10**9,b,1,a)" +p03479,s332601034,Accepted,"x,y=map(int,input().split()) +ans=0 +while x<=y: + ans+=1 + x*=2 +print(ans)" +p03548,s871550616,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +x, y, z = map(int, readline().split()) +q = x // (y + z) +r = x % (y + z) +ans = q if z <= r else q - 1 +print(ans)" +p02787,s896696991,Accepted,"h,n = map(int, input().split( )) +m = [] +mxa = 0 +for _ in range(n): + ai,bi = map(int, input().split( )) + m.append((ai,bi)) + mxa = max(mxa,ai) +inf = 10**10 +dp = [inf for _ in range(h+1+mxa)] +dp[0] = 0 +for i in range(h+mxa): + for j in range(n): + if i+m[j][0]<=h+mxa: + dp[i+m[j][0]] = min(dp[i+m[j][0]],dp[i]+m[j][1]) +print(min(dp[h:])) +" +p02760,s444727805,Accepted,"a = [] +for _ in range(3): + a += [int(i) for i in input().split()] + +n = int(input()) + +ans = [] +for _ in range(3): + ans += [0]*3 + +for _ in range(n): + b = int(input()) + if b in a: + ans[a.index(b)] = 1 + +f = False +for i in range(3): + if sum(ans[3*i:3*i+3]) == 3: + f = True + +for i in range(3): + if sum(ans[i::3]) == 3: + f = True + +if (ans[0] + ans[4] + ans[8]) == 3: + f = True +if (ans[2] + ans[4] + ans[6]) == 3: + f = True + +if f: + print('Yes') +else: + print('No') + + +" +p02829,s753799502,Accepted,"a = int(input()) +b = int(input()) +print(6-(a+b))" +p02647,s307905669,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +for _ in range(min(k, 100)): + new_a = [0]*n + for i in range(n): + d = a[i] + new_a[max(i-d, 0)] += 1 + if i+d+1 <= n-1: + new_a[i+d+1] -= 1 + for i in range(n-1): + new_a[i+1] += new_a[i] + + a = new_a + +print(*a) +" +p02988,s879191454,Accepted,"n=int(input()) +p=list(map(int,input().split())) +ans=0 +for i in range(1,n-1): + if p[i-1]0: + ans.append(b) + else: + a=abs(a) + ans.append(a+b+min(a,b)) + i+=1 +print(min(ans))" +p02726,s740546048,Accepted,"n,x,y = map(int, input().split()) +t = [0 for i in range(n)] +x = x-1 +y = y-1 +for i in range(0,n): + for j in range(i,n): + a = abs(i-x)+abs(j-y)+1 + b = abs(i-j) + if a < b: + t[a-1] += 1 + else: + t[b-1] += 1 + +for k in range(0,n-1): + print(int(t[k]))" +p03161,s495641823,Wrong Answer,"n,k = list(map(int,input().split(' '))) +h = list(map(int, input().split(' '))) + +dp = [0]*n + +for i in range(1,n): + temp = 1000000 + for j in range(1,k+1): + if i-j>=0: + temp = min(dp[i-j]+abs(h[i]-h[i-j]), temp) + + dp[i] = temp + +print(dp[-1])" +p03774,s818840495,Wrong Answer,"n,m=map(int,input().split()) +a=[list(map(int,input().split())) for a in range(n)] +c=[list(map(int,input().split())) for b in range(m)] +dist=0 +minnum=0 +for indi,i in enumerate(a): + min=10*10 + minnum=0 + for indj,j in enumerate(c): + dist=0 + dist+=abs(i[0]-j[0]) + dist+=abs(i[1]-j[1]) + #print(""dist={}"".format(dist)) + if min>dist: + min=dist + minnum=indj + print(minnum+1)" +p03705,s235008944,Accepted,"N,a,b=map(int, input().split()) +if a>b: + print(0) +elif an : + sm-=n + work*=10 + work%=n + +else : print(-1)" +p02657,s018899845,Accepted,"a, b = map(int, input().split()) + +print(a*b)" +p02982,s638198107,Accepted,"N,D=map(int,input().split()) +X=[list(map(int,input().split())) for _ in range(N)] +ans=0 +for i in range(N): + for j in range(i+1,N): + d=0 + for k in range(D): + d+=(X[i][k]-X[j][k])**2 + for l in range(1000): + if l**2==d: + ans+=1 + break +print(ans) +" +p03013,s909523698,Accepted,"N,M = map(int,input().split()) + +def fib(n): + if n == 0: + return 0 + one = 1 + two = 1 + for _ in range(n-2): + two,one = one + two,two + return two + +ans,now = 1,0 +for i in range(M): + a = int(input()) + ans *= fib(a - now) + now = a+1 + if ans > 10**9+7: + ans %= 10**9 + 7 +ans *= fib(N - now + 1) +ans %= 10**9 + 7 + +print(ans)" +p03145,s316007658,Accepted,"X , Y, Z =map(int,input().split()) +print(X*Y//2)" +p03371,s389306980,Accepted,"a, b, c, x, y = (int(x) for x in input().split()) +ans = 10**18 +ans = min(ans, a * x + b * y) +z = min(x, y) +ans = min(ans, 2 * c * z + a * (x - z) + b * (y - z)) +ans = min(ans, 2 * c * max(x, y)) +print(ans) +" +p02578,s057533864,Accepted,"N = int(input()) +As = list(map(int, input().split())) + +sum_humidai = 0 +max_front_person = 0 + +for person_idx, person_height in enumerate(As): + + if person_idx == 0: + continue + + max_front_person = max(max_front_person, As[person_idx - 1]) + if max_front_person > person_height: + humidai = max_front_person - person_height + sum_humidai += humidai + +print(sum_humidai)" +p03038,s918662790,Accepted,"n, m = list(map(int, input().split())) +a = list(map(int, input().split())) +c = [[] for _ in range(m)] +for i in range(m): + c[i] = list(map(int, input().split())) +a.sort() +c.sort(key=lambda x: x[1], reverse=True) +ans = sum(a) +sa = 0 +cnt = 0 +r = c[0][0] +for i, v in enumerate(a): + if r <= i and cnt <= m - 2: + cnt += 1 + r += c[cnt][0] + if r > i and v < c[cnt][1]: + ans += abs(c[cnt][1] - v) + else: + break +print(ans) +" +p02772,s782176604,Wrong Answer,"n = int(input()) +list = map(int,input().split()) + +list2=[] +for i in list: + if i%2==0: + list2.append(i) + +if list2: + if all(i%3==0 or i%5==0 for i in list2): + print('APPROVED') + else: + print('DENIED') +else: + print('DENIED') + + + + +" +p03719,s156004016,Accepted,"a,b,c=map(int,input().split()) +print(""Yes""if a<=c<=b else""No"")" +p03293,s582224660,Accepted,"s=input() +t=input() +for i in range(1,len(s)+1): + if t==s[-i:]+s[:-i]: + print('Yes') + exit() +print('No')" +p02582,s262268578,Accepted,"s=input() +count=0 +count1=0 +for i in s: + if i=='R': + count+=1 + if count1 4 * a * b and check > 0: + ans = 'Yes' +else: + ans = 'No' +print(ans) +" +p02570,s886689146,Accepted,"D,T,S=map(int,input().split()) +if D/S<=T : + print(""Yes"") +else : + print(""No"")" +p03067,s349028820,Accepted,"a, b, c = map(int, input().split()) +if asum(a[:i+1]): + i+=1 +i-=1 +print(abs(2*sum(a[:i+1])-sm))" +p02797,s206525709,Accepted,"n,k,s = map(int,input().split()) + +PAD = 10**9 +ans = [] +if s==PAD: + PAD = 1 +for i in range(k): + ans.append(s) +for i in range(n-k): + ans.append(PAD) + +print(*ans) " +p02953,s483958286,Accepted,"N=int(input()) +H=list(map(int,input().split())) +base=0 +for h in H: + if base>h: + print(""No"") + break + base=max(base,h-1) +else: + print(""Yes"")" +p03324,s097849724,Accepted,"D,N=map(int,input().split()) +A=100**D +ans=N*A +if N==100: + ans=101*A +print(ans)" +p03986,s381152076,Accepted,"import itertools +s = input() +ans = len(s) +a = 0 +for key,group in itertools.groupby(s): + b = len(list(group)) + if key==""S"": + a += b + elif key==""T"": + if a<=b: + ans -= a*2 + a = 0 + else: + ans -= b*2 + a = a-b +print(ans)" +p02690,s739294024,Wrong Answer,"import math +x = int(input()) +for i in range(0, x): + b = int(i**5 - x) + if b > 0: + b = b**0.2 + else: + b = -((-b)**0.2) + try: + if b % 1 == 0: + print(i, int(b)) + break + except: + pass" +p03994,s173043396,Wrong Answer,"s = str(input()) +n = int(input()) +k = ord(""z"") +a = [0]*len(s) +for i in range(len(s)): + a[i] = ord(s[i]) +for i in range(len(s)): + if n>=k+1-a[i]: + n = n-k-1+a[i] + a[i] = ord(""a"") + + if n<=0: + break +if n>0: + a[-1] += n%26 +ans = """" +for i in range(len(s)): + ans += chr(a[i]) +print(ans) +" +p02693,s218176140,Accepted,"k = int(input()) +a, b = map(int, input().split()) +p = a % k +q = k - p +if (p == 0) or ((a + q) <= b): + print('OK') +else: + print('NG') +" +p02773,s653868280,Wrong Answer,"import collections +import numpy as np +n = int(input()) +S = [[0] * 2 * 10 * 5] * n +l = [] + +for i in range(n): + S[i] = input() + +c = collections.Counter(S) +tmp = c[max(c)] + +for k,v in c.items(): + if tmp != v: + break + tmp = v + l.append(k) + +l = sorted(l) +for i in l: + print(i)" +p03854,s521492244,Wrong Answer,"init = input() + +words = [ + 'dream', + 'dreamer', + 'erase', + 'eraser' +] + +def reverseWord(str): + return str[::-1] + +def elimTheWord(str): + for word in reversed_words: + if str.find(word) == 0: + str = str[len(word):] + return str + +reversed_words = list(map(reverseWord, words)) + +# main +target = reverseWord(init) + +while True: + pivot = elimTheWord(target) + if pivot == '': + print('Yes') + break + if pivot == target: + print('No') + break + target = pivot" +p02760,s122240284,Accepted,"A = [ [int(x) for x in input().split()] for _ in range(3) ] +N = int(input()) +B = set([ int(input()) for _ in range(N) ]) +res = ""No"" +for i in range(3): + c1 = 0 + c2 = 0 + for j in range(3): + c1 += 1 if A[i][j] in B else 0 + c2 += 1 if A[j][i] in B else 0 + if c1==3 or c2==3: + res = ""Yes"" +if sum([ 1 if A[j][j] in B else 0 for j in range(3) ]) == 3: + res = ""Yes"" +if sum([ 1 if A[j][2-j] in B else 0 for j in range(3) ]) == 3: + res = ""Yes"" +print(res)" +p02624,s899397926,Accepted,"def readinput(): + n=int(input()) + return n + +def main(n): + fk=[1]*(n+1) + for i in range(2,n+1): + j=i + while(j<=n): + fk[j]+=1 + j+=i + sum=0 + for i in range(1,n+1): + sum+=i*fk[i] + return sum + +if __name__=='__main__': + n=readinput() + ans=main(n) + print(ans) +" +p02663,s026150852,Accepted,"h1,m1,h2,m2,k=map(int,input().split()) +t=0 +if m2>m1: + t=m2-m1+(h2-h1)*60-k +else: + t=60+m2-m1+(h2-1-h1)*60-k +print(t) +" +p03043,s431128860,Accepted,"import math + +N, K = [int(x) for x in input().split()] + +S = 0 +for i in range(1, N + 1): + a = 0 + while i < K: + a += 1 + i *= 2 + S += 0.5 ** a + +ans = S / N +print(ans)" +p02912,s459385254,Accepted,"import heapq + +def main(): + N, M = map(int, input().split()) + A = list(map(int, input().split())) + A = list(map(lambda x: x*(-1), A)) + heapq.heapify(A) + ans = 0 + while M > 0: + heapq.heappush(A, (heapq.heappop(A)*-1) // 2 * -1) + M -= 1 + for i in range(N): + ans += -A[i] + print(ans) + +if __name__ == '__main__': + main()" +p02730,s444270950,Wrong Answer,"import math +S=input() +N=len(S) +S1=S[0:math.floor((N-1)/2)] +S2=S[math.floor((N+3)/2)-1:N] +if S1==S1[::-1]: + if S2==S2[::-1]: + print('Yes') + else: + print('No') +else: + print('No')" +p03951,s663746696,Accepted,"def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) +def ism():return map(str,input().split()) +def isl():return list(map(str,input().split())) + +n = ii() +s = list(input()) +t = list(input()) + +for i in range(n): + if s[i:] == t[:n-i]: + print(n+i) + exit() + + +print(2*n)" +p02684,s894232751,Accepted,"n,k = map(int,input().split()) +a_list = list(map(int,input().split())) + +used_dict = {} +used_list = [] + +current_node = 0 + +while True: + if current_node not in used_dict: + used_dict[current_node] = True + used_list.append(current_node) + current_node = a_list[current_node]-1 + else: + break + +repeat_index = used_list.index(current_node) +repeat_list = used_list[repeat_index:] +repeat_length = len(used_list) - repeat_index + +if k > repeat_index: + amari = (k-repeat_index) % repeat_length + print(repeat_list[amari]+1) +else: + print(used_list[k]+1) +" +p03386,s182346850,Wrong Answer,"import math +def main(): + a,b,k = list(map(int,input().split())) + for i in range(a,b+1): + if (i < a+k) or(b-k+1 < i): + print(i) + +main() +" +p02987,s789218954,Accepted,"S=input() +s=list(set(S)) +print(""Yes"" if len(s)==2 and S.count(s[0])==S.count(s[1])==2 else ""No"")" +p02601,s114264850,Wrong Answer,"a, b, c = map(int, input().split()) +k = int(input()) +c = c*2 +if k > 1: + for i in range(1,k): + if b < c: + b = b*2 + elif b > c: + c = c*2 +if a < b and b < c: + print('Yes') +else: + print('No')" +p03612,s485077062,Accepted,"n = int(input()) +p = [int(x) for x in input().split()] + +ans = 0 +for i in range(n-1): + if p[i] == i+1: + p[i], p[i+1] = p[i+1],p[i] + ans += 1 +if p[n-1] == n: + ans += 1 + +print(ans)" +p03681,s491600625,Accepted,"import math +n,m=map(int,input().split());r=10**9+7 +if n==m: print(2*math.factorial(n)*math.factorial(m)%r) +elif abs(n-m)==1: print(math.factorial(n)*math.factorial(m)%r) +else: print(0)" +p02947,s313648029,Wrong Answer,"import math +n = int(input()) +l = ["""".join(sorted(input())) for i in range(n)] +l.sort() +c = 0 +b = l[0] +ans = 0 +for s in l[1:]: + if s == b: + c += 1 + else: + ans += c * (c + 1) * 0.5 + c = 0 + b = s +print(ans)" +p02939,s400189558,Wrong Answer,"S=list(input()) +S=['_']+S+['_'] +i=0 +count=0 +while iN: + print(""-1"") +else: + print(int(N-sum))" +p02860,s565341801,Accepted,"N = int(input()) +S = input() + +if N % 2 == 0: + if S[: N // 2] == S[N // 2:]: + print(""Yes"") + else: + print(""No"") +else: + print(""No"") +" +p02814,s021502085,Accepted,"from fractions import gcd +n, m = [int(i) for i in input().split()] +a = [int(i)//2 for i in input().split()] + + +def two(x): + i = 0 + while x % 2 == 0: + i += 1 + x //= 2 + return i + + +if two(min(a, key=two)) != two(max(a, key=two)): + print(0) +else: + lcm = 1 + for i in a: + lcm = i * lcm // gcd(i, lcm) + if lcm > m: + print(0) + break + else: + print((m+lcm)//(2*lcm)) +" +p02823,s611891891,Wrong Answer,"N,A,B = map(int,input().split()) +if (B-A)%2==0: + print((B-A)//2) +else: + print(min(N-A,B-1))" +p02847,s479522768,Accepted,"S=input() +if S=='SAT': + print(1) +if S=='MON': + print(6) +if S=='TUE': + print(5) +if S=='WED': + print(4) +if S=='THU': + print(3) +if S=='FRI': + print(2) +if S=='SUN': + print(7)" +p02935,s491150082,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +while len(A)>=2: + X = float((A[0]+A[1])/2) + A.pop(0) + A.pop(0) + A.append(X) + A.sort() +else: + print(*A)" +p03239,s603354318,Accepted,"n, t_th = map(int, input().split()) +c_min = 10000 +for i in range(n): + c, t = map(int, input().split()) + if t <= t_th and c < c_min: + c_min = c +if c_min == 10000: + print('TLE') +else: + print(c_min) +" +p03109,s270679130,Accepted,"s=input() +l=list(map(int,s.split(""/""))) +if l[0] <=2018 or l[0] ==2019 and (l[1]<=3 or l[1] ==4 and l[2]<=30): + print('Heisei') +else: + print(""TBD"")" +p03264,s103310241,Accepted,"def solve(): + k = int(input()) + print((k//2) * ((k+1)//2)) + +if __name__ == '__main__': + solve() +" +p03284,s184771499,Accepted,"def main(): + n,k = map(int,input().split()) + if n % k == 0: + print(0) + else: + print(1) +main()" +p02796,s141408424,Wrong Answer,"n = int(input()) +lis = [] +for _ in range(n): + x, l= list(input().split("" "")) + p_d = int(x) + int(l) + m_d = int(x) - int(l) + lis.append([m_d, p_d]) + +lis.sort() +a = -10 ** 10 +x = 0 + +for b in range(n): + if lis[b][0] >= a: + x += 1 + a = lis[b][1] + +print(x)" +p02646,s892879403,Accepted,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) + +if V <= W: + ans = ""NO"" +else: + if abs(A - B) / (V - W) <= T: + ans = ""YES"" + else: + ans = ""NO"" +print(ans) +" +p03767,s984527490,Accepted,"N = int(input()) +a = list(map(int,input().split())) +print(sum(sorted(a)[N::2]))" +p03705,s927912194,Accepted,"N, A, B = map(int, input().split()) + +if (N == 1 and A != B) or (B < A): + print(0) +else: + print((B - A) * (N - 2) + 1) +" +p03345,s534405793,Wrong Answer,"A, B, C, K = map(int, input().split()) + +m = A - B + +if (K % 2 == 0): + print(m) +else: + if (abs(m) > 10**18): + print('Unfair') + print(abs(m)) +" +p03485,s782170461,Accepted,"import math +n=list(map(int,input().split())) +print(math.ceil(sum(n)/len(n)))" +p02695,s547990449,Wrong Answer,"a, b, n = list(map(lambda x: int(x), input().split(' '))) + +print((a * (n - 1)) // b - a * ((n - 1) // b))" +p02833,s689967113,Accepted,"n = int(input()) +total = 0 +i = 1 + +while(n//pow(5, i)): + if n%2 == 0: + total += (n // pow(5, i)) // 2 + i += 1 + +print(total) +" +p03720,s388464305,Accepted,"n,m = map(int,input().split()) +l = [] +for i in range(m): + a,b = map(int,input().split()) + l.append(a) + l.append(b) +for i in range(1,n+1): + print(l.count(i)) + " +p03251,s888389123,Accepted,"n, m, x, y = [int(i) for i in input().split()] +x_list = [int(i) for i in input().split()] + [x] +y_list = [int(i) for i in input().split()] + [y] +print(""No War"" if max(x_list) < min(y_list) else ""War"")" +p02755,s248115378,Accepted,"A, B = map(int, input().split()) +done = False +for i in range(1, 1001): + if A == (i *8 // 100) and B == (i * 10 // 100): + print(i) + done = True + break + +if not done: + print(-1)" +p02743,s289100725,Accepted,"import math +a, b, c = map(int,input().split()) + +if c-a-b < 0: + print(""No"") +elif 4*a*b<(c-a-b)*(c-a-b): + print(""Yes"") +else: + print(""No"")" +p03778,s850105569,Accepted,"W,a,b=map(int,input().split()) +l=a+W +r=b+W + +a1=abs(l-b) +a2=abs(r-a) +if b<=l: + if a<=r: + print(0) + exit() +ans=min(a1,a2) +print(ans)" +p03076,s354052805,Wrong Answer,"s = [input() for i in range(5)] +x10 = int(0) +sum = int(0) +a = [] + +for i in range(5): + if int(s[i]) % 10 == 0: + x10 = x10 + 1 + else: + pass + sum = sum + ((int(s[i]) - 1) // 10 + 1) * 10 + a.append(int(s[i]) % 10) + +b = [int(s) for s in a] + +if x10 == 5: + print(sum) +else: + print(sum - 10 + min(b))" +p03827,s713047301,Accepted,"n = int(input()) +s = input() + +x = 0 +ans = 0 +for i in s: + if i == 'I': + x += 1 + ans = max(ans, x) + else: + x -= 1 + +print(ans)" +p03745,s369528798,Accepted,"n = int(input()) +A = list(map(int, input().split())) +count = 1 +direction = 0 +for a, b in zip(A, A[1:]): + dif = b - a + if direction == 0: + if dif > 0: + direction = 1 + elif dif < 0: + direction = -1 + elif (direction == 1 and dif < 0) or (direction == -1 and dif > 0): + count += 1 + direction = 0 +print(count)" +p02689,s402473974,Accepted,"n,m=map(int,input().split()) +h=list(map(int,input().split())) +l=[[] for _ in range(n)] +for _ in range(m): + a,b=map(int,input().split()) + l[a-1].append(b-1) + l[b-1].append(a-1) +ans=0 +for i in range(n): + f=1 + for j in l[i]: + if h[i]<=h[j]: + f=0 + if f: + ans+=1 +print(ans)" +p02813,s098100439,Accepted,"import itertools +import numpy as np +n = int(input()) +p = tuple(map(int, input().split())) +q = tuple(map(int, input().split())) + +num = np.arange(1, n+1) + +zyun = list(itertools.permutations(list(num), n)) + +for i in range(0, len(zyun)): + if zyun[i] == p: + a = i+1 + if zyun[i] == q: + b = i+1 + +print(abs(a-b))" +p02631,s599830529,Accepted,"n = int(input()) +arr = list(map(int, input().split())) + +a = arr[0] + +for i in range(1, n): + a ^= arr[i] + +ans = [] +for i in range(n): + ans.append(a ^ arr[i]) + +print(*ans)" +p02615,s934455507,Wrong Answer,"n = int(input()) +lis = list(map(int, input().split())) + +lis = sorted(lis, reverse=True) + +ans = 0 +for i in range(n-1): + ans += lis[i] + +print(ans)" +p02835,s328340891,Wrong Answer,"if sum(list(map(int,input().split())))>21: + print(""burst"") +else: + print(""win"") +" +p03555,s755238778,Accepted,"x = input() +y = input() +t = '' +for i in range(3): + t = x[i] + t +if t == y: + print('YES') +else: + print('NO')" +p02811,s354402900,Accepted,"k, x = map(int, input().split()) +if 500*k >= x: + print(""Yes"") +else: + print(""No"")" +p03012,s082697536,Wrong Answer,"inp = int(input())-1 +list = list(map(int,input().split())) +def xx(a): + if a<0: + return a*(-1) + else: + return a +def xxx(listing): + cc=0 + for all in listing: + cc=all+cc + return cc +ans = xx(xxx(list[0:1]) - xxx(list[1:inp+1])) +for iterater in range(1,inp): + iterater=iterater+1 + a = xx(xxx(list[0:iterater]) - xxx(list[iterater+1:inp])) + if a <= ans: + ans = a +print(ans)" +p03997,s574316237,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) + +print(int((a+b)*h/2))" +p02665,s423596345,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +bottom = sum(A) + +if A[0] >= 1: + print(-1) + exit() + +ret = 1 +children = 1 + +for i in range(N): + children = children * 2 - A[i+1] + if children <= 0 and i != N-1: + ret = -1 + break + + bottom -= A[i+1] + if children >= bottom: + children = bottom + ret += children + A[i+1] + print(children) + print(bottom) +print(ret) +" +p02813,s487212248,Accepted,"N=int(input()) +P=list(input().split()) +Q=list(input().split()) +P=int(''.join(P)) +Q=int(''.join(Q)) +n=[i for i in range(1,N+1)] +A=[] +def dps(n,A,me): + if len(n)==0: + A.append(me) + return + else: + for i in range(0, len(n)): + t=n.pop(i) + dps(n, A, me*10+t) + n.insert(i, t) +dps(n,A,0) +print(abs(A.index(P)-A.index(Q)))" +p03821,s451659405,Accepted,"n=int(input()) +ab=[list(map(int, input().split())) for _ in range(n)] + +cnt=0 +for i in range(n): + a=ab[n-i-1][0] + b=ab[n-i-1][1] + a+=cnt + amari=a%b + if amari!=0: + cnt+=b-amari +print(cnt)" +p03161,s929637512,Accepted,"n,k = map(int,input().split()) +h = list(map(int,input().split())) +dp = [10**100]*n +dp[0] = 0 +for i in range(1,n): + for j in range(1,k+1): + if i-j >= 0: + dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]) + else: + break +print(dp[-1])" +p02838,s642707353,Wrong Answer,"def mi(): return map(int,input().split()) +def lmi(): return list(map(int,input().split())) +def ii(): return int(input()) +def isp(): return input().split() + +n=ii() +a=lmi() +ans=0 +for i in range(60): + x=0 + for j in range(n): + + if (a[j]>>i)&1: + x+=1 + + num=x*(n-x)*2**i + ans+=num + +print(ans)" +p03434,s981007849,Accepted,"N=int(input()) +a=list(map(int,input().split())) +a.sort(reverse=True) +sumA=0; sumB=0; +for i in range(N) : + if i%2==0 : + sumA+=a[i] + else : + sumB+=a[i] +print(sumA-sumB)" +p02706,s660172756,Wrong Answer,"n, m = map(int, input().split()) +aa = list(map(int, input().split())) +print(n - sum(aa))" +p02982,s814268864,Accepted,"N, D = map(int, input().split()) +X = [list(map(int, input().split())) for _ in range(N)] + +import math +ans = 0 +for i in range(N): + X1 = X[i] + for X2 in X[i+1:]: + if math.sqrt(sum([(x1-x2)**2 for x1, x2 in zip(X1, X2)])).is_integer(): + ans += 1 +print(ans)" +p03030,s844954176,Accepted," +n = int(input()) +sp = [[i for i in range(3)] for i in range(n)] + + + +for _ in range(n): + s,ps = map(str,input().split()) + p = ps + sp[_][0] = _ + sp[_][1] = s + sp[_][2] = p + +sp.sort(key=lambda x:(x[1],-int(x[2]))) + +for _ in sp: + print(_[0]+1)" +p03035,s151871966,Accepted,"a,b=map(int,input().split()) +print(0 if a<=5 else b//2 if 6<=a<=12 else b)" +p02732,s494573693,Accepted,"N = int(input()) +A = list(map(str, input().split())) + +import collections as cl +c_A = cl.Counter(A) +sum_c_A=0 +for i in c_A.keys(): + if c_A[i]>1: + sum_c_A += c_A[i]*(c_A[i]-1)/2 + +for j in A: + print(int(sum_c_A-c_A[j]+1))" +p02768,s094415255,Accepted,"n,a,b = map(int, input().split()) +mod = 10 ** 9 + 7 + +def power_func(a,n,p): + bi=str(format(n,""b""))#2進表現に + res=1 + for i in range(len(bi)): + res=(res*res) %p + if bi[i]==""1"": + res=(res*a) %p + return res + +ans = power_func(2, n, mod) - 1 + +comb = [1] * (b + 1) + +for i in range(b): + comb[i + 1] = comb[i] * (n - i) * pow(i + 1,mod - 2, mod) % mod + +ans -= comb[a] + comb[b] +ans %= mod + + +print(ans)" +p02623,s150939286,Accepted,"N, M, K = map(int, input().split()) +A = [int(i) for i in input().split()] +B = [int(i) for i in input().split()] + +a, b = [0], [0] +for i in range(N): + a.append(a[i] + A[i]) + +for i in range(M): + b.append(b[i] + B[i]) + +ans, j = 0, M +for i in range(len(a)): + if a[i] > K: + break + while a[i] + b[j] > K: + j -= 1 + ans = max(ans, i + j) + +print(ans)" +p02628,s666962850,Accepted,"N, K = map(int, input().split()) +P = list(map(int, input().split())) +P.sort() + +ans = 0 + +for i in range(K): + ans += P[i] + +print(ans)" +p03836,s569546450,Accepted,"sx,sy,tx,ty = map(int,input().split()) +x = tx-sx +y = ty-sy +print(""U""*y+""R""*x+""D""*y+""L""*(x+1)+""U""*(y+1)+""R""*(x+1)+""D""+""R""+""D""*(y+1)+""L""*(x+1)+""U"")" +p02683,s014140272,Accepted,"n,m,x=map(int,input().split()) +arr=[list(map(int,input().split())) for _ in range(n)] +ans=10**18 +for i in range(2**n): + flag=format(i,'b') + flag='0'*(n-len(flag))+flag + tmp=0 + check=[0]*(m) + for j in range(n): + if flag[j]=='0': + continue + tmp+=arr[j][0] + for k in range(m): + check[k]+=arr[j][k+1] + for j in range(m): + if check[j]= N: break +for i in range(1,k+1): + if i==d-N: continue + print(i)" +p04005,s028985971,Accepted,"# AGC004a +def main(): + import sys + input = sys.stdin.readline + sys.setrecursionlimit(10**6) + a, b, c = map(int, input().split()) + + if a % 2 == 0 or b % 2 == 0 or c % 2 == 0: + print(0) + exit(0) + print(min(a*b, b*c, c*a)) + + +if __name__ == '__main__': + main() +" +p02817,s836578840,Wrong Answer,"a = list(map(str, input().split())) +print(a[1], a[0])" +p02552,s818982657,Accepted,"a = int(input()) +if a == 0: + print(""1"") +elif a == 1: + print(""0"")" +p03778,s780458001,Accepted,"W,a,b=map(int,input().split()) +print(max(0,b-a-W,a-b-W))" +p02696,s876363332,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + a, b, n = list(map(int, readline().split())) + + x = min(b - 1, n) + + ans = int(a*x/b) + + print(ans) + + +if __name__ == '__main__': + main() +" +p03387,s446838086,Accepted,"abc = [int(i) for i in input().split()] +abc.sort() +ab, bc = abc[2] - abc[1], abc[2] - abc[0] +cnt = 0 +if ab % 2 == 0 and bc % 2 == 0: + cnt += ab//2 + cnt += bc//2 +elif ab % 2 != 0 and bc % 2 != 0: + cnt += ab//2 + cnt += bc//2 + 1 +else: + cnt += ab//2 + cnt += bc//2 + 2 +print(cnt)" +p03103,s971326664,Accepted,"n, m = map(int, input().split()) +l = [list(map(int, input().split())) for i in range(n)] +ll = sorted(l) +count = 0 +total = 0 +for i in range(n): + if count < m: + count += ll[i][1] + total += ll[i][0]*ll[i][1] + else: + c = count-m + total -= ll[i-1][0]*c + print(total) + exit() + if i == n-1: + d = m - count + total += ll[i][0]*d + print(total) + exit()" +p02793,s226920969,Accepted,"def gcd(a,b): + if b==0:return a + return gcd(b,a%b) + +def Lcm(a,b): + return (a*b)//gcd(a,b) + +def dp(): + n=int(input()) + l=list(map(int,input().split())) + lcm=l[0] + for i in range(n): + lcm=Lcm(lcm,l[i]) + ans=0 + mod=1000000007 + for i in range(n): + ans+=lcm//l[i] + print(ans%mod) + +if __name__ == ""__main__"": + dp()" +p02622,s921491546,Wrong Answer,"def MinorChange(): + + str1 = str(input()) + str2 = str(input()) + + data = [] + + for num in range(len(str1)): + if str1[num] != str2[num]: + data.append(str2[num]) + + print(len(list(set(data)))) + +if __name__ == '__main__': + MinorChange()" +p02702,s580460624,Accepted,"import sys + +input = sys.stdin.readline + +S = input().rstrip() +n = len(S) +l = [0]*2019 +d = 10 + +t = int(S[n-1]) +l[t%2019] += 1 + +l[0] += 1 + +for i in range(n-2, -1, -1): + t += int(S[i])*d%2019 + l[t%2019] += 1 + d *= 10 + d %= 2019 + +ans = 0 + +for i in l: + ans += i*(i-1)//2 + +print(ans)" +p03243,s378059716,Wrong Answer,"N = int(input()) + +res = 0 +for i in range(1,9): + tmp = i * 111 + if tmp >= N: + res = tmp + break +print(res) +" +p02660,s868343233,Accepted,"import sys +input = sys.stdin.readline + +x=int(input()) + +import math +L=int(math.sqrt(x)) + +FACT=dict() + +for i in range(2,L+2): + while x%i==0: + FACT[i]=FACT.get(i,0)+1 + x=x//i + +if x!=1: + FACT[x]=FACT.get(x,0)+1 + +ANS=0 +for f in FACT.values(): + i=1 + while f: + if f>=i: + ANS+=1 + f-=i + i+=1 + else: + break +print(ANS)" +p02702,s602269837,Accepted,"from collections import Counter +S = list(map(int, list(input()))) +MOD = 2019 + +acc_mod = [0] +for i, s in enumerate(S[::-1]): + acc_mod.append((acc_mod[-1] + s * pow(10, i, MOD)) % MOD) + +ans = 0 +for v in Counter(acc_mod).values(): + ans += v * (v - 1) // 2 +print(ans) +" +p02952,s847934816,Wrong Answer,"n = int(input()) +ing_total = 0 +N = n + +while N < 1: + N /= 10 + ing_total += 1 + +total_count = 0 + +for i in range(1,ing_total+1,2): + if ing_total % 2 == 0: + total_count += 10**i - 10**(i-1) + else: + if i == ing_total: + gap = n - (10**(i-1)-1) + total_count += gap + + else: + total_count += 10**i - 10**(i-1) + +print(total_count) + +" +p03387,s507113408,Accepted,"import math +A,B,C = map(int,input().split()) +k = [A,B,C] +k.sort() +k.reverse() +ans = 0 +ans += k[0]-k[1] +now = k[2] +now += ans +if (k[0]-now)%2 == 0: + ans += math.ceil((k[0]-now)/2) + print(ans) +else: + ans += math.ceil((k[0]-now)/2) + ans += 1 + print(ans) +" +p03407,s001638063,Accepted,"a, b, x = map(int, input().split()) + +if a+b >= x: + print(""Yes"") +else: + print(""No"")" +p04005,s612233628,Accepted,"#coding:utf-8 +a,b,c = map(int,input().split()) + +if (a%2==0 or b%2==0 or c%2==0): + print (0) +else: + print (a*b*c//max(a,max(b,c)))" +p04030,s099359468,Accepted,"S = list(input()) +Answer = [] + +for s in S: + if s == 'B' and Answer != []: + del Answer[-1] + elif s == 'B' and Answer == []: + continue + else: + Answer.append(s) + +print(*Answer, sep="""") +" +p02729,s096449463,Accepted,"line = input().split() +n = int(line[0]) +m = int(line[1]) + +# 偶数と偶数の方法の数 +eeCount = n * (n - 1) / 2 + +# 奇数と奇数の方法の数 +ooCount = m * (m - 1) / 2 + +print(int(eeCount + ooCount))" +p04030,s038535142,Accepted,"s = input() + +result = """" +for i in range(len(s)): + if s[i] == ""B"": + result = result[0:len(result) - 1] + else: + result = result + s[i] +print(result)" +p02546,s121971573,Accepted,"S = input().split() +S = S[0] +S = list(S) + +if S[-1] == ""s"": + S.append(""es"") + print(''.join(S)) + +else: + S.append(""s"") + print(''.join(S))" +p02933,s522690734,Accepted,"a = int(input()) +s = str(input()) +if (a >= 3200): + print(s) +else: + print(""red"")" +p03471,s881690393,Wrong Answer,"#!/usr/bin/env python3 + +def main(): + n, y = map(int, input().split()) + + for i in range(n): + for j in range(n): + if n - i - j >= 0 and 10000 * i + 5000 * j + 1000 * (n - i - j) == y: + print(i, j, n - i - j) + exit() + else: + print(""-1 -1 -1"") + + +if __name__ == ""__main__"": + main() +" +p03627,s808378837,Wrong Answer,"from collections import Counter +m1,m2=0,0 +N=int(input()) +A=Counter(list(map(int,input().split()))) +key=sorted(A.keys(),reverse=True) +for i in key: + if A[i]>1 and m1==0: + m1=i + elif m1!=0 and A[i]>1: + print(m1*i) + exit() +print(0)" +p03293,s200933009,Wrong Answer,"S=str(input()) +T=str(input()) +flag=0 +for i in range(len(S)): + if S!=T: + k=str(S[-1]) + S=S.strip(k) + S=k+S + else: + flag=1 +print('Yes' if flag==1 else 'No')" +p02779,s821928617,Accepted,"import bisect, collections, copy, heapq, itertools, math, string +import sys +def I(): return int(sys.stdin.readline().rstrip()) +def MI(): return map(int, sys.stdin.readline().rstrip().split()) +def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip().split()) + +from collections import defaultdict +from collections import Counter +import bisect +def main(): + N = I() + A = LI() + c = Counter(A) + if len(c.values()) == N: + print('YES') + else: + print('NO') +if __name__ == ""__main__"": + main() + +" +p02777,s888452673,Accepted,"s,t=input().split() +a,b=map(int,input().split()) +u=input() +ans=0 +if u in s: + a-=1 +if u in t: + b-=1 +print(a,b)" +p02582,s569175574,Accepted,"x = max(map(len,input().split(""S""))) +print(x) +" +p03285,s612894851,Accepted,"n = int(input()) +for i in range(15): + for j in range(26): + if i * 7 + j * 4 == n: + print('Yes') + exit() +print('No')" +p03239,s951148808,Wrong Answer,"n, t = map(int, input().split()) +c, tx = [0]*n, [0]*n +a = 1000 +for i in range(n): + c[i], tx[i] = map(int, input().split()) + if tx[i] <= t and a > c[i]: + a = c[i] +if a == 1000: + print('TLE') +else: + print(a)" +p03543,s706139403,Accepted,"N = list(input()) + +if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: + print(""Yes"") +else: + print(""No"") +" +p02817,s748344047,Accepted,"S = input().split() +print(S[1]+S[0])" +p02706,s869002769,Accepted,"N, M = [int(x) for x in input().split()] +A = [int(a) for a in input().split()] +tmp = N - sum(A) +if tmp >= 0: + print(tmp) +else: + print(-1)" +p03986,s747518556,Accepted,"s=input() +n,ans,l=len(s),len(s),0 +for c in s: + if c=='S': + l += 1 + elif l: + l -= 1 + ans -= 2 +print(ans) +" +p03282,s508637783,Accepted,"s = input() +k = int(input()) + +if ""1"" not in s[:k]: + print (s[0]) + exit() +first = ""1"" +t = 0 +for i in range(len(s)): + if s[i] != ""1"": + first = s[i] + break + else: + t += 1 +if k <= t: + print (""1"") +else: + print (first)" +p02548,s589955615,Wrong Answer,"n = int(input()) +ans = 0 + +for i in range(2,n,1): + if n % i != 0: + ans += 1 + +ans = ans*2 + 1 + + +print(ans)" +p02971,s535974692,Accepted,"N = int(input().rstrip()) +A = [] +mx1 = 0 +mx2 = 0 +for i in range(N): + A.append(int(input().rstrip())) + if A[i] > mx1: + mx1, mx2 = A[i], mx1 + elif A[i] > mx2: + mx2 = A[i] +for j in range(N): + if A[j] == mx1: + print(mx2) + else: + print(mx1)" +p03543,s633705196,Accepted,"n = list(input()) +if (n[0] == n[1] == n[2]) or (n[1] == n[2] == n[3] ): + print(""Yes"") +else: + print(""No"")" +p03284,s334309702,Wrong Answer,"N, K = map(int,input().split()) +print(N % K) +" +p03011,s785159044,Accepted,"p,q,r=map(int,input().split()) +if p>=q and p>r: + print(q+r) +if q>=r and q>p: + print(p+r) +if r>=p and r>q: + print(q+p) +if r==p and p==q: + print(q+p)" +p02571,s603597482,Wrong Answer,"s = input() +t = input() +n,m = len(s),len(t) +ans = 10**4 +for i in range(n-m): + c = 0 + for j in range(m): + if t[j] != s[i+j]: + c += 1 + ans = min(ans,c) +print(ans)" +p02633,s742411598,Accepted,"t=int(input()) +i=1 +while((i*t)%360!=0): + i+=1 +print(i)" +p02819,s178588666,Accepted,"## C - Next Prime https://atcoder.jp/contests/abc149/tasks/abc149_c> +Number=int(input()) +flg =0 + +if Number ==2: #2だったらflg=1にして終了したい + flg=1 + print(Number) +elif Number%2==0: + Number+=1 + +Odd_Number_List =[i for i in range(3,Number,2)] + +while flg==0: + Amari_List = list(map(lambda x:Number%x,Odd_Number_List)) + if Amari_List.count(0)==0: + flg=1 + print(Number) + + else: + Odd_Number_List.append(Number) + Number+=2 + + +" +p02744,s150859347,Accepted,"#解説AC + +n = int(input()) + +def dfs(s, mx): + if len(s) == n: + print(s) + else: + for i in range(ord('a'), ord(mx)+1): + + dfs(s + chr(i), chr(ord(mx) + 1) if i == ord(mx) else mx) +dfs('', 'a')" +p02847,s603346306,Accepted,"S = input() + +List = ['SUN','SAT','FRI','THU','WED','TUE','MON'] + +a = List.index(S) + +if a == 0: + a = 7 + +print(a)" +p03478,s658718263,Wrong Answer,"temp=input() +n=int(temp.split()[0]) +a=int(temp.split()[1]) +b=int(temp.split()[2]) + +def rel(n): + k1000=n//1000 + k100=n//100 + k10=(n-n//100*100)//10 + k1=n%10 + return k1000+k100+k10+k1 + +result=[] +for x in range(1,n+1): + if b >= rel(x) >= a: + result.append(x) + +print(sum(result))" +p02848,s205909001,Accepted,"n = int(input()) +s = input() +alp = [chr(ord('A') + i) for i in range(26)] +res = '' +for si in s: + index = 0 + for i in range(len(alp)): + if si == alp[i]: + index = i + res += alp[(index + n) % len(alp)] +print(res) +" +p03385,s529377587,Accepted,"s = input() +if s[0] != s[1] and s[1] != s[2] and s[2] != s[0]: + print(""Yes"") +else: + print(""No"")" +p02924,s027222742,Accepted," +N = int(input()) +print(N * (N - 1) // 2) +" +p03126,s090313356,Wrong Answer,"n,m=map(int,input().split()) +s=set(range(m+1)) +for i in range(n):s=s&set(map(int,input().split())) +print(len(s)-1)" +p03001,s078830146,Accepted,"w,h,x,y=map(int,input().split()) +b=0 +if x==w/2 and y==h/2: + b=1 +s=w*h/2 +print(s,b)" +p02578,s088404675,Accepted," +N = int(input()) +As = list(map(int, input().split())) +ans = 0 + +tall = int(As[0]) + +for A in As: + if(tall > A): + ans += tall - A + else: + tall = A + +print(ans)" +p02982,s032701117,Wrong Answer,"# ABC133B + +import numpy as np + +n, d = map(int, input().split()) +x = [0] * n +for i in range(n): + x[i] = list(map(int, input().split())) +x = np.array(x) +count = 0 +for i in range(n-1): + for j in range(i+1, n): + d = np.sqrt(sum((x[i, :] - x[j, :]) ** 2)) + print(i, j, ""** d ="", d) + if d == int(d): + count += 1 +print(count) +" +p02697,s028739141,Wrong Answer,"N,M = map(int,input().split()) +if N%2==1: + N += 1 +for i in range(M): + print(N//2+1-M+i,N//2+M-i)" +p03319,s858169563,Accepted,"n,k = list(map(int, input().split())) +a = list(map(int, input().split())) + +# 最小値付近から攻める +idx = a.index(min(a)) + +ans = 10**12 +for i in range(k): + right = n - idx - 1 - i + left = max(idx - k + 1 + i, 0) + + q1,r1 = divmod(left, k-1) + q2,r2 = divmod(right, k-1) + ans = min(ans, q1 + q2 + min(r1,1) + min(r2,1)) + +print(ans+1)" +p03254,s289840666,Wrong Answer,"N,x = map(int, input().split()) +A = list(map(int, input().split())) + +A.sort() +S = 0 +count = 0 + +for i in range(N): + S += A[i] + +if S < x: + print(N-1) + exit() +else: + for i in range(N): + b = x - A[i] + if b > 0: + count += 1 + x -= A[i] + elif b == 0: + count += 1 + exit() + else: + exit() + print(count)" +p02601,s573042987,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) + +for _ in range(K): + if A >= B: + B *= 2 + else: + C *= 2 + +if A < B < C: + print('Yes') +else: + print('No')" +p03612,s668160581,Accepted,"n = int(input()) +A = list(map(int, input().split())) +cnt = 0 +for i in range(n): + now = A[i] + if now == i + 1: + cnt += 1 + if i + 1 < n: + nex = A[i + 1] + if nex == i + 2: + A[i + 1] = now + continue +print(cnt) +" +p03408,s776530009,Accepted,"N=int(input()) +s=[input()for i in range(N)] +M=int(input()) +t=[input()for i in range(M)] +ans=0 +for i in s:ans=max(ans,s.count(i)-t.count(i)) +print(ans)" +p02578,s476745628,Accepted,"n = int(input()) +a = list(map(int, input().split( ))) +front = 0 +step = 0 +for height in a : + x = 0 + if front > height : + x = front - height + step += x + if front < height: + front = height +print(step) +" +p03449,s166575307,Wrong Answer,"import itertools + +N = int(input()) + +A1 = list(map(int,input().split())) +A2 = list(map(int,input().split())) + +#どこで下の行に移るか +csA1 = list(itertools.accumulate(A1)) +csA2 = list(itertools.accumulate(A2)) + +#print(csA1) +#print(csA2) + +ans = A1[-1] + csA2[-1] +for i in range(N-1): + tmp = csA1[i] + (csA2[-1] - csA2[i]) + A2[i] + ans = max(ans,tmp) +print(ans)" +p03637,s162884823,Wrong Answer,"N=int(input()) +a=list(map(int,input().split())) +l=[0]*N +for i in range(N): + if a[i]%4: + if a[i]%2:l[i]=1 + else:l[i]=2 + else:l[i]=4 +print('Yes'if(l.count(1)+(1 if l.count(2)else 0)+1)//2<=l.count(4)else'No')" +p02711,s541001690,Accepted,"from sys import stdin + +A=input() +if A[0]=='7' or A[1]=='7' or A[2]=='7': + print(""Yes\n"") +else: + print(""No\n"")" +p02847,s917065187,Wrong Answer,"youbi=['MON','TUE','WED','THU','FRI','SAT','SUN'] +s=input() +for i in range(len(youbi)): + if s=='SUN': + print(7) + + elif youbi[i]==s: + print(6-i)" +p04029,s506105797,Wrong Answer,"# 式:y = N*(N+1)/2 + +N = int(input()) # 人数Nを代入 + +candy = N * (N + 1) / 2 + +print(candy) +" +p03360,s995175292,Accepted,"a,b,c=map(int,input().split()) +k=int(input()) +m=max(a,b,c) + +print(a+b+c+(m*2**k)-m)" +p03352,s902307234,Accepted,"X = int(input()) + +output = 1 +for i in range(1,32): + for j in range(2, 10): + p = i ** j + if p > X: + break + if p > output: + output = p +print(output)" +p02848,s166635600,Wrong Answer,"import sys +import os + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + N = int(sys.stdin.buffer.readline()) + S = sys.stdin.buffer.readline().decode() + + ret = [] + for s in S: + n = ord(s) + N + if n > 90: + ret.append(chr(n - 26)) + else: + ret.append(chr(n)) + + print("""".join(ret)) + + +if __name__ == '__main__': + main() +" +p03910,s437905322,Accepted,"import math + +n = int(input()) +max_num = int(-(-(math.sqrt(1 + 8*n) - 1) // 2)) + +s = int(max_num * (1 + max_num) / 2) + +d = s - n + +for i in range(max_num): + if i+1 != d: + print(i+1)" +p02756,s150325135,Accepted,"from collections import deque +S = deque() +tmp = input() +for i in range(len(tmp)): + S.append(tmp[i]) +Q = int(input()) +flag = True +for i in range(Q): + string = input().split() + if string[0] == '1': + flag = not flag + elif flag ^ (string[1] == '1'): + S.append(string[2]) + else: + S.appendleft(string[2]) +if not flag: + S.reverse() +for s in S: + print(s, end='')" +p03817,s717058670,Accepted,"x=int(input()) +s=(x//11)*2 +a=x%11 +if a>0: + s+=1 +if a>6: + s+=1 +print(s)" +p03210,s036729310,Accepted,"N = int(input()) +if N == 3 or N==5 or N==7: + print('YES') +else: + print('NO')" +p02657,s571989810,Accepted,"n,m=map(int,input().split()) +print(n*m)" +p03345,s674008551,Accepted,"a, b, c, k = map(int,input().split()) + +s = abs(a - b) + +if len(str(s)) >= 19: + print('Unfair') +else: + if k % 2 != 0: + print(-a + b) + else: + print(a - b)" +p02627,s571939953,Wrong Answer,"a=input() +if str.isupper(a)==True: + print(""A"") +else: + print(""b"") +" +p03633,s963289020,Wrong Answer,"import math +n = int(input()) +t = [int(input()) for _ in range(n)] +if n == 1: + print(0) + exit() +a = t[0]*t[1]//math.gcd(t[0],t[1]) +for i in range(2, n): + a = t[i]*a//math.gcd(t[i],a) +print(a)" +p02642,s672901126,Wrong Answer,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +n = int(readline()) +a = list(map(int,readline().split())) +a.sort() +if a[0] == a[-1]: + print(0) + exit() + +s = set() +ans = 0 +s.add(a[0]) +for i in a[1:]: + p = True + for j in s: + if i%j == 0: + ans += 1 + p = False + break + if p: + s.add(j) + +print(ans)" +p03131,s024846648,Accepted,"K, A, B = map(int, input().split()) +if B - A <= 2: + print(K + 1) + exit() +count = K - A + 1 +ans = A + (count // 2) * (B - A) + count % 2 +print(ans) +" +p03555,s232214360,Accepted,"import math +b=input() +c=[] +for i in range(len(b)): + c.append(b[i]) +#a = list(map(int,input().split())) +#b = list(map(int,input().split())) +#s=int(input()) + +f=input() +t=[] +for i in range(len(f)): + t.append(f[i]) +d=[] +for i in range(len(c)): + d.append(c[-(i+1)]) + +if d==t: + print(""YES"") +else: + print(""NO"")" +p03387,s885203455,Wrong Answer,"*A,=sorted(map(int,input().split())) +print((A[2]-A[1])+int(-~(A[1]-A[0])/2) if (A[1]-A[0])%2==0 else A[1]+A[2]-2*A[0])" +p03013,s698482827,Accepted,"n, m = map(int, input().split()) +step = [True] * n +r = [0,1] +MOD = 10**9 + 7 +for _ in range(m): + broken = int(input()) + step[broken - 1] = False +for i, tf in enumerate(step): + if tf: + r += [(r[i] + r[i+1]) % MOD] + else: + r += [0] +print(r[-1])" +p03611,s224998965,Accepted,"from itertools import accumulate +n = int(input()) +a = list(map(int, input().split())) +# 0が混ざってる場合に対応して、1ずつ足しておく +a = [i+1 for i in a] + +# 10**5だと99999がコーナーケースになる +l = [0] * 10 ** 6 +# いもす法 +for i in a: + l[i-1] += 1 + l[i+2] -= 1 + +b = accumulate(l) +print(max(list(b)))" +p04030,s135797716,Accepted,"# https://atcoder.jp/contests/abc043/tasks/abc043_b +s = list(input()) +result = [] +for c in s: + if c == 'B': + if len(result) > 0: + result.pop() + else: + result.append(c) + +print(''.join(result)) +" +p03745,s219578393,Wrong Answer,"#!/usr/bin/env python3 + +# 入力 +n = int(input()) +a = list(map(int, input().split())) + +# 主処理 +result = 1 +isSkip = False +for i in range(1, n-1): + if isSkip: + isSkip = False + continue + center = a[i] + left = a[i-1] + right = a[i+1] + if ((center < left and center < right) or (left < center and right < center)): + result += 1 + isSkip = True + +# 出力 +print(result) +" +p03817,s621187459,Wrong Answer,"#!/usr/bin/env python3 + +x = int(input()) + +tmp = 0 +if x % 11 < 7: + tmp = 1 +else: + tmp = 2 +print(x//11 * 2 + tmp) +" +p02598,s557613750,Accepted,"import math + +n,k = map(int,input().split()) +a = [int(i) for i in input().split()] + +a.sort() +r = a[n-1] +l = 0 + + +def calc(t,x): + return math.ceil(t / x) - 1 + + +while r - l > 1: + mid = (r+l)//2 + count = 0 + for i in a: + count += calc(i,mid) + if count > k: + l = mid + else: + r = mid + +print(r) +" +p02725,s785462592,Wrong Answer,"K, N = map(int, input().split()) +A = list(map(int, input().split())) + +dist = [A[i+1] - A[i] for i in range(N-1)] + +if A[N-1] - A[0] <= K / 2: + res = A[N-1] - A[0] +else: + res = K - max(dist) + +print(res) +" +p03680,s273944490,Wrong Answer,"N = int(input()) +a = [int(input()) for _ in range(N)] + +l = 1 +p = a[0] - 1 +while l < int(1e5): + l += 1 + if a[p] == 2: + print(l) + break + else: + p = a[p] - 1 +else: + print(-1)" +p02694,s843245282,Wrong Answer,"n=int(input()) +c=1 +x=100 +while x0) or (a>0 and d<0): + ans=max(list1) +else: + list1.append(0) + ans=max(list1) +print(ans)" +p03352,s053393368,Wrong Answer,"import sys +n = int(input()) +for i in range(n,0,-1): + if ((i**(1/2))%1 == 0) or ((i **(1/3))%1 == 0) or ((i **(1/5))%1 == 0) or ((i **(1/7))%1 == 0) or ((i **(1/9))%1 == 0): + print(i) + sys.exit() +print(1) + " +p03730,s855228230,Accepted,"import fractions +a,b,c=map(int,input().split()) +print(""YES"" if c%fractions.gcd(a,b)==0 else ""NO"")" +p03555,s258058187,Accepted,"s=input() +t=input() +if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]: + print(""YES"") +else: + print(""NO"")" +p02603,s699137709,Accepted,"n=int(input()) +A=list(map(int,input().split())) +money=1000 +stock=0 +for i in range(n-1): + if A[i] -*- + +a, b, c = map(int, input().split()) +print('Yes' if a <= c <= b else 'No')" +p03639,s234021831,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +cnt_2 = 0 +cnt_4 = 0 +for a in A: + if a % 4 == 0: + cnt_4 += 1 + elif a % 2 == 0: + cnt_2 += 1 + +cnt_1 = N - cnt_2 - cnt_4 + +if cnt_2 == 0 and cnt_1 <= cnt_4 + 1: + print('Yes') +elif cnt_1 <= cnt_4: + print('Yes') +else: + print('No')" +p02661,s624684760,Accepted,"n = int(input()) +aList = [] +bList = [] +for i in range(n): + a, b = map(int, input().split()) + aList.append(a) + bList.append(b) + +aList.sort() +bList.sort() + +if n % 2 == 0: + middle = n // 2 + print(bList[middle] + bList[middle-1] - aList[middle] - aList[middle-1] + 1) +else: + middle = (n-1) // 2 + print(bList[middle] - aList[middle] + 1) +" +p02700,s325452689,Accepted,"a, b, c, d = map(int, input().split()) + +for i in range(max(a, b, c, d)): + if b >= c: + print('Yes') + exit() + else: + c -= b + if a <= d: + print('No') + exit() + else: + a -= d + continue" +p02818,s279183400,Accepted,"a,b,k=map(int,input().split()) +if a>=k: + print(a-k,b) +elif a+b>=k: + print(0,b-(k-a)) +else: + print(0,0)" +p02583,s051815975,Accepted,"n = int(input()) +l = list(map(int,input().split())) +count = 0 +if n < 3: + pass +else: + for i in range(n-2): + for j in range(i+1,n-1): + for k in range(j+1,n): + a,b,c = l[i],l[j],l[k] + if abs(a-c) B else 'Draw' if A == B else 'Bob') +" +p03944,s987555557,Accepted,"W, H, N = list(map(int, input().split())) +A = [] +for _ in range(N): + A.append(list(map(int, input().split()))) + +xmax, xmin, ymax, ymin = W, 0, H, 0 +for a in A: + if a[2] == 1: + xmin = max(xmin, a[0]) + if a[2] == 2: + xmax = min(xmax, a[0]) + if a[2] == 3: + ymin = max(ymin, a[1]) + if a[2] == 4: + ymax = min(ymax, a[1]) + +S = (xmax-xmin) * (ymax-ymin) +if S < 0 or xmin > xmax or ymin > ymax: + S = 0 +print(S)" +p04011,s309574668,Wrong Answer,"N = int(input()) +K = int(input()) +X = int(input()) +Y = int(input()) + +print(N * X + Y * max(N - K,0))" +p02768,s732404079,Accepted,"n, a, b = map(int, input().split()) +mod = pow(10, 9) + 7 + +def comb(N, x): + numerator = 1 + for i in range(N-x+1, N+1): + numerator = numerator * i % mod + denominator = 1 + for j in range(1, x+1): + denominator = denominator * j % mod + d = pow(denominator, mod-2, mod) + return numerator * d + +a = comb(n, a) +b = comb(n, b) + +print((pow(2, n, mod) -1 -a -b) % mod)" +p03475,s793479702,Wrong Answer,"N = int(input()) + +stations = [tuple(map(int, input().split(' '))) for _ in range(N - 1)] + +for i in range(N - 1): + t = 0 + for j in range(i, N - 1): + c, s, f = stations[j] + t = max(t, s) + t += t % f + t += c + print(t) +print(0) +" +p03210,s699804637,Accepted,"x=int(input()) +if x in [7,5,3]: + print(""YES"") +else: + print(""NO"")" +p04045,s778118972,Accepted,"import sys +input = sys.stdin.readline +from collections import defaultdict + +n,k= map(int, input().split()) +d= list(map(int, input().split())) +d=set(d) + + +for i in range(n,pow(10,5)): + a=set() + v=str(i) + for j in range(len(v)): + a.add(int(v[j])) + + if a.isdisjoint(d): + print(i) + exit()" +p02595,s601501129,Accepted,"n,d=map(int,input().split()) +ans=0 +for i in range(n): + x,y=map(int,input().split()) + if x**2 + y**2 <= d**2: + ans+=1 +print(ans) +" +p02682,s275226610,Accepted,"a, b, c, k = map(int, input().split()) + +xa = min(a, k) +k -= xa +xb = min(b, k) +k -= xb +xc = k +ans = xa - xc + +print(ans)" +p03073,s479323555,Accepted,"s = list(input()) +s1 = [0]*len(s) +s0 = [1]*len(s) +for i in range(1,len(s), 2): + s1[i] += 1 + s0[i] -= 1 +n1 = 0 +n0 = 0 +for i in range(len(s)): + if s1[i] != int(s[i]): + n1 += 1 + elif s0[i] != int(s[i]): + n0 += 1 +print(min(n1, n0))" +p04034,s991660481,Accepted,"import sys +input = sys.stdin.readline + +def main(): + N,M = map(int,input().split()) + + vol = [1 for i in range(N)] + prob = [False for _ in range(N)] + prob[0] = True + + for _ in range(M): + a,b = map(int,input().split()) + if prob[a-1]: + prob[b-1] = True + vol[a-1] -= 1 + vol[b-1] += 1 + if vol[a-1] == 0: + prob[a-1] = False + + print(prob.count(True)) + +if __name__ == ""__main__"": + main() +" +p03437,s012981373,Accepted,"XY = input().split() +X,Y = int(XY[0]), int(XY[1]) +if(X % Y != 0): + print(X) +else: + print(-1)" +p02659,s183262219,Accepted,"a,b=map(int,input().replace('.','').split()) +print(a*b//100)" +p02718,s547677651,Wrong Answer,"n, m = map(int, input().split()) +a = list(map(int, input().split())) +mini = n / (4 * m) +a.sort(reverse = True) +if a[m-1] < mini: + print('No') +else: + print('Yes')" +p03371,s247625129,Wrong Answer," +a,b,c,x,y = map(int,input().split()) +z = 0 +p = 0 + +if a + b < c * 2: + p = a * x + b * y +else: + if x > y: + x -= y + z = y * 2 + y = 0 + if a > c * 2: + z += x * 2 + x = 0 + + else: + y -= x + z = x * 2 + x = 0 + if b > c * 2: + z += 0 + +print(x * a + y * b + z * c) +" +p03803,s996142885,Wrong Answer,"a,b=list(map(int,input().split())) +if a>b: + print(""Alice"") +elif a==b: + print(""Draw"") +else: + print(""Bob"")" +p03836,s674619843,Wrong Answer,"sx, sy, tx, ty = map(int,input().split()) + +dx = (tx - sx) +dy = (ty - sy) + +s = 'U' * dy + 'R' * dx + +s += 'D' * dy + 'L' * dx + +s += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + +s += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + +print(s)" +p02759,s580487441,Accepted,"from math import ceil +n = int(input()) +print(ceil(n/2))" +p02548,s098093618,Accepted,"N = int(input()) + +cnt = 0 +for i in range(1, N): + j = (N - 1)//i + cnt += j + +print(cnt)" +p03607,s710987772,Wrong Answer,"## 20 +n = int(input()) +a = [0 for i in range(10**5)] + +for i in range(n): + num = (int(input())-1)%10**4 + a[num] += 1 + a[num] %= 2 + + +print(a.count(1)) + +" +p03827,s328622390,Accepted,""""""" +N = list(map(int,input().split())) +S = [str(input()) for _ in range(N)] +S = [list(map(int,list(input()))) for _ in range(h)] +print(*S,sep="""") +"""""" + +import sys +sys.setrecursionlimit(10**6) +input = lambda: sys.stdin.readline().rstrip() +inf = float(""inf"") # 無限 + +n = int(input()) +s = input() +count = 0 +max_num = 0 +for _ in s: + if _==""I"": + count+=1 + else: + count-=1 + if max_num str: + return (6 - len(str(num))) * ""0"" + str(num) + + +now_ken = 0 +ans_dict = {} +for p, y in PYsorted: + if p != now_ken: + now_num = 1 + now_ken = p + else: + now_num += 1 + ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num) + +for py in PYlist: + print(ans_dict[py]) +" +p02682,s328669838,Accepted,"a,b,c,k=map(int,input().split()) +if k<=a: + print(k) +elif k<=(a+b): + print(a) +else: + print(a-(k-(a+b)))" +p03001,s945890374,Accepted,"W, H, x, y = map(int, input().split()) +if x == W/2 and y == H/2: + ans = 1 +else: + ans = 0 +print(W * H / 2, ans)" +p02861,s677615524,Accepted,"import math +N = int(input()) +x = [] +y = [] + +for i in range(N): + xi, yi = map(int, input().split("" "")) + x.append(xi) + y.append(yi) + + +route = 0 +for i in range(N): + for j in range(i, N): + route += math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2) + +# print(route * math.factorial(N-1) * 2 / math.factorial(N)) +print(route * 2 / N) +" +p02708,s173561570,Wrong Answer,"n,k=map(int,input().split()) +ans=0 +for i in range(k,n+2): + mi=i*(i-1)//2 + ma=(2*n-i+1)*i//2 + c=(ma-mi+1)%(10**9+7) + ans+=c +print(ans) +" +p02678,s115504281,Accepted,"from collections import deque +n,m = map(int, input().split()) +g = [[] for _ in range(n)] + +for _ in range(m): + a,b = map(int, input().split()) + a,b = a-1, b-1 + g[a].append(b) + g[b].append(a) +stack = deque([0]) +dist = [-1]*n +dist[0] = 0 + +while stack: + v = stack.popleft() + for nv in g[v]: + if dist[nv] == -1: + dist[nv] = v+1 + stack.append(nv) + +print(""Yes"") +print(*dist[1:], sep= ""\n"")" +p03487,s110363605,Wrong Answer,"import collections + +N = int(input()) +a = list(map(int,input().split())) +ans = 0 + +aa = collections.Counter(a).most_common() +print(aa) + +for i,j in aa: + if i > j: + ans += j + if i < j: + ans += j-i + +print(ans)" +p03061,s507763898,Accepted,"import math + +N = int(input()) +A = [int(i) for i in input().split()] + +left = [0] * (N+1) +for i in range(1, N+1): + left[i] = math.gcd(left[i-1], A[i-1]) + +right = [0] * (N+1) +right[N-1] = A[N-1] +for i in range(N-2, -1, -1): + right[i] = math.gcd(right[i+1], A[i]) + +output = 0 +for i in range(N): + output = max(output, math.gcd(left[i], right[i+1])) + +print(output)" +p02760,s077576278,Wrong Answer,"b = [[int(e) for e in input().split()] for _ in range(3)] +N = int(input()) + +for _ in range(N): + x = int(input()) + + for i in range(3): + for j in range(3): + if b[i][j] == x: + b[i][j] = -1 + +ans = False +for i in range(3): + if b[i][:] == [-1] * 3 or b[:][i] == [-1] * 3: + ans = True + +if [b[0][0], b[1][1], b[2][2]] == [-1] * 3 or [b[0][2], b[1][1], b[2][0]] == [-1] * 3: + ans = True + +if ans: + print(""Yes"") +else: + print(""No"") +" +p02793,s475536317,Accepted,"# -*- coding: utf-8 -*- + + +def main(): + from fractions import gcd + + n = int(input()) + a = list(map(int, input().split())) + mod = 10 ** 9 + 7 + lcm = 1 + ans = 0 + + # 同じコードがPython3だとギリギリ通るが、PyPy3だとTLE + for ai in a: + lcm = lcm * ai // gcd(lcm, ai) + + for ai in a: + ans += lcm // ai + + print(ans % mod) + + +if __name__ == '__main__': + main() +" +p03803,s755199859,Wrong Answer,"a, b = map(int,input().split()) + +if a == b: + print(""Draw"") +elif a == 1 and b != 1: + print(""Alice"") +elif a != 1 and b == 1: + print(""Bob"") +elif a < b: + print(""Alice"") +else: + print(""Bob"") + " +p02628,s069118482,Accepted,"import sys +si = sys.stdin.readline + + +def main(): + [n, k] = [int(e) for e in si().split()] + l = [int(e) for e in si().split()] + l.sort() + s = 0 + for i in range(k): + s += l[i] + + print(s) + + +if __name__ == '__main__': + main() +" +p03317,s266772557,Accepted,"N,K = map(int,input().split()) +A = list(map(int,input().split())) +print((N+K-3)//(K-1))" +p03592,s018251039,Accepted,"n,m,k = map(int,input().split()) +ok = False +for i in range(n+1): + for j in range(m+1): + if i*(m-j)+(n-i)*j == k: + ok = True + break +if ok:print('Yes') +else:print('No') +" +p02790,s221508604,Accepted,"A, B = map(int, input().split()) +if A > B: + A, B = B, A +A = str(A) +print(A * B)" +p03543,s309719779,Wrong Answer,"def resolve(): + n = input() + ln = list() + for i in range(10): + ln.append(0) + + for c in n: + num = int(c) + ln[num] += 1 + + ans = """" + for i in range(10): + if ln[i] >= 3: + ans = ""Yes"" + break + if ans == """": + print(""No"") + else: + print(""Yes"") +resolve()" +p03379,s613872588,Accepted,"N = int(input()) +X = list(map(int, input().split())) +Y = sorted(X) +m = Y[(N // 2) - 1] +M = Y[N // 2] +for x in X: + if m >= x: + print(M) + elif M <= x: + print(m) +" +p02608,s382635076,Accepted,"N = int(input()) +cnt = [0] * (10 ** 4 + 1) +for x in range(1, 3333): + for y in range(1, 3333): + for z in range(1, 3333): + check = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x + if check > 10000: + break + else: + cnt[check - 1] += 1 +for i in range(N): + print(cnt[i]) +" +p02647,s533107335,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +# N = 10 ** 5 * 2 +# K = N +# A = [0] * (N+1) + +cnt = 0 +while (A[0] < N or A[-1] < N) and cnt < K: + cnt += 1 + next_A = [0] * (N+1) + for j in range(N): + tmp = A[j] + next_A[max(j-tmp, 0)] += 1 + next_A[min(N, tmp+1+j)] -= 1 + for j in range(N): + next_A[j+1] += next_A[j] + next_A.pop() + A = next_A +print("" "".join([str(i) for i in A])) +" +p02989,s482575131,Wrong Answer,"N=int(input()) +d=[int(s) for s in input().split("" "")] + +d.sort() + +if (N//2)%2==0: + print(0) +else: + K=d[(N//2)]-d[(N//2)-1] + if d[N//2]==d[(N//2)-2]: + K=0 + elif K==0: + K=1 + print(K)" +p04043,s107761167,Accepted,"A = list(map(int, input().split())) + +A.sort() +if A[0] == 5: + if A[1] == 5: + if A[2] == 7: + print(""YES"") + exit() +print(""NO"")" +p02707,s812505121,Wrong Answer,"s = [input() for i in range(2)] +li = list(map(int, s[1].split())) +s0 = int(s[0]) +f1 = 0 +for i in li: + if i == 1: + f1 += i +for j in range(1,s0+1): + if s0-f1*j > 0: + print(f1) + else: + print(0)" +p02820,s398368044,Accepted,"n, k = map(int, input().split()) +R, S, P = map(int, input().split()) +t = input() +point = {'r':P, 's':R, 'p':S} + +ans = 0 +for i in range(k): + j = i + m = 0 + pre_t = 'na' + counted = False + while j < n: + if not (t[j] == pre_t and counted): + ans += point[t[j]] + counted = True + else: + counted = False + pre_t = t[j] + m += 1 + j = i + m * k +print(ans)" +p03971,s176325995,Accepted,"N, A, B = map(int, input().split()) +S = input() +a = 0 +b = 0 +for i in range(N): + if S[i] == ""a"" and a + b < A + B: + print(""Yes"") + a += 1 + elif S[i] == ""b"" and a + b < A + B and b < B: + print(""Yes"") + b += 1 + else: + print(""No"")" +p02677,s674624860,Accepted,"import math +A,B,H,M = map(int,input().split()) +zisin = 360/12 * H + 30/60 * M +hunsin = 360/60 * M +kakusa = min(abs(zisin - hunsin),abs(360-zisin+hunsin))*math.pi/180 +ans_2 = A**2 + B**2 - 2*A*B*math.cos(kakusa) +print(ans_2**0.5)" +p02699,s549895569,Wrong Answer,"while True: + num1,num2 = input().split() + if int(num1) < 1 or int(num1) > 100 or int(num2) < 1 or int(num2) > 100: + break + if int(num1) < int(num2): + print(""safe"") + break + else: + print('unsafe') + break +" +p03210,s371166449,Wrong Answer,"x=int(input()) +if x==7 or 5 or 3: + print(""YES"") +else: + print(""NO"")" +p03206,s955085337,Accepted,"d = int(input()) + +if d == 25: + ans = 'Christmas' +elif d == 24: + ans = 'Christmas Eve' +elif d == 23: + ans = 'Christmas Eve Eve' +else: + ans = 'Christmas Eve Eve Eve' + +print(ans)" +p02917,s728061332,Wrong Answer," +def solve(): + A = [0]*N + A[-1] = 10**6 + A[0] = 10**6 + for i in range(N-2,0,-1): + A[i] = min(A[i+1], B[i-1]) +# print(i) + A[-1] = B[-1] + A[0] = B[0] +# print(A) + print(sum(A)) + +if __name__ == ""__main__"": + N = int(input()) + B = list(map(int, input().split())) + solve() +" +p02555,s827414766,Wrong Answer,"s=int(input()) + +n = s - 5 + +dp = [0] * 2001 + +dp[1]=2 +dp[2]=3 +dp[3]=4 + +for i in range(4, 2001): + dp[i] = dp[i-1] + dp[i-3] + +if s < 3: + print(0) +elif s == 3: + print(1) +elif s == 4: + print(1) +elif s == 5: + print(1) +else: + print(dp[n])" +p02627,s278626922,Accepted,"a = input() +if a.isupper(): + print(""A"") +else: + print(""a"")" +p02714,s883814401,Accepted,"n = int(input()) +s = input() + +r = len([i for i in range(n) if s[i] == ""R""]) +g = len([i for i in range(n) if s[i] == ""G""]) +b = len([i for i in range(n) if s[i] == ""B""]) + +count = 0 +for i in range(n): + for j in range(i + 1, n): + k = 2 * j - i + if k >= n: + break + if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: + count += 1 + +print(r * g * b - count)" +p02718,s633876815,Wrong Answer,"n,m=map(int,input().split()) +c=0 +v=list(map(int,input().split())) +s=sum(v) +v.sort(reverse=True) +val=s/(m*4) +if(v[m-1]>=val): + print(""YES"") +else: + print(""NO"")" +p02918,s943281174,Accepted,"n,k = map(int,input().split()) +s = input() + +score=0 +for i in range(n-1): + if s[i] == s[i+1]: + score+=1 + +ans=min(score+2*k,n-1) +print(ans)" +p03457,s368371223,Accepted,"N = int(input()) +A = [list(map(int,input().split())) for _ in range(N)] +A.insert(0,[0,0,0]) +for i in range(len(A)-1): + dt = A[i+1][0]-A[i][0] + dist = abs(A[i+1][1]-A[i][1])+abs(A[i+1][2]-A[i][2]) + if dist>dt: + print(""No"") + quit() + if dist%2!=dt%2: + print(""No"") + quit() +print(""Yes"")" +p03000,s857988023,Accepted,"# -*- coding: utf-8 -*- + +def main(): + + N, X = map(int, input().split()) + L = list(map(int, input().split())) + + D = 0 + ans = 0 + + if D <= X: + ans += 1 + + for i in L: + D += i + if D <= X: + ans += 1 + + print(ans) + + +if __name__ == ""__main__"": + main()" +p03544,s399181820,Wrong Answer,"n=int(input()) +lo=2 +li=1 +cou=0 +import sys +if n==1: + print(1) +if n==2: + print(3) + sys.exit() + +for i in range(n-1): + + cou=lo+li + lo=li + li=cou + + +print(cou) + + + +" +p02660,s506572199,Wrong Answer,"import math +n = int(input()) + +res = 0 +if n <= 1: + print(res) +else: + max_num = math.ceil(math.sqrt(n + 1)) + org_n = n + used_num_list = [] + for z in range(2, max_num + 1): + if n == 1 or z > math.sqrt(n): + res += 1 + break + if n % z == 0: + res += 1 + n = n // z + if n == z: + break + if n == org_n: + res += 1 + print(res)" +p03478,s550697884,Wrong Answer,"n, a, b = map(int, input().split()) +ans = 0 +for i in range(n+1): + if a <= sum(list(map(int, list(str(i))))) <= b: + ans += 1 +print(ans) +" +p02835,s656950669,Wrong Answer,"a1,a2,a3 = map(int,input().split()) + +sum = a1 + a1 + a3 + +if sum >= 22: + print('bust') +elif sum <= 21: + print('win') +" +p02584,s680374721,Accepted,"X, K, D = list(map(int, input().split())) + +X = abs(X) +count = X // D + +if count >= K: + answer = X - K*D +else: + if (K - count) % 2 == 0: + answer = X - count*D + else: + answer = abs(X - (count+1)*D) + +print(answer)" +p03281,s051586734,Wrong Answer,"n = int(input()) +if n < 105: + print(0) +else: + output = 0 + for i in range(105,n+1): + yaku = 0 + for j in range(1,n+1): + if n % j == 0: + yaku += 1 + if yaku > 8: + continue + if yaku == 8: + output += 1 + print(output)" +p02861,s812978775,Accepted,"import itertools +import math +from statistics import mean + +N = int(input()) +towns = [] +for i in range(N): + xi,yi=map(int,input().split()) + towns.append([xi,yi]) +order=[int(x) for x in range(N)] +root_time=[] +for one_order in itertools.permutations(order): + root_t=0 + for i in range(len(one_order)-1): + root_t += math.sqrt((towns[one_order[i]][0]-towns[one_order[i+1]][0])**2+(towns[one_order[i]][1]-towns[one_order[i+1]][1])**2) + root_time.append(root_t) + +print(mean(root_time))" +p03146,s170384121,Accepted,"S = int(input()) +A = [S] +if (A[0]%2) == 0: + A.append(int(A[0]/2)) +else: + A.append(int(3*A[0]+1)) +i = 1 +while i >0: + if A[i]%2 == 0: + X = int(A[i]/2) + if X in A: + A.append(X) + break + else: + A.append(X) + i += 1 + else: + X = int(3*A[i]+1) + if X in A: + A.append(X) + break + else: + A.append(X) + i += 1 +print(len(A))" +p02802,s701820552,Accepted,"from collections import defaultdict +N, M = map(int, input().split()) +D = defaultdict(int) +acd = set() +ac = 0 +pen = 0 +for i in range(M): + p, S = input().split() + p = int(p) + if S == ""WA"": + D[p] += 1 + else: + if p not in acd: + acd.add(p) + ac += 1 + pen += D[p] +print(ac, pen)" +p02696,s447292065,Accepted,"#coding: utf-8 +A, B, N = map(int, input().split()) +if N >= B: + print((A*(B-1)//B) - A * ((B-1)//B)) +else: + print((A * N) // B - A * (N // B)) +" +p03038,s806354618,Accepted,"n,m = map(int,input().split()) +*a, = map(int,input().split()) +bc =[list(map(int,input().split()))for _ in [0]*m] + +a.sort() +bc.sort(key=lambda x:-x[1]) +i =0 +for b,c in bc: + for j in range(i,min(n,i+b)): + if a[j]< c:a[j]=c + i = i+b +print(sum(a))" +p02982,s317741610,Accepted,"# -*- coding: utf-8 -*- +n, d = map(int,input().split()) +x = [] +for i in range(n): + x.append([int(i) for i in input().split()]) + +ans = 0 +for i in range(n): #iは1個目の点 + for j in range(i + 1, n): #jは2つ目の点 + tmp = 0 + for k in range(d): #dは次元 + tmp += pow(x[i][k] - x[j][k], 2) + #print(tmp) + if pow(tmp, 0.5) % 1 == 0: + ans += 1 +print(ans) +" +p02596,s121269451,Accepted,"import sys +import math +import collections +import decimal +import itertools +from collections import deque +from functools import reduce +import heapq +import copy +k = int(input()) +#n, d = map(int, sys.stdin.readline().split()) +#s = input() +#a = list(map(int, sys.stdin.readline().split())) + +m = 7 +for i in range(1, 10 ** 6): + if m % k == 0: + print(i) + sys.exit() + + m *= 10 + m += 7 + if m > k: + m %= k + +print(-1) + +" +p03137,s221390840,Accepted,"n,m = map(int,input().split()) +x = list(map(int,input().split())) +if n >= m: + print(0) + exit() +x.sort() +y = [x[i+1]-x[i] for i in range(m-1)] +y.sort(reverse = True) +count = x[m-1]-x[0] +count -= sum(y[:n-1]) +print(count)" +p03838,s969573663,Accepted,"x,y = map(int,input().split()) +ans = abs(abs(x)-abs(y)) +if x > 0 and y > 0: + if x > y: + ans += 2 +elif x > 0 and y < 0: + ans += 1 +elif x < 0 and y > 0: + ans += 1 +elif x < 0 and y < 0: + if x > y: + ans += 2 +else: + if x > y: + ans += 1 +print(ans)" +p02727,s146491646,Wrong Answer,"x,y,a,b,c, = map(int,input().split()) +p = list(map(int,input().split())) +q = list(map(int,input().split())) +r = list(map(int,input().split())) +s = p[:x]+q[:y]+r +s.sort(reverse=True) +print(sum(s[:x+y]))" +p03377,s489665399,Accepted,"# | Its_Rashid | # +a , b , x = map(int , input() . split()) +print('YES' if a <= x and a + b >= x else 'NO')" +p02690,s831837216,Accepted,"flag = 0 +X = int(input()) +for A in range(1000): + if flag!=0: + break + for B in range(1000): + if A**5 - B**5 == X: + print(str(A) + "" "" + str(B)) + flag=1 + break + elif A**5 + B**5 == X: + print(str(A) + "" "" + str(-B)) + flag=1 + break" +p02773,s697304526,Wrong Answer,"def main(): + N = int(input()) + S = [] + c = {} + for i in range(N): + S.append(input()) + S = sorted(S) + for i in range(N): + s = S[i] + c[s] = c[s] + 1 if (s in c) else 1 + m = max(list(c.values())) + for s in c.keys(): + if c[s] == m: + print(s) + +if __name__ == ""__main__"": + main()" +p03779,s369068257,Accepted,"x = int(input()) + +for i in range(1, x+1): + wa = int(i*(i+1)/2) + if wa > x: + break + if wa == x: + print(i) + exit() + +print(i)" +p03437,s969879254,Wrong Answer,"x,y = map(int,input().split()) +if y%x == 0: + print(-1) +else: + print(x*2)" +p03281,s660593586,Accepted,"N = int(input()) +ans = 0 +for i in range(1, N+1, 2): + c = 0 + for j in range(1, i+1): + if i % j == 0: + c += 1 + if c == 8: + ans += 1 +print(ans)" +p02603,s931019873,Accepted,"N = input() +N = int(N) +A = list(map(int, input().split())) +# S =[1]*N +stock = 0 #株の数 +money = 1000 #所持金 +for i in range(N): + if i>0: + if A[i-1]=l: + ans.append(int(num)) + else: + ans.append(int(num)) + for i in B: + if abs(int(num[-1])-int(i))<2: + dfs(num+i) +if k<=9: + print(k) +else: + for i in A: + dfs(i) + ans = sorted(ans) + print(ans[k-1])" +p02701,s087238015,Wrong Answer,"import collections + +n = int(input()) +l = [input() for _ in range(n)] + +c = collections.Counter(l) +print(c)" +p03962,s772643544,Accepted,"a,b,c=map(int,raw_input().split()) +if a==b and a!=c or b==c and b!=a or c==a and c!=b: + print ""2"" +elif a==b and b==c: + print ""1"" +else: + print ""3""" +p02629,s324626901,Accepted,"a = ""zabcdefghijklmnopqrstuvwxy"" +number = int(input()) +result = """" +for i in range(13): + result += a[int(number % 26)] + if number % 26 == 0: + number -= 26 + if number // 26 == 0: + break + number = number // 26 +result = result[::-1] +print(result)" +p03352,s899954711,Accepted,"x = int(input()) +kouho = {1} +for i in range(2,32): + p = i**2 + while p <= x: + kouho.add(p) + p *= i +print(max(kouho))" +p02995,s157031330,Wrong Answer,"from fractions import gcd + +a,b,c,d = map(int,input().split()) +count = (b-(b//c+b//d-b//(c*d/gcd(c,d)))) - ((a-1)-((a-1)//c+(a-1)//d-(a-1)//(c*d/gcd(c,d)))) +print(int(count))" +p03438,s722190463,Accepted,"import sys +input = sys.stdin.readline + +N=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) + +cnt =0 +for ai,bi in zip(a,b): + if ai<=bi: + cnt+= (bi-ai)//2 + else: + cnt+= bi-ai + +if cnt>=0: + print('Yes') +else: + print('No') +" +p02900,s228842115,Wrong Answer,"import math +a, b = map(int, input().split()) +li = [] +n = math.floor(math.sqrt(max(a,b))) + +for i in range(1,n+1): + if a%i == 0 and b%i == 0: + li.append(i) + +ans = 0 +n = math.floor(math.sqrt(li[-1])) + +for i in li: + flag = True + for j in range(2, n+1): + if i<=j: + break + else: + if i % j == 0: + flag = False + if flag: + ans += 1 + +print(ans)" +p02699,s159750658,Accepted,"s,w = map(int, input().split()) + +if s <= w: + print('unsafe') +else: + print('safe')" +p02879,s064899889,Accepted,"A,B = map(int,input().split()) +if A < 10 and B < 10: + print(A*B) +else: + print(-1)" +p02779,s234268402,Wrong Answer,"n=int(input()) +num=[int(i) for i in input().split()] + +if len(num)==len(set(num)): + print('Yes') +else: + print('No')" +p03252,s996365574,Accepted,"import collections + + +s = input() +t = input() +s = collections.Counter(s) +t = collections.Counter(t) + +if sorted(s.values()) == sorted(t.values()): + print(""Yes"") +else: + print(""No"")" +p02627,s033788317,Accepted,"s = input() + +if s.islower(): + print(""a"") +else: + print(""A"")" +p03243,s082974926,Accepted,"N = int(input()) + +i=0 +while True: + listN = list(str(N)) + #print(listN) + if listN[0]==listN[1] and listN[1]==listN[2]: + print(N) + break + N+=1" +p03448,s015116250,Accepted,"A = int(input()) +B = int(input()) +C = int(input()) +X = int(input()) +X = X // 50 + +ans = 0 +for ai in range(A+1): + for bi in range(B+1): + for ci in range(C+1): + if 10*ai + 2*bi + ci == X: + ans += 1 + +print(ans) +" +p03555,s973331671,Accepted,"C=input()+input() +print(""YNEOS""[1 in[1 for i in range(3)if C[i]!=C[-i-1]]::2])" +p02785,s178455765,Wrong Answer,"n , k = map(int, input().split()) +hp = input().split() + +sum_hp = 0 + +hp.sort() + +for i in range(k): + if(len(hp)> 0): + hp.pop() + + +for j in hp: + sum_hp = sum_hp + int(j) + +print(str(sum_hp))" +p03037,s478666515,Accepted,"n, m = map(int, input().split()) +l_lst = [] +r_lst = [] +for i in range(m): + l, r = map(int, input().split()) + l_lst.append(l) + r_lst.append(r) +print(max(0, min(r_lst) - max(l_lst) + 1))" +p03206,s786490283,Accepted,"d = int(input()) +if d == 25: + print('Christmas') +elif d == 24: + print('Christmas Eve') +elif d == 23: + print('Christmas Eve Eve') +else: + print('Christmas Eve Eve Eve')" +p03474,s701220657,Accepted,"A, B = map(int, input().split()) +S = input() + +ans = 'Yes' +for i, s in enumerate(S): + if i == A: + if s != '-': + ans = 'No' + break + else: + if s not in '0123456789': + ans = 'No' + break + +print(ans) +" +p02843,s284761599,Accepted,"X=int(input()) +dp=[0]*(X+106) +dp[0]=1 +for i in range(X): + if dp[i]==1: + for j in range(100,106): + dp[i+j]=1 +print(dp[X])" +p02797,s917842767,Accepted,"N,K,S = map(int,input().split()) +ans = [] +if S == 10**9: + for i in range(K): + ans.append(S) + for i in range(N-K): + ans.append(1) +else: + for i in range(K): + ans.append(S) + for i in range(N-K): + ans.append(S+1) +print("" "".join(map(str,ans)))" +p02595,s832051183,Accepted,"import math +n, d = map(int,input().split()) +ans = 0 +for i in range(n): + x, y = map(int,input().split()) + z = math.sqrt(x**2 + y**2) + if (z <= d): + ans = ans + 1 +print(ans)" +p03456,s056064471,Accepted,"import math +li = input().split() + +a = ''.join(li) +b = math.pow(int(a),0.5) +if b % int(b) == 0: + print('Yes') +else: + print('No')" +p02677,s296081507,Accepted,"from math import pi, sin, cos, sqrt +a,b,h,m=map(int,input().split()) +c=2*pi/12*h + pi/6/60*m +d=2*pi/60*m +ax=a*cos(c) +ay=a*sin(c) +bx=b*cos(d) +by=b*sin(d) +print(sqrt((ax-bx)**2 + (ay-by)**2))" +p03565,s563702414,Accepted,"s=input() +t=input() +strs=[] +S=len(s) +T=len(t) +for i in range(S-T+1): + flag=0 + for j in range(T): + if s[i+j]==""?"": + continue + if s[i+j]!=t[j]: + flag=1;break + if flag==0: + posstr=s[:i]+t+s[i+T:] + strs.append(posstr.replace(""?"",""a"",50)) +strs.sort() +if strs==[]:print(""UNRESTORABLE"") +else:print(strs[0]) +" +p03210,s102823390,Accepted,"x = int(input()) + +if x == 7 or x == 5 or x == 3: + print(""YES"") +else: + print(""NO"") +" +p02661,s812377948,Wrong Answer,"import statistics +import math +N = int(input()) + +n =[] +m =[] + +for i in range(N): + a,b = list(map(int,input().split())) + n.append(a) + m.append(b) + +nmean = statistics.median(n) +mmean =statistics.median(m) + +if N%2 == 1: + print(mmean - nmean + 1) +else: + print(int(mmean - nmean)*2 +1 )" +p03017,s956814404,Accepted,"N, A, B, C, D = map(int, input().split()) +N-=1 +A-=1 +B-=1 +C-=1 +D-=1 +S = input() + +overtakeFlag = False +proceedableFlag = True +if C > D: + for i in range(B, D+1): + if S[i-1] == ""."" and S[i] == ""."" and S[i+1] == ""."": + overtakeFlag = True +else: + overtakeFlag = True + +for i in range(A, max(C, D)-1): + if S[i]==""#"" and S[i+1]==""#"": + proceedableFlag = False + +if overtakeFlag and proceedableFlag: + print(""Yes"") +else: + print(""No"") +" +p02765,s310153110,Wrong Answer,"n,r=map(int,input().split()) +if n>=10: + print(r) +else: + print(r-100*(10-n))" +p02823,s682358403,Wrong Answer,"N,A,B = list(map(int,input().split())) +a = A - 1 +b = N - B +c = B - A +if c%2==0: + res = c/2 +elif a=0: + print(""Zero"") +elif a<0 and b<0: + if abs(b-a)%2==0: + print(""Negative"") + else: + (""Positive"") +else: + print(""Positive"")" +p03107,s985477416,Accepted,"st = [] +S = input() +ans = 0 +for c in S: + if st != [] and c != st[-1]: + st.pop(-1) + ans += 2 + else: + st.append(c) +print(ans)" +p02547,s190785365,Accepted,"n = int(input()) + +dices = [] + +successive_cnt = 0 + +for i in range(n): + d, e = [int(x) for x in input().split(' ')] + + if d == e: + successive_cnt += 1 + else: + successive_cnt = 0 + + if successive_cnt == 3: + break + +if successive_cnt == 3: + print('Yes') +else: + print('No')" +p02628,s158598752,Accepted,"import sys +input = sys.stdin.readline + + +def log(*args): + print(*args, file=sys.stderr) + + +def main(): + _, k = map(int, input().strip().split()) + ps = sorted(map(int, input().strip().split())) + print(sum(ps[:k])) + + +if __name__ == '__main__': + main() +" +p02910,s688863816,Wrong Answer,""""""" +abc141-b +"""""" + +import sys + +S = input() + +if (len(S) == 1): + print(""No"") + sys.exit() +else: + for i in range(int(len(S))-1): + if (i % 2 == 0): + if (S[i] == ""L""): + print(""No"") + sys.exit() + else: + if (S[i] == ""R""): + print(""No"") + sys.exit() + +print(""Yes"")" +p03438,s536167890,Accepted,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = [] +a_sum = 0 +b_sum = 0 +for i in range(n): + c.append(b[i]-a[i]) + if c[i] < 0: + b_sum += c[i] + else: + a_sum += c[i]//2 + +if a_sum < abs(b_sum): + print(""No"") +else: + print(""Yes"")" +p03680,s517159870,Wrong Answer,"n = int(input()) +a = [int(input()) for l in range(n)] +flag = True +ans = 0 +i = a[0] +while flag: + i = a[i-1] + ans += 1 + if i == 2: + print(ans+1) + flag = False + + if ans > n-1: + print(-1) + flag = False + + " +p02603,s758912637,Accepted,"N = int(input()) +A = [] +A = list(map(int, input().split())) + +c_amount = 1000 +for i in range(N-1): + if(A[i]>=A[i+1]): + pass + else: + c_amount+=(c_amount//A[i])*(A[i+1]-A[i]) + +print(c_amount) +" +p03625,s480287465,Wrong Answer,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +c = Counter(a) +d = [0,0] +for i in c: + if c[i]>1: + d.append(i) + if c[i]>3: + d.append(i) +d.sort(reverse=True) +print(d[-1]*d[-2])" +p02819,s347505517,Accepted,"import math + +num = int(input()) +step = [] +sqrt_num = int(math.sqrt(num)) +count=0 + +while True: + for i in range(2,sqrt_num+2): + if num == 2: + count=1 + break + + if num%i == 0: + count = 0 + break + + count=1 + + if count == 1: + break + + num = num+1 + sqrt_num = int(math.sqrt(num)) + +print(num)" +p02659,s541388438,Accepted,"from decimal import Decimal +A, B = list(map(float, input().split())) +a = Decimal(str(A))*Decimal(str(B)) +print(int(a//1))" +p02880,s810653891,Accepted,"def main(n): + for i in range(1,10): + x,y = divmod(n, i) + if y == 0 and (0 < x and x < 10): + return True + return False + +n = int(input()) +print(""Yes"" if main(n) else ""No"")" +p02831,s128930962,Accepted,"a,b=map(int,input().split()) +m=min(a,b) +kouyakusuu=1 +for i in range(1,m+1): + if a%i==0 and b%i==0: + kouyakusuu=i +print(a*b//kouyakusuu)" +p03062,s273550867,Accepted,"import numpy as np +N = int(input()) +A = np.array(input().split(), dtype=np.int64) + +neg = np.count_nonzero(A[A < 0]) +ans = np.abs(A).sum() +if neg % 2 == 1: + v = np.abs(A).min() + ans -= 2 * v + +print(ans) +" +p02859,s320572036,Accepted,"from sys import stdin + +r = int(stdin.readline().rstrip()) + +print(r ** 2)" +p02714,s419736804,Accepted,"n = int(input()) +S = input() + +ans = S.count('R') * S.count('G') * S.count('B') + +for i in range(n-2): + for j in range(i+1,n-1): + if 2*j-i >= n: + break + elif S[i] != S[j] and S[j]!=S[2*j-i] and S[i] != S[2*j-i]: + ans -=1 + +print(ans)" +p03243,s065140676,Accepted,"s=int(input()) +A=[111,222,333,444,555,666,777,888,999] +for i in A: + if i-s>=0: + print(i) + exit()" +p02994,s915397014,Accepted,"n,l=map(int,input().split()) +a=list(range(l,n+l)) +m=list(map(abs,a)) +print(sum(a)-a[m.index(min(m))])" +p03472,s036601168,Accepted,"n,h = map(int,input().split()) +a = [] +b = [] +for i in range(n): + ai,bi = map(int,input().split()) + a.append(ai) + b.append(bi) +a.sort(reverse=True) +b.sort(reverse=True) +ans = 0 +damage = 0 +for i in b: + if i > a[0]: + damage += i + ans += 1 + if damage >= h: + print(ans) + exit() +h -= damage +print(ans + (h+a[0]-1)//a[0])" +p02854,s362701358,Accepted,"n = int(input()) +dat = list(map(int, input().split())) +t = sum(dat) +target = t//2 +c = 0 +c2 = t +res = 99999999999999999 +for i in range(n): + c += dat[i] + c2 -= dat[i] + res = min(res, abs(c-c2)) + +print(res)" +p02797,s813256202,Accepted,"N,K,S=map(int,input().split()) +if S==10**9: + l=[10**9]*K + [1]*(N-K) + print(*l) +else: + l=[S]*K+[10**9]*(N-K) + print(*l)" +p02621,s075485007,Accepted,"a=int(input()) +print(a+a**2+a**3)" +p03632,s977914207,Accepted,"# -*- coding: utf-8 -*- +a,b,c,d = map(int, input().split()) +start_later = max(a,c) +stop_earlier = min(b,d) +res = stop_earlier - start_later +print(res if res > 0 else 0) +" +p03309,s940957469,Wrong Answer,"import numpy as np +n = int(input()) +a = np.array(list(map(int, input().split()))) +b = a - np.arange(1, n+1) +print(int(np.median(b)))" +p03062,s499490321,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +m = 0 +b = [] +for i in range(n): + if a[i] < 0: + m += 1 + b.append(-a[i]) + else: + b.append(a[i]) + +if m % 2 == 1: + print(sum(b) - 2*min(b)) +else: + print(sum((b))) +" +p03796,s354066004,Accepted,"n = int(input()) +pw = 1 +for i in range(n): + pw *= (i+1) + pw %= 10**9+7 +print(pw)" +p03309,s026539977,Accepted,"import sys +import heapq, math +from itertools import zip_longest, permutations, combinations, combinations_with_replacement +from itertools import accumulate, dropwhile, takewhile, groupby +from functools import lru_cache +from copy import deepcopy + +N = int(input()) +A = list(map(int, input().split())) + +for i in range(N): + A[i] -= i + 1 + +A.sort() +central = A[N // 2] + +ans = 0 +for i in range(N): + ans += abs(central - A[i]) +print(ans)" +p03069,s763442174,Accepted,"import sys +input = sys.stdin.readline + +N = int(input()) +S = list(input().rstrip()) + +A = [0] +a = 0 +for s in S: + if s == ""."": + a += 1 + A.append(a) + +B = A[-1] + +ans = N+1 +for i, a in enumerate(A): + score = (i - a) + B - a + ans = min(ans, score) + +print(ans)" +p02797,s109858726,Wrong Answer,"n, k, s = map(int, input().split()) + +arr = [s] * k + [s + 1, s - 1] * ((n - k) // 2) + [s + 1] * ((n - k) % 2) + +print(*arr)" +p02744,s220219018,Accepted,"def dfs(s, mx, N): + if len(s) == N: + print s + else: + for ch in range(ord('a'), ord(mx) + 1): + if chr(ch) == mx: + dfs(s + chr(ch), chr(ord(mx) + 1), N) + else: + dfs(s + chr(ch), mx, N) + +def solve2(): + N = int(raw_input()) + dfs('', 'a', N) + +if __name__ == '__main__': + solve2() +" +p02912,s738313892,Wrong Answer,"from math import floor + + +def main(): + N, M = map(int, input().split("" "")) + A = list(map(int, input().split("" ""))) + A.sort(reverse=True) + while M > 0: + for i in range(0, N): + if A[i] > 2 and M > 0: + A[i] = floor(A[i] / 2) + M -= 1 + print(sum(A)) + + +if __name__ == '__main__': + main()" +p02820,s599812777,Accepted,"N, K = map(int, input().split()) +R, S, P = map(int, input().split()) +T = list(input()) + + +ans = 0 +commands = [''] * N +for i, t in enumerate(T): + if t == 'r': + command = 'p' + point = P + + elif t == 's': + command = 'r' + point = R + + elif t == 'p': + command = 's' + point = S + + if (i - K >= 0) and (commands[i - K] == command): + command = '' + point = 0 + + ans += point + commands[i] = command + +print(ans)" +p03814,s579488483,Accepted,"A = input() +N = len(A) +for i in range(N): + if A[i] == ""A"": + posA = A.index(A[i]) + break +p = 0 +for j in range(0, N): + if A[j] == ""Z"" and j > p: + p = j +p += 1 +print(len(A[posA:p]))" +p02796,s365849438,Accepted,"class Robot: + def __init__(self, left, right): + self.left = left + self.right = right + + def __lt__(self, other): + return self.right < other.right + +n = int(input().rstrip()) +robos = [None] * n + +for i in range(n): + line = input().rstrip().split(' ') + robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1])) + +robos.sort() + +cur = -1000000000 +ans = 0 +for i in range(n): + if cur <= robos[i].left: + ans += 1 + cur = robos[i].right + +print(ans)" +p02726,s099063019,Accepted,"N,X,Y = map(int,input().split()) +L = [] +for i in range(N-1): + L.append(0) +for A in range(1,N): + for B in range(A+1,N+1): + a_1 = B-A + a_2 = abs(X-A)+1+abs(Y-B) + a = min([a_1,a_2]) + L[a-1]+=1 +for j in range(N-1): + print(L[j])" +p03681,s671013526,Accepted,"import math +mod=10**9+7 +factorial=[1 for _ in range(10**5+10)] +for i in range(1, 10**5+10): + factorial[i]=i*factorial[i-1] % mod +n,m=map(int,input().split()) +if abs(n-m)>1: + print(0) +elif abs(n-m)==0: + print(2*factorial[n]*factorial[m]%mod) +else: + print(factorial[n]*factorial[m]%mod) +" +p02947,s853903530,Accepted,"#abc137 c +n=int(input()) +table=dict() +for i in range(n): + s=str(sorted(input())) + if s not in table: + table[s]=1 + else: + table[s]+=1 +ans=0 + +for x in table.values(): + kumi=(x*(x-1))/2 + ans+=int(kumi) +print(ans)" +p04020,s386669328,Wrong Answer,"import sys + +N = int(sys.stdin.readline().rstrip()) + +A = [] +for _ in range(N): + A.append(int(sys.stdin.readline().rstrip())) + +pairs = 0 +pre_res = 0 +for a_i in A: + r = a_i // 2 + pairs += r + res = a_i - 2*r + if res + pre_res == 2: + pairs += 1 + res = 0 + + pre_res = res + +print(pairs)" +p03696,s599618356,Accepted,"n = int(input()) +s = input() +countr, countl = 0, 0 + +for i in range(n-1, -1, -1): + if s[i] == ')': countr += 1 + elif countr > 0: countr -= 1 +s = '('*countr+s +n = len(s) + +for i in range(n): + if s[i] == '(': countl += 1 + elif countl > 0: countl -= 1 +s += ')'*countl + +print(s) +" +p02866,s987429681,Accepted,"from collections import Counter + + +N = int(input()) +D = list(map(int, input().split())) +p = 998244353 +count = Counter(D) + +if D[0] != 0 or len(set(D)) != max(D) + 1 or count[0] > 1: + ans = 0 +else: + count = sorted(count.items(), key=lambda x: x[0]) + ans = 1 + for i in range(len(count) - 1): + x = count[i][1] + y = count[i + 1][1] + ans *= x ** y + ans %= p + +print(ans)" +p02970,s216709467,Accepted,"import math +n,d=map(int,input().split()) +print(math.ceil(n/(2*d+1)))" +p02640,s634773273,Accepted,"X, Y = [int(i) for i in input().split()] + +ans = ""No"" +for i in range(101): + if ans != ""No"": + break + for j in range(101): + if i+j != X: + continue + if i*2 + j*4 == Y: + ans = ""Yes"" + break +print(ans)" +p02646,s625781689,Wrong Answer,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) + +A_res = A + V * T +B_res = B + W * T +if A > B: + print(""NO"") +elif A_res >= B_res: + print(""YES"") +else: + print(""NO"")" +p03607,s952658878,Accepted,"N = int(input()) +S = set() +ans = 0 +for i in range(N): + a = int(input()) + if a in S: + ans -= 1 + S.remove(a) + else: + ans += 1 + S.add(a) +print(ans)" +p03680,s535647662,Accepted,"n=int(input()) +a=[0] +for _ in range(n): + a.append(int(input())) +b=[0]*(n+1) +i=1 +ans=0 +while b[i]==0 and i!=2: + b[i]=1 + i=a[i] + ans+=1 +print(ans if i==2 else -1) + + + +" +p02922,s301431690,Wrong Answer,"a,b=map(int,input().split()) +count=0 +while b>0: + b=b-a + count=count+1 + +print(count) +" +p03659,s730451478,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] + +sm = sum(a) +acc = [0] +for i in range(n): + acc.append(acc[-1] + a[i]) + +ans = 10000000000 +for i in range(1,n): + ans = min(ans,abs(sm - acc[i] * 2)) +print(ans) +" +p02705,s178005319,Wrong Answer,"from math import pi +def cicle(r): + return 2 * r * pi" +p02548,s815663188,Accepted," +n = int(input()) + +ans = 0 + +a = 1 + +while a <= n: + + if a == 1 : + ans = ans + (n - 1) + else : + if n % a == 0 : + ans = ans + ( (n // a) - 1) + else : + ans = ans + ( (n // a) ) + + a += 1 + +print(ans)" +p03327,s348459197,Accepted,"N = input() +N = int(N) + +if (N <= 999): + print(""ABC"") +else: + print(""ABD"") +" +p03161,s616600497,Accepted,"N, K = map(int, input().split()) +H = list(map(int, input().split())) + +H = [0] + H +dp = [0] * (N+1) + +for i in range(2, N+1): + dp[i] = dp[i-1] + abs(H[i]-H[i-1]) + for k in range(2, K+1): + if i-k >= 1: + dp[i] = min(dp[i], dp[i-k]+abs(H[i]-H[i-k])) + +res = dp[N] +print(res)" +p02576,s909729543,Accepted,"## coding: UTF-8 +import math + +N, X, T = map(int,input().split()) +ans = math.ceil(N/X) * T +print(ans) +" +p02972,s804003229,Accepted,"N = int(input()) +a = [0] + list(map(int,input().split())) +ans = [0]*(N+1) +for k in range(N,0,-1): + temp = 0 + l = k + while l <= N: + temp += ans[l] + l += k + if a[k] == 1 and temp%2 == 0: + ans[k] = 1 + elif a[k] == 0 and temp%2 == 1: + ans[k] = 1 +b = [] +for k in range(1,N+1): + if ans[k] == 1: + b.append(k) +print(len(b)) +print(*b) +" +p03087,s678354976,Accepted,"import copy + +n, q = map(int, input().split()) +s = input() + +cnt = [0] +for i in range(n-1): + if s[i] == 'A' and s[i+1] == 'C': + cnt.append(cnt[-1] + 1) + else: + cnt.append(cnt[-1]) + +for i in range(q): + l, r = map(int, input().split()) + print(cnt[r-1] - cnt[l-1])" +p03319,s864831123,Wrong Answer,"import math + +N,K=map(int,input().split()) +a=input().split() + +A=[int(b) for b in a] + +place=A.index(min(A)) + +if place==0: + answer=N//2 + print(answer) +else: + answer=math.ceil((N-place)/2) + answer+=math.ceil(place/2) + print(answer) + " +p02659,s944322245,Accepted,"a,b = input().split() +a = int(a) +b = int(b[0] + b[2:]) +print(a*b//100) +" +p03359,s481201788,Accepted,"a,b=map(int,input().split()) +print(a-1+(b>=a))" +p03711,s117424746,Accepted,"G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])] +def check(x, y): + for g in G: + if x in g and y in g: + return True + return False +x, y = map(int, input().split()) +print(""Yes"" if check(x, y) else ""No"") +" +p02612,s601872682,Accepted,"n = int(input()) +x = n % 1000 +if x == 0: + print(0) +else: + print(1000-x) +" +p02719,s376241692,Accepted,"n, k = map(int, input().split()) +rest = n % k +print(min(rest, k - rest))" +p03695,s407521800,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +color=[] +free=0 +Sans,Mans=0,0 +for i in a: + if i//400<8 and i//400 not in color: + color.append(i//400) + Sans+=1 + elif i>=3200: + free+=1 + +#Mans=Sans +#if free+Sans>=8: + # Mans=8 +#else: + # Mans=Sans+free + +Mans=Sans+free +if Sans==0: + Sans=1 +print(Sans,Mans)" +p02657,s971133454,Accepted,"a, b = map(int, input().split()) +print(a*b)" +p02682,s917014554,Accepted,"import sys +input = sys.stdin.readline +def calc(A, B, C, K): + sum = 0 + if K>A: + sum += A + K = K-A + else: + sum = K + return sum + if K>B: + K = K - B + else: + return sum + sum = sum - K + return sum + + +def main(): + A, B, C, K = map(int, input().split()) + sum = calc(A,B,C,K) + print(sum) + + + +if __name__ == '__main__': + main()" +p03821,s604456603,Wrong Answer,"n=int(input()) +ans=0 +a=[] +for i in range(n): + a.append(list(map(int,input().split()))) +for i in reversed(range(n)): + if a[i][1] != 1 and a[i][0] != 0: + a[i][0] += ans + ans += a[i][1] - a[i][0] % a[i][1] +print(ans)" +p03163,s240242219,Wrong Answer,"def main(): + import numpy as np + import sys + input = sys.stdin.readline + + n,w = map(int,input().split()) + l = [list(map(int,input().split())) for i in range(n)] + + dp = np.zeros((n+1,w+1),dtype=""int64"") + for i in range(n): + dp[i+1,l[i][0]:] = np.maximum(dp[i,l[i][0]:],dp[i,-l[i][0]]+l[i][1]) + print(dp[n][w]) + +if __name__ == ""__main__"": + main()" +p02720,s749233715,Accepted,"from collections import deque + +K = int(input()) +queue = deque(range(1, 10)) + +for i in range(K): + x = queue.popleft() + shimo1keta = x % 10 + if shimo1keta != 0: + queue.append(x * 10 + shimo1keta - 1) + queue.append(x * 10 + shimo1keta) + if shimo1keta != 9: + queue.append(x * 10 + shimo1keta + 1) + +print(x) +" +p03075,s303697436,Accepted,"l1 = [] +for _ in range(6): + l1.append(int(input())) + +if (l1[4] - l1[0]) > l1[5]: + r = ':(' +else: + r = 'Yay!' + + +print(r)" +p02678,s682619858,Accepted,"from collections import deque +n,m = map(int,input().split()) +g = [[] for _ in range(n)] +for i in range(m): + a,b = map(int,input().split()) + g[a-1].append(b-1) + g[b-1].append(a-1) +q = deque([0]) +d = [-1]*n +d[0] = 0 +while q: + v = q.popleft() + for i in g[v]: + if d[i] != -1: + continue + d[i] = v + q.append(i) +if -1 in d: + print(""No"") +else: + print(""Yes"") + for i in d[1:]: + print(i+1)" +p02552,s864553936,Accepted,"# -*- coding: utf-8 -*- +x = int(input()) +print(0 if x == 1 else 1)" +p02583,s991158167,Wrong Answer,"N = int(input()) + +L = map(int, input().split()) +L = list(set(L)) +L.sort() +ret = 0 +N_ = len(L) +if N_ >= 3: + for i in range(N_ - 2): + for j in range(i + 1, N_ - 1): + for k in range(j + 1, N_): + if L[i] + L[j] < L[k]: + ret += 1 +print(ret) +" +p03592,s910150815,Accepted,"N, M, K = map(int, input().split()) +if K % N == 0 or K % M == 0: + print('Yes') + exit() +candidates = set() +for i in range(1, N): + curr = i * M + for j in range(1, M): + curr += N - 2 * i + candidates.add(curr) +print('Yes') if K in candidates else print('No') +" +p03852,s677047096,Accepted,"c = input() +print(""vowel"" if c in [""a"", ""e"", ""i"", ""o"", ""u""] else ""consonant"") +" +p03359,s646279632,Accepted,"a,b=list(map(int,input().split())) +if a<=b: + print(a) +else: + print(a-1)" +p03317,s244570060,Accepted,"import math +s = list(map(int, input().split())) +n=s[0] +k=s[1]-1 +s = list(map(int, input().split())) +ind=s.index(1) +# print(ind,n-ind-1,math.ceil(ind/k),math.ceil((n-ind-1)/k)) +print(math.ceil((n-1)/(k)))" +p03679,s757308950,Accepted,"a,b,c = map(int,input().split()) +if b-c>=0: + print(""delicious"") +elif a+b-c>=0: + print(""safe"") +else: + print(""dangerous"")" +p02948,s886219627,Accepted,"import heapq + +N,M = (int(x) for x in input().split()) +AB = [] +sum = 0 + +for i in range(N): + a,b = (int(x) for x in input().split()) + AB.append([a,b]) + +AB = sorted(AB , key = lambda x : x[0]) +heap = [] +heapq.heapify(heap) +j = 0 + +for i in range(M+1): + while jb and b!=1)): + print('Alice') +elif ((b==1 and a!=1) or (b>a and a!=1)): + print('Bob') +else: + print('Draw') + " +p03220,s211771272,Accepted,"def resolve(): + N = int(input()) + T, A = [int(i) for i in input().split()] + H = [int(i) for i in input().split()] + absList = [] + for i in range(N): + absList.append((abs(A - (T - (H[i] * 0.006))), i)) + print(min(absList)[1] + 1) + + +resolve() +" +p02842,s534176815,Wrong Answer,"import math +N = int(input()) +S = N / 1.08 +if math.ceil(S) * 1.08 != N: + print("":("") +else: + print(math.ceil(S)) +" +p03455,s386768518,Wrong Answer,"a,b = map(int,input().split()) +c = a*b % 2 +if c == 0: + print(""even"") +else: + print(""odd"") +" +p03131,s183291339,Accepted,"n, a, b = map(int, input().split()) + +if a + 2 < b: + if n < a: + print(n + 1) + else: + n -= a - 1 + if n % 2 == 0: + print(n//2 * (b - a) + a) + else: + print(n//2 * (b - a) + 1 + a) +else: + print(n + 1)" +p02783,s623551179,Wrong Answer,"h,a=map(int,input().split()) +count=0 +while h>=0: + h-=a + count+=1 +print(count) " +p02780,s717266464,Wrong Answer,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +sum_tmp = sum(a[:k]) +sum_max = sum_tmp +for i in range(3,len(a)): + sum_tmp += a[i] - a[i-k] + if sum_tmp > sum_max: + sum_max = sum_tmp +print((sum_max + k)/2)" +p02724,s890732021,Accepted,"x=int(input()) +s=0 +while x>=500: + x-=500 + s+=1000 +while x>=5: + x-=5 + s+=5 +print(s)" +p02971,s829393848,Accepted,"n = int(input()) +A = [int(input()) for _ in range(n)] +# print(A) +mf = max(A) +cnt_mf = A.count(mf) + +if cnt_mf > 1: + for _ in range(n): + print(mf) + exit() + +Aset = set(A) +# print(Aset - {mf}) +ms = max((Aset - {mf})) +# print(ms) + +for e in A: + if e != mf: + print(mf) + else: + print(ms) +" +p03745,s532562364,Accepted,"n = int(input()) +a = [int(x) for x in input().split()] + +ans = 1 +up = None + +for i in range(n-1): + if up == None: + if a[i] == a[i+1]: + continue + elif a[i] < a[i+1]: + up = True + else: + up = False + elif up and a[i] > a[i+1]: + up = None + ans += 1 + elif not up and a[i] < a[i+1]: + up = None + ans += 1 +print(ans)" +p03633,s853923462,Accepted,"import fractions +N = int(input()) +T = [] +for i in range(N): + T.append(int(input())) +X = T[0] +for i in range(1, N): + X = X*T[i] // fractions.gcd(X, T[i]) +print(X)" +p03944,s909358803,Wrong Answer,"W, H, N = [int(i) for i in input().split()] + +xya = [] + +for _ in range(N): + xya.append([int(i) for i in input().split()]) + +xmin = 1 +ymin = 1 +xmax = W +ymax = H + +for i in xya: + if i[2] == 1: + xmin = max(xmin, i[0]) + elif i[2] == 2: + xmax = min(xmax, i[0]) + elif i[2] == 3: + ymin = max(ymin, i[1]) + else: + ymax = min(ymax, i[1]) + +s = (xmax - xmin) * (ymax - ymin) + +if s > 0: + print(s) +else: + print(0)" +p03835,s533547462,Accepted,"k,s=map(int,input().split()) +ret=0 +k+=1 +for i in range(k): + for j in range(k): + d=s-i-j + if k>d>=0: + ret+=1 +print(ret)" +p03208,s391882026,Accepted,"n,k=map(int,input().split()) +h=[int(input()) for _ in range(n)] +h.sort() +ans=max(h) +for i in range(n-k+1): + tmp=h[i+k-1]-h[i] + ans=min(ans,tmp) +print(ans)" +p03387,s873910406,Accepted,"l = list(map(int, input().split())) +l.sort() + +max_v = l[2] +mid_v = l[1] +min_v = l[0] + +count = max_v - mid_v +mid_v = max_v +min_v = min_v + count +diff = max_v - min_v + +if diff == 0: + count = count +elif diff == 1: + count += 2 # ope2 and ope1 +elif diff > 1 and diff % 2 == 0: + count += diff / 2 +elif diff > 1 and diff % 2 == 1: + count += int(diff / 2) + count += 2 +else: + print(""Error"") +print(int(count)) +" +p03951,s629916572,Wrong Answer,"N=int(input()) +s=str(input()) +t=str(input()) +cnt=0 + +for i in range(min(len(s),len(t))): + if s[-1-i]==t[i]: + cnt+=1 + else: + break +st=s[:len(s)-cnt+1]+t[cnt:] +if s==t: + st=s +print(len(st))" +p03478,s998470536,Accepted,"n,a,b = map(int,input().split()) +c = 0 +for i in range(1,n+1): + s = 0 + d = i + while d!=0: + s+= d%10 + d//=10 + if a<=s<=b: + c+=i +print(c)" +p02629,s847737622,Accepted,"import math +p=int(input()) +ll=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] +a=0 +n=0 +prevn=0 + +while n<1000000000000001: + a+=1 + prevn=n + n+=26**a + if n>=p: + break + +p2=p-prevn-1 + +al="""" +for i in range(a): + s1=math.floor(p2/(26**(a-i-1))) + al=al+ll[s1] + p2=p2%26**(a-i-1) + +print(al)" +p02547,s718024012,Accepted,"n = int(input()) +flag = 0 +max_ = 0 +for i in range(n): + d = list(map(int, input().split())) + if d[0] == d[1]: + flag += 1 + else: + flag = 0 + + if max_ < flag: + max_ = flag + +if max_ >= 3: + print(""Yes"") +else: + print(""No"")" +p02618,s958579734,Accepted,"import random +D = int(input()) +C = list(map(int, input().split())) +S = [list(map(int, input().split())) for _ in range(D)] + +score = 0 +last_day = [-1] * 26 +for d in range(D): + print(d % 26 + 1) +" +p03624,s074932802,Accepted,"s=input() + +s=list(s) + +alf = [chr(ord('a') + i) for i in range(26)] + +for i in alf: + if i not in s: + print(i) + exit() +print('None')" +p03331,s617226999,Wrong Answer,"n=int(input()) +gou=0 +goub=0 +ke = n +for i in range(n): + b=n-i + while i: + gou += i%10 + i= i//10 + while b: + goub += b%10 + b= b//10 + kei=gou+goub + if ke > kei: + ke=kei +print(ke)" +p02659,s182766553,Wrong Answer,"a,b = map(float, input().split()) +b100 = int(b*100) +ab = int(a*b100) +print(str(ab)[:-2]) + +" +p03317,s488000003,Accepted,"n,k = map(int,input().split()) +a = [int(i) for i in input().split()] + +b = a.index(1) +ans = 0 +b -= (k-1) +if b < 0: + b = a.index(1) + abs(b) +if b > n-1 -(k-1): + b -= b- (k-1) +c,d = divmod(b,k-1) +ans += c +if d != 0: + ans +=1 +e,f = divmod(n-1 - b,k-1) +ans += e +if f != 0: + ans +=1 +if d != 0 and f != 0 and d + f <= k-1: + ans -=1 +print(ans)" +p02957,s806824046,Wrong Answer,"a,b=map(int, input().split()) +print(int(a*b/2) if a*b/2%2==0 else ""IMPOSSIBLE"")" +p03799,s577461376,Wrong Answer,"n,m=map(int,input().split()) + +cnt=0 + +m=m-2*n +cnt+=n + +num=m//4 +cnt+=num + +print(cnt)" +p03127,s953951547,Wrong Answer,"n = int(input()) +aL = sorted(list(map(int, input().split("" "")))) + +s = set() + +oddOnly = True +gOnly = True +for a in aL: + if a % 2 == 1: + gOnly = False + if a % aL[0] != 0: + oddOnly = False + s.add(a) + +if oddOnly: + print(min(aL)) +elif gOnly: + print(2) +else: + print(1) +" +p02659,s686831802,Accepted,"import sys +import decimal + +a,b = input().split() +Da = decimal.Decimal(a) +Db = decimal.Decimal(b) +res = Da*Db + +print(int(res))" +p03329,s669719660,Wrong Answer,"n=int(input()) +inf=float(""inf"") +DP=[inf]*(n+1) +DP[0]=0 + +for i in range(1,n+1): + for P in (6,9): + cnt=1 + while P**cnt<=i: + DP[i]=min(DP[i-1]+1,DP[i-P**cnt]+1,DP[i]) + cnt +=1 + +print(DP[n])" +p03069,s639541527,Accepted,"N = int(input()) +S = input() + +w = S.count('.') +b = N - w +ans = min(w, b) +l, r = 0, w + +for si in S: + if si == '#': + l += 1 # 現時点iも含め左側に存在する黒の数 + else: + r -= 1 # 現時点iも含め右側に存在する白の数 + ans = min(ans, l+r) + +print(ans)" +p03695,s236471579,Accepted,"import sys + +sys.setrecursionlimit(10 ** 7) +input = sys.stdin.readline +f_inf = float('inf') +mod = 10 ** 9 + 7 + + +def resolve(): + n = int(input()) + A = list(map(int, input().split())) + + Color = [0] * 9 + for a in A: + if a >= 3200: + Color[-1] += 1 + else: + Color[a // 400] = 1 + + mi = sum(Color[:8]) + (1 if sum(Color[:8]) == 0 and Color[8] > 0 else 0) + ma = sum(Color[:8]) + Color[8] + + print(mi, ma) + + +if __name__ == '__main__': + resolve() +" +p02811,s712979838,Accepted,"k, x = map(int, input().split()) + +if k*500 >= x: + print('Yes') +else: + print('No')" +p03219,s539422212,Accepted,"x,y = map(int,input().split()) +print(x + y // 2)" +p02724,s076560841,Accepted,"x=int(input()) +print(str(int(x/500)*1000+int((x%500)/5)*5))" +p03679,s873974015,Accepted,"a,b,c = map(int,input().split()) +if(c-b>a): + print(""dangerous"") +elif(c-b<=0): + print(""delicious"") +else: + print(""safe"") +" +p03474,s607713942,Accepted,"import re +A, B = map(int, input().split()) +S = input() +n_pattern = ""[0-9]"" +res = ""Yes"" +for i in range(A+B+1): + if i < A: + if re.match(n_pattern, S[i]) is None: + res = ""No"" + break + elif i == A: + if S[i] != ""-"": + res = ""No"" + break + else: + if re.match(n_pattern, S[i]) is None: + res = ""No"" + break + +print(res) +" +p02572,s302901826,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +p = int(1e9 + 7) + +result = 0 +total = 0 +for i in range(N - 1, 0, -1): + total = (total + A[i]) % p + result = (result + A[i-1] * total) % p +print(result)" +p03696,s162645389,Wrong Answer,"n = int(input()) +s = input() +ans = """" +l=r=0 +for i in range(n): + if s[i]==""("": l+= 1 + else: r += 1 + if i+1 < n and s[i]+s[i+1]== "")("": + ans += ""(""*max(l,r) + "")""*max(l,r) + l=r=0 +if max(l,r) != 0:ans += ""(""*max(l,r) + "")""*max(l,r) +print(ans)" +p03251,s819736310,Accepted,"N, M, X, Y = map(int, input().split()) +x = [int(_) for _ in input().split()] +y = [int(_) for _ in input().split()] + +x_max = max(x) +y_min = min(y) + +if (y_min-x_max > 0) and (Y-X > 0) and (X0)-1)" +p02971,s211799967,Accepted,"import sys +input = sys.stdin.readline + +n = int(input()) + +max1 = 0 +max2 = 0 +maxindex = -1 + +for i in range(n): + a = int(input()) + if a >= max1: + max2 = max1 + max1 = a + maxindex = i + elif a >= max2: + max2 = a + +out = [max1] * n +out[maxindex] = max2 + +for m in out: + print(m) +" +p03680,s899411954,Accepted,"N = int(input()) +a = [int(input())-1 for _ in range(N)] + +ans,i = 0,0 +check = [0]*N + +while i != 1: + check[i] += 1 + if check[i] > 1: + ans = -1 + break + ans += 1 + i = a[i] + +print(ans)" +p03146,s096434090,Accepted,"s = int(input()) +A = [s] +ans = 1 +while True: + A.append(A[-1]//2 if A[-1]%2 == 0 else A[-1]*3+1) + ans += 1 + if A.count(A[-1]) > 1: + break +print(ans)" +p02848,s225006200,Accepted,"n = int(input()) +s = input() +ans = '' + +for i in range(len(s)): + next = ord(s[i]) + n + if next > ord('Z'): + next -= 26 + ans += (chr(next)) + +print(ans)" +p03251,s495065324,Accepted,"n, m, x, y = map(int, input().split()) +xs = list(map(int, input().split())) +ys = list(map(int, input().split())) + +xx = max(xs) +yy = min(ys) + +for i in range(x+1,y+1): + if xx < i <= yy: + print('No War') + break +else: + print('War')" +p03106,s500925777,Accepted,"A,B,K = map(int, input().split()) + +l = [] + +for i in range (1, min(A,B)+1): + if A % i== 0 and B % i == 0: + l.append(i) +print(l[-K])" +p02623,s458966175,Accepted,"import sys +input = sys.stdin.buffer.readline + +import bisect +N, M, K = map(int, input().split()) +A = list(map(int, (input().split()))) +B = list(map(int, (input().split()))) +cumA, cumB = [0], [0] +for a in A: + cumA.append(cumA[-1]+a) +for b in B: + cumB.append(cumB[-1]+b) +ans = 0 +for i in range(N, -1, -1): + if cumA[i] > K: continue + j = bisect.bisect_right(cumB, K-cumA[i]) + ans = max(ans, i+j-1) +print(ans)" +p03037,s325571005,Wrong Answer,"import sys +import math +import itertools +import collections +import heapq +import re +import numpy as np + +rr = lambda: sys.stdin.readline().rstrip() +rs = lambda: map(str, sys.stdin.buffer.readline().split()) +ri = lambda: int(sys.stdin.readline()) +rm = lambda: map(int, sys.stdin.buffer.readline().split()) +rl = lambda: list(map(int, sys.stdin.readline().split())) +inf = float('inf') +mod = 10**9 + 7 + +n, m = rm() +l = 0 +r = inf +for _ in range(m): + a, b = rm() + l = max(a, l) + r = min(b, r) +print(r-l+1) + +" +p03281,s045798083,Accepted,"import math +import itertools +import numpy as np + +def div(n): + c = 0 + for i in range(1,n+1): + if n % i == 0: + c += 1 + return c + +def solve(): + n = int(input()) + ans = 0 + for i in range(1,n+1): + if div(i) == 8 and i % 2 == 1: + ans += 1 + print(ans) + return 0 + +if __name__ == ""__main__"": + solve() +" +p03795,s546629363,Wrong Answer,"n =int(input()) +print(n*800+200*(n+14)//15)" +p02705,s301942302,Wrong Answer,"r = input() + +pi = 3.1415926535 + +R = int(r) * pi + +print(R)" +p03645,s831048751,Accepted,"N,M = map(int,input().split()) +x = set() +y = set() + +for m in range(M): + a,b = map(int,input().split()) + if a==1: + x.add(b) + if b==N: + y.add(a) + +if x&y: + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"")" +p02861,s253042947,Accepted,"import math +N=int(input()) +d=[] +l=[] +for i in range(N): + x,y=map(int,input().split()) + l.append([x,y]) +for i in range(N-1): + for j in range(i+1,N): + x1,y1=l[i][0],l[i][1] + x2,y2=l[j][0],l[j][1] + d.append(math.sqrt((x1-x2)**2+(y1-y2)**2)) +print(2*sum(d)/N)" +p02578,s183193403,Accepted,"def main(): + N = int(input()) + A = list(map(int, input().split())) + temp = A[0] + su = 0 + for i in range(1, N): + if A[i - 1] > A[i]: + su += A[i - 1] - A[i] + A[i] = A[i - 1] + print(su) + + +if __name__ == '__main__': + main() +" +p03759,s377934416,Accepted,"a, b, c = map(int, input().split()) + +if b - a == c - b: + print('YES') +else: + print('NO') + +" +p02547,s226320469,Wrong Answer,"n = int(input()) +x = 0 + +for i in range(n): + a, b = map(int, input().split()) + if a == b: + x += 1 + +if x >= 3: + print('Yes') +else: + print('No') +" +p03720,s017535527,Accepted,"n, m = map(int, input().split()) + +l = [0] * n +for i in range(m): + a, b = map(int, input().split()) + l[a-1] += 1 + l[b-1] += 1 + +for i in range(n): + print(l[i])" +p02596,s152241359,Accepted,"K = int(input()) + +if K % 2 == 0 or K % 5 == 0: + print(-1) + exit() + +i = 0 +ai = 0 +while True: + ai = (ai * 10 + 7) % K + i += 1 + if ai == 0: + break +print(i)" +p03324,s986148292,Accepted,"d,n=map(int,input().split()) +x=n*(100**d) +print(x if n%100!=0 else x+(100**d))" +p02727,s358412766,Wrong Answer,"x,y,a,b,c=map(int,input().split()) +p=list(map(int,input().split())) +q=list(map(int,input().split())) +r=list(map(int,input().split())) + +p.sort(reverse=True) +q.sort(reverse=True) +r.sort() + +xy = p[:x] + q[:y] +xy.sort() +j=0 +for i in range(x+y): + if j==c: break + if xy[i] 9: + if (N%(int(""1"" + (len(str(N)) - 1)*""0""))) == int((len(str(N)) - 1) * ""9""): + tmp = list(str(N)) + tmp = [int(item) for item in tmp] + print(sum(tmp)) + else: + tmp = list(str(N - (N%(int(""1"" + (len(str(N)) - 1)*""0""))) - 1)) + tmp = [int(item) for item in tmp] + print(sum(tmp)) +else: + print(N) + + +" +p03814,s508617257,Accepted,"s = input() +end_z = s.rfind('Z') +begin_a = s.find('A') +print(end_z - begin_a + 1)" +p02797,s004981832,Wrong Answer,"N, K, S = map(int, input().split()) + +ans = [] +if S == 10**9: + for i in range(K): + ans.append(S) + for i in range(N-K): + ans.append(S+1) +else: + for i in range(K): + ans.append(S) + for i in range(N-K): + ans.append(S+1) +print(*ans)" +p02646,s658532546,Accepted,"import sys + +def solve(): + input = sys.stdin.readline + A, V = map(int, input().split()) + B, W = map(int, input().split()) + T = int(input()) + if V <= W: print(""NO"") + else: + diff = abs(A - B) + if (V - W) * T >= diff: print(""YES"") + else: print(""NO"") + + return 0 + +if __name__ == ""__main__"": + solve()" +p02909,s535380757,Accepted,"s=input() +if s=='Rainy': + print('Sunny') +elif s=='Sunny': + print('Cloudy') +else: + print('Rainy')" +p02732,s696330334,Accepted,"n=int(input()) +a=list(map(int,input().split())) +l=[0 for i in range(n+1)] + +for i in a: + l[i]+=1 +cmb1=[0 for i in range(n+1)] +cmb2=[0 for i in range(n+1)] + +for i in range(1,n+1): + cmb1[i]=(l[i]*(l[i]-1))//2 + cmb2[i]=((l[i]-1)*(l[i]-2))//2 + +kei1=0 +for i in range(1,n+1): + kei1+=cmb1[i] + +for i in range(1,n+1): + print(kei1-cmb1[a[i-1]]+cmb2[a[i-1]]) +" +p04020,s708256375,Accepted,"N=int(input()) +A=[int(input()) for i in range(N)] +count=0 +count+=A[0]//2 +A[0]%=2 +for i in range(1,N): + count+=(A[i-1]+A[i])//2 + if A[i]: + A[i]=(A[i-1]+A[i])%2 + else: + A[i]=0 +print(count) +" +p02612,s435379422,Accepted,"X = int(input()) +if X%1000: + print(1000 - (X%1000)) +else: + print(0)" +p02665,s061440055,Wrong Answer,"DoesExist = True + +N = int(input()) +As = input().split() + +for i in range(len(As)): + As[i] = int(As[i]) + +for num in range(len(As)): + if As[num] > 2**num - 1: + DoesExist = False + +nodes_num = 0 +nodes_limit = [] + +def nibungi(): + global nodes_num, nodes_limit, As + nodes_num += N + for i in range(len(As)): + nodes_num += As[i] + print(nodes_num) + +if DoesExist == False: + print(""-1"") + +else: + nibungi()" +p03077,s027583244,Accepted,"import math +n = int(input()) +lis = [int(input()) for i in range(5)] +print(math.ceil(n / min(lis)) + 4)" +p03069,s397390327,Accepted,"n = int(input()) +S = input() + +rw = S.count('.') +rb = S.count('#') +lw = 0 +lb = 0 + +ans = min(rb, rw) +for s in S: + if s == '.': + lw += 1 + rw -= 1 + else: + lb += 1 + rb -= 1 + ans = min(ans, lb+rw) +print(ans) +" +p02726,s815501285,Accepted,"n, x, y = map(int, input().split()) +x -= 1 +y -= 1 +k = [0] * n +for i in range(n-1): + for j in range(i+1,n): + m = min(abs(j-i), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)) + k[m] += 1 + +for i in range(1,n): + print(k[i])" +p03408,s331735876,Wrong Answer,"N = int(input()) +S = [input() for _ in range(N)] +M = int(input()) +T = [input() for _ in range(M)] + +ans_list = [] +for s in S: + ans = 0 + ans += S.count(s) + ans -= T.count(s) + ans_list.append(ans) + +print(max(ans_list))" +p02916,s093767612,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) + +s = 0 +t = 99 +for i in a: + if t < n: + s += c[t-1] + s += b[i-1] + t = i + +print(s)" +p02696,s358715389,Accepted,"A,B,N = (map(int , input().split())) +min(B-1,N) +x = min(B-1,N) +print(((A*x)//B - A * (x//B)))" +p02743,s003747684,Accepted,"import math +a,b,c= map(int, input().split()) + +num = (c-a-b)**2 + +if(a+b > c): + print(""No"") +elif(4*a*b < num): + print(""Yes"") +else: + print(""No"")" +p02778,s749977117,Wrong Answer,"s=str(input()) +s=list(s) +ans=[""x""]*len(s) +print(ans)" +p04020,s689783597,Wrong Answer,"import sys +input = sys.stdin.readline +N = int(input()) +a = [0] * N +res = 0 +for i in range(N): + x = int(input()) + res += x // 2 + a[i] = x % 2 +sch = [] +for i in range(N - 1): + if a[i] == a[i + 1] == 1: sch.append((i, i + 2)) +sch.sort(key = lambda x: x[1]) +x = 0 +for i in range(len(sch)): + if x <= sch[i][0]: + res += 1 + x = sch[i][1] +print(res)" +p02971,s502298457,Accepted,"n=int(input()) +a=[0]*n +for i in range(0,n): + a[i]=int(input()) +temp=sorted(a,reverse=True) +for i in range(0,n): + if a[i]==temp[0]: + print(temp[1]) + else: + print(temp[0]) + " +p03474,s543806178,Accepted,"A, B = map(int, input().split()) +S = input() + +if S[:A].count('-') == 0 and S[A] == '-' and S[A + 1:].count('-') == 0: + print('Yes') +else: + print('No') +" +p03438,s832810827,Accepted,"# B - Two Arrays +n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +sum_a=sum(a) +sum_b=sum(b) + +a_cnt,b_cnt=0,0 + +for aa,bb in zip(a,b): + if aa>bb: + a_cnt+=aa-bb + elif aascore>0: + score*=2 + cnt+=1 + ans+=0.5**cnt +ans*=1/n +print(ans)" +p02556,s346096542,Wrong Answer,"n=int(input()) +r=[] +for _ in range(n): + a,b=map(int,input().split()) + r.append([a+b,[a,b]]) +r=sorted(r,reverse=True,key=lambda x:x[0]) +print(abs(r[0][1][0]-r[-1][1][0])+abs(r[0][1][1]-r[-1][1][1]))" +p03328,s387776004,Wrong Answer,"a, b = map(int, input().split()) + +print((b-a)*(b-a + 1)/2 - b) +" +p02743,s662757025,Accepted,"from decimal import Decimal +a,b,c = map(Decimal,input().split()) +x = Decimal(0.5) +if a**x+b**x < c**x: + print(""Yes"") +else: + print(""No"")" +p03317,s906906416,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +ans = 1 +n -= k +k -= 1 + +if n % k == 0: + ans += n // k +else: + ans += n // k + 1 + +print(ans) +" +p02660,s309370079,Wrong Answer,"n=int(input()) +p=1 +while p<1e6: + c=t=0;p+=1 + while n%p<1:n/=p;x=c==t;t+=x;c+=1-t*x +print(t+1-(n<2))" +p03206,s572042098,Accepted,"D = input() + +if D == '25': + print('Christmas') +elif D == '24': + print('Christmas Eve') +elif D == '23': + print('Christmas Eve Eve') +elif D == '22': + print('Christmas Eve Eve Eve') +" +p02624,s752289790,Accepted,"if __name__ == '__main__': + n = int(input().strip()) + ans = 0 + + for i in range(1, n + 1): + limit = int(n / i) + ans += limit * (limit + 1) * i / 2 + print(int(ans)) +" +p02578,s572981787,Wrong Answer,"N = int(input()) +A = map(int, input().split()) + +#current height +now = 0 +total = 0 + +for a in A: + print(""a"", a) + + if a >= now: + now = a + pass + else: + total += now - a + #print(""now"", now) + #print(""total"", total) + +print(total) +" +p03434,s515937714,Wrong Answer,"N = int(input()) +a = map(int, input().split()) + +a = sorted(a, reverse=True) + +Alice = 0 +Bob = 0 + +if N == 3: + print((a[2] + a[0]) - a[1]) + +else: + for i in range(0,N-1,2): + Alice += a[i] + Bob += a[i+1] + + print(Alice-Bob) + +" +p02682,s831867917,Accepted,"a, b, c, k = map(int, input().split()) + +if a >= k: + print(k) +elif a < k <= a+b: + print(a) +elif a+b < k <= a+b+c: + print(a-(k-a-b)) " +p03617,s714294329,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) +ans = (N // 2) * min(Q*8, H*4, S*2, D) + (N % 2) * min(Q*4, H*2, S) +print(ans)" +p03323,s204320671,Wrong Answer,"import sys +input = sys.stdin.readline +A,B = [int(i) for i in input().split()] +ans = ""Yay!"" +if A > 8 and B > 8 : + ans = "":("" +print(ans)" +p03785,s421846773,Wrong Answer,"import bisect + +N, C, K = map(int,input().split()) + +T = [0]*N +for i in range(N): + T[i] = int(input()) +T.sort() + +ans = 0 +left = 0 +while True: + if left >= N: + break + #print(""T[left]"",T[left]) + ind = bisect.bisect_left(T, T[left]+K) + #print(""ind"",ind) + left = min(ind,left+C) + ans += 1 + #print(""left"",left) + +print(ans)" +p02629,s968348550,Accepted,"# import sys +# readline = sys.stdin.readline +# generator = (readline().strip() for _ in range(N)) + +# N, M = map(int, input().split()) +# As = list(map(int, input().split())) +# queries = (input() for _ in range(N)) + + +def solve(): + N = int(input()) + v = N + + ans = '' + + while v > 0: + d, m = divmod(v, 26) + if m == 0: + d -= 1 + m = 26 + ans = chr(m + 96) + ans + v = d + + return ans + + +def main(): + print(solve()) + + +if __name__ == ""__main__"": + main() +" +p03038,s512311859,Accepted,"from collections import Counter + +N, M = [int(_) for _ in input().split()] +A = [int(_) for _ in input().split()] + +BC = [tuple([int(_) for _ in input().split()]) for _ in range(M)] + +X = Counter(A) +for a in X: + BC.append((X[a], a)) +BC.sort(key=lambda x: x[1], reverse=True) + +ans = 0 +k = N +for b, c in BC: + v = min(k, b) + ans += v * c + k -= v + +print(ans) +" +p02682,s012499518,Accepted,"A, B, C, K = map(int, input().split()) +if(A >= K): print(K) +elif(A + B >= K): print(A) +else: print(A - (K - (A + B)))" +p03317,s604795954,Wrong Answer,"import numpy as np +N,K = map(int,input().split()) +an = list(map(int,input().split())) + +min_an_index = np.argmin(an) + +a = min_an_index +b = N - min_an_index - 1 + +if K < a: + b -= K - b +if K < b: + a -= K - a + +a1 = a // (K-1) +if a % (K-1) != 0: + a1 += 1 + +b1 = b // (K-1) +if b % (K-1) != 0: + b1 += 1 + +count = a1 + b1 +print(count)" +p03785,s917892232,Wrong Answer,"N, C, K = [int(x) for x in input().split()] + +times = [int(input()) for x in range(N)] +times.sort() + +count = 0 +prev = None +passenger = 0 + +for t in times: + passenger += 1 + if passenger == C: + count += 1 + passenger = 0 + elif prev is not None: + if t - prev > K: + count += 1 + passenger = 1 + prev = t + +if passenger: + count += 1 + +print(count) +" +p02695,s035283186,Accepted,"import itertools + +N,M,Q = list(map(int, input().split())) +numbers = [list(map(int,input().split())) for l in range(Q)] + +#print(numbers) + + +suuretus = itertools.combinations_with_replacement(range(1, M+1), N) + +ans = 0 +for suuretu in suuretus: + tmp = 0 + + if len(suuretu) == N: +# print(suuretu) + for number in numbers: + if suuretu[number[1]-1] - suuretu[number[0]-1] == number[2]: + tmp += number[3] + + ans = max(ans, tmp) +# print(ans) + +print(ans)" +p03252,s078424358,Accepted,"ch = list(""abcdefghijklmnopqrstuvwxyz"") + +s = list(input()) +t = list(input()) +import numpy as np + +s = np.array(s) +t = np.array(t) + +flag = True +for i in ch: + t_temp = (t[s == i]) + s_temp = (s[t == i]) + if len(set(t_temp)) > 1 or len(set(s_temp)) > 1: + flag = False + +if flag:print(""Yes"") +else:print(""No"")" +p02723,s954473959,Accepted,"S = input() +if S[2] == S[3] and S[4] == S[5]: + print(""Yes"") +else: + print(""No"")" +p03962,s104948050,Accepted,"a, b, c = map(int, input().split()) +if a == b and b == c: + print(1) +elif a != b and b != c and c != a: + print(3) +else: + print(2)" +p03281,s137946489,Accepted,"import sys +import itertools +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N = int(read()) +ans = 0 +for i in range(1,N+1,2): + count = 0 + for j in range(1,i+1): + if i % j ==0: + count += 1 + if count == 8: + ans += 1 +print(ans)" +p02811,s120164874,Accepted,"N,X = map(int,input().split()) + +if N*500 >= X: + print(""Yes"") +else: + print(""No"")" +p04033,s633943321,Accepted,"a,b = map(int,input().split()) + +if a*b <= 0: + print(""Zero"") +elif a > 0: + print(""Positive"") +else: + if(b-a)%2 == 0: + print(""Negative"") + else: + print(""Positive"") +" +p03680,s015438586,Accepted,"n = int(input()) + +a = [int(input()) for i in range(n)] + +ans = 0 +var = 0 + +for i in range(n): + var = a[var]-1 + if var == 1: + ans = i+1 + break +if ans == 0: + ans = -1 +print(ans)" +p03163,s822909248,Accepted,"n,w=map(int, input().split()) +g=[0] +v=[0] +for i in range(n): + G,V=map(int, input().split()) + g.append(G) + v.append(V) + +dp=[[0]*(w+1) for i in range(n+1)] + +for i in range(1,n+1): + for j in range(w+1): + if j-g[i]>=0:dp[i][j]=max(dp[i-1][j],dp[i-1][j-g[i]]+v[i]) + else:dp[i][j]=dp[i-1][j] + +print(dp[n][w])" +p02879,s814158877,Wrong Answer,"a,b = map(int,input().split()) +if a > 10 or b > 10: + print(-1) +else: + print(a * b)" +p02783,s445656401,Wrong Answer,"a,b=map(int,input().split()) + +print(a//b+1) + +" +p03759,s731754233,Accepted,"a,b,c=map(int,input().split()) + +if b-a==c-b: + print(""YES"") +else: + print(""NO"")" +p02731,s745000334,Accepted,"import sys +input = sys.stdin.readline + +l = int(input()) +ans = (l / 3) ** 3 +print(ans) +" +p03319,s720078615,Accepted,"import math +n, k = map(int, input().split()) +li = list(map(int, input().split())) +print(math.ceil((n-1)/(k-1)))" +p02664,s761178669,Accepted,"S = list(input().strip()) +n = len(S) +for i in range(n): + if S[i] == '?': + S[i] = 'D' +print(''.join(S))" +p02909,s066478858,Wrong Answer,"weather=[""Sunny"",""Cloudy"",""Rainy""] +print(chr(1+(weather.index(input()))))" +p03760,s296799709,Wrong Answer,"o=list(input()) +print(o) +e=list(input()) +print(e) +for x,y in zip(o,e):print(x+y,end="""") +" +p02553,s932562796,Accepted,"a, b, c, d = map(int, input().split()) + +result = -10**18 +for x in [a, b]: + for y in [c, d]: + result = max(x * y, result) +print(result) +" +p03162,s445889589,Accepted,"N = int(input()) +happy = [[0, 0, 0]] +for _ in range(N): + happy.append(list(map(int, input().split()))) + +dp = [[0, 0, 0] for _ in range(N+1)] + +for i in range(1,N+1): + for today in range(3): + for yesterday in range(3): + if today == yesterday: continue + + dp[i][today] = max(dp[i][today], dp[i-1][yesterday] + happy[i][today]) + +print(max(dp[N][0], dp[N][1], dp[N][2]))" +p02684,s558082460,Accepted,"n,k=map(int,input().split()) +mati=list(map(int,input().split())) +count=0 +i=mati[0] +matidic={} +frag=1 +while frag: + count+=1 + + if i in matidic: + frag=0 + bef=matidic[i] + roop=count-bef + + else: + matidic[i]=count + i = mati[i - 1] + +#print(roop,bef,matidic) +#print(k%roop) +if bef0: + print(""Yes"") + else: + print(""No"")" +p02842,s141807465,Accepted,"N = int(input()) +for i in range(1,50001): + if i*108//100 == N: + print(i) + exit() +print(':(')" +p02748,s578038083,Accepted,"A,B,M=map(int,input().split()) +L_A=list(map(int,input().split())) +L_B=list(map(int,input().split())) +ans=min(L_A)+min(L_B) +for i in range(M): + X,Y,Z=map(int,input().split()) + ans=min(ans,(L_A[X-1]+L_B[Y-1]-Z)) +print(ans)" +p02682,s112873701,Wrong Answer,"A, B, C, K = map(int, input().split()) + +ans = 0 + +if A >= K: + print(K) +elif A + B >= K: + print(A) +else: + print(A - K)" +p02761,s188307354,Accepted,"N,M=map(int, input().split()) + +sc = [] +for i in range(M): + sc.append(list(map(int, input().split()))) +for i in range(10**N): + ans = str(i) + if len(ans) == N and all(ans[s-1] == str(c) for s,c in sc): + print(ans) + quit() +print(-1) +" +p02899,s796783746,Accepted,"N = int(input()) +A = list(map(int,input().split())) +ans = [0]*N + +for i in range(N): + tmp = A[i] + ans[tmp-1] = i + +for j in range(N): + ans[j] += 1 + +print(*ans) +" +p03219,s539291241,Wrong Answer,"X, Y = map(int, input().split()) +print(X+Y/2)" +p02571,s691598410,Accepted,"s=input() +t=input() +ans=1000 +for i in range(len(s)-len(t)+1): + cnt=0 + for j in range(len(t)): + if s[i+j]!=t[j]: + cnt+=1 + ans=min(ans,cnt) +print(ans)" +p02622,s428596542,Wrong Answer,"a=[input() for i in range(2)] +P=a[0] +S=a[1] +count=0 +for t in range(0,len(P)-1): + if P[t] == S[t]: + count=count+1 +print(count)" +p02731,s950535539,Accepted,"L = int(input()) + +ans = (L / 3) ** 3 +print(ans)" +p02873,s476171497,Wrong Answer,"def compute_score(sub): + max_i = max(sub) + min_i = min(sub) + score = max_i * (max_i + 1) * (1 /2) + min_i * (min_i - 1) * (1/2) + return score + +S = input() +sub = [0, 0] +ans = 0 +flag = False +for s in S: + if s == '<' and flag: + ans += compute_score(sub) + sub = [0, 0] + flag = False + if s == '>': + flag = True + if s == '<': + sub[0] += 1 + else: + sub[1] += 1 +ans += compute_score(sub) +print(ans)" +p02732,s722139573,Accepted,"def main(): + n = int(input()) + a = list(map(int,input().split())) + d = {} + for i in range(n): + if d.get(a[i]) == None: + d[a[i]] = 1 + else: + d[a[i]] += 1 + ans = 0 + for k in d.keys(): + ans += d[k] * (d[k]-1) //2 + for i in range(n): + print(ans - ((d[a[i]]*(d[a[i]]-1))//2 - (d[a[i]]-1) * (d[a[i]]-2)//2)) + +if __name__ == ""__main__"": + main() +" +p02676,s212724997,Accepted,"def main(): + K, S = open(0).read().split() + K = int(K) + + ans = '' + len_S = len(S) + if len_S <= K: + ans = S + else: + ans = S[:K] + '.' * 3 + + print(ans) + return(ans) + + +if __name__ == '__main__': + main() +" +p03493,s980393601,Accepted,"a=str(input()) +sum=0 +if a[0]==""1"": + sum+=1 +if a[1]==""1"": + sum+=1 +if a[2]==""1"": + sum+=1 +print(sum)" +p02571,s493567414,Accepted,"s = input() +t = input() +x = len(s)-len(t) +ans = 10**9 +for i in range(x+1): + cnt = 0 + for j in range(len(t)): + if s[i+j] != t[j]: + cnt += 1 + ans = min(ans, cnt) +print(ans)" +p02854,s515371422,Accepted,"N = int(input()) +A = list(map(int, input().split())) +total = sum(A) +mid = total // 2 +sum_left, sum_left2 = 0, 0 +seperation_i = 0 +for i, l in enumerate(A[:-1]): + sum_left += l + if sum_left >= mid: + seperation_i = i + sum_left2 = sum_left - l + break +sum_right, sum_right2 = sum(A[seperation_i + 1:]), sum(A[seperation_i:]) +print(min(abs(sum_right - sum_left), abs(sum_right2 - sum_left2)))" +p02817,s774168386,Accepted,"S, T = map(str, input().split()) +print(T+S)" +p02675,s936399565,Wrong Answer,"n = str(input()) +print(n[-1]) + + +if n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1]=='9': + print('hon') +elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8': + print('pon') +else: + print('bon') + +" +p02861,s996744223,Accepted,"#import numpy as np +import sys +import math +from collections import defaultdict +import itertools +read = sys.stdin.buffer.read +readline = sys.stdin.readline +readlines = sys.stdin.buffer.readlines + +N = int(input()) +coordinate = [] +[coordinate.append(list(map(int,input().split()))) for _ in range(N)] + +ans = 0 +fa = 0 + +for x in list(itertools.permutations( [i for i in range(1,N+1)] , N)): + for i in range(N-1): + xx = coordinate[x[i]-1][0] - coordinate[x[i+1]-1][0] + y = coordinate[x[i]-1][1] - coordinate[x[i+1]-1][1] + ans += math.sqrt(xx**2 + y ** 2) + fa += 1 +print(ans/fa) + +" +p02633,s264040847,Accepted,"import math +n=int(input()) +print(int(360/math.gcd(n,360)))" +p03639,s601393700,Accepted,"n = int(input()) +a = list(map(int, input().split())) +x1 = [] +x2 = [] +x4 = [] +for i in range(n): + if a[i] % 4 == 0: + x4.append(a[i]) + elif a[i] % 2 == 0: + x2.append(a[i]) + else: + x1.append(a[i]) +if len(x2) == 0: + if len(x1) <= len(x4)+1: + print(""Yes"") + else: + print(""No"") +else: + if len(x1) <= len(x4): + print(""Yes"") + else: + print(""No"")" +p03408,s786591410,Accepted,"n = int(input()) +s = [] +for i in range(n): + s.append(input()) + +m = int(input()) +t = [] +for i in range(m): + t.append(input()) + +count = 0 +for i in range(n): + count = s.count(s[i]) - t.count(s[i]) if count < s.count(s[i]) - t.count(s[i]) else count +print(count)" +p03679,s386218537,Accepted,"X, A, B = map(int, input().split()) +if B <= A: + print('delicious') +elif B <= A + X: + print('safe') +else: + print('dangerous')" +p02797,s474369478,Accepted,"from sys import stdin +N,K,S = [int(x) for x in stdin.readline().rstrip().split()] + +if S == 10**9: + ans = [S]*K + [1]*(N-K) +else: + ans = [S]*K + [S+1]*(N-K) +for i in ans: + print(i,end="" "")" +p03285,s371836718,Accepted,"n = int(input()) +a = n // 4 +b = n // 7 +flag = 0 +for i in range(a+1): + for j in range(b+1): + if (i*4+j*7)==n: + flag = 1 +if flag==1: + print(""Yes"") +else: + print(""No"") +" +p04012,s254277069,Accepted,"from collections import Counter +w = [c for c in str(input())] +ans = 'Yes' +for k, v in Counter(w).items(): + if v % 2 == 1: + ans = 'No' + break +print(ans)" +p02820,s687119677,Accepted,"n, k = map(int, input().split()) +r, s, p = map(int, input().split()) +d = {""r"": p, ""s"": r, ""p"": s} +t = input() + +ans = 0 +prev = [""#"" for _ in range(k)] +for i, move in enumerate(t): + if prev[i%k] != move: + ans += d[move] + prev[i%k] = move + else: + prev[i%k] = ""#"" +print(ans) + " +p02761,s923348854,Wrong Answer,"#graph implementation +import math +n,m=map(int,input().split()) +ans=[0]*n +for i in range(m): + s,c=map(int,input().split()) + if ans[s-1]==0: + ans[s-1]=c + else: + if ans[s-1]>=c and c>0: + ans[s-1]=c +if ans[0]==0 and len(ans)<3: + for i in ans: + print(i,end="""") +elif ans[0]==0: + print(-1) +else: + for i in ans: + print(i,end="""") +#print(ans) +" +p03455,s734576383,Accepted,"# 1<=a,b<=10000 +# a,bは整数 + +#number = input('整数を入力してね > ') +#print (number) +a, b = map(int, input().split()) +#print(a, b) +c = a * b +#print(c) +d=c%2 +if d==0: + print('Even') +if d==1: + print('Odd')" +p02595,s494609665,Accepted,"N, D = map(int, input().split()) +res = 0 +for i in range(N): + x, y = map(int, input().split()) + if not (x ** 2) + (y**2) > D ** 2: + res += 1 +print(res)" +p03062,s662037051,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +dp = [[0,0] for i in range(n+1)] + +dp[0][0]= 0 +dp[0][1]= -10**10 + +for i in range(1,n+1): + dp[i][1]= max(dp[i-1][0]-a[i-1], dp[i-1][1]+a[i-1]) + dp[i][0]=max(dp[i-1][0]+a[i-1], dp[i-1][1]-a[i-1]) + + +print(dp[n][0])" +p04043,s892877803,Accepted,"a,b,c=map(int, input().split()) +t=0 +if a==5: + if b==5: + if c==7: + t=1 + elif b==7: + if c==5: + t=1 +elif a==7: + if b==5: + if c==5: + t=1 +if t==1: + print('YES') +else: + print('NO') + " +p02831,s156741653,Accepted,"from fractions import gcd + +a, b = map(int, input().split()) +print(a * b // gcd(a, b))" +p02860,s121259681,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 7) +read = sys.stdin.buffer.read +input = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +N = int(input()) +S = input() + +ans = ""No"" +if S[:(N//2)] == S[(N//2):]: + ans = ""Yes"" +print(ans) +" +p03059,s514270246,Wrong Answer,"a,b,t=map(int,input().split()) +for i in range(20): + if a*i < t+1: + k=i + else: + break +print(b*k)" +p02838,s409156349,Accepted,"import numpy as np + +N = int(input()) +A = np.array(list(map(int, input().split()))) +mod = 10**9+7 +ans = 0 +for i in range(60): + b1 = np.count_nonzero(A>>i&1) + ans += 2**i*b1*(N-b1) + ans %= mod +print (ans)" +p02972,s983859361,Accepted,"n = int(input()) +a = [0] + list(map(int, input().split())) + +m = 0 +b = [0] * (n + 1) + +for i in reversed(range(1, n+1)): + cnt = 0 + for j in range(i, n+1, i): + cnt += b[j] + if cnt % 2 != a[i]: + b[i] = 1 + m += 1 + +print(m) +if m > 0: + print(*[i for i, j in enumerate(b) if j == 1], sep=' ') +" +p04043,s105674391,Accepted,"S = input() +if S.count(""5"") == 2 and S.count(""7"") == 1 : + print(""YES"") +else : + print(""NO"")" +p03345,s485549983,Wrong Answer,"a,b,c,k = map(int, input().split()) + +ans = a - b + +if(k % 2 == 1): + ans = abs(ans) + +if(len(str(ans)) >= 19): + ans = 'Unfair' + +print(ans)" +p02983,s324488652,Wrong Answer,"L,R=[int(x) for x in input().strip().split()] + +ans=10**9+1 +for i in range(L,R+1,1): + if i%2019==0: + break + for j in range(L,R+1,1): + if j%2019==0: + break + + if i=1: + if n % mid == 0: + print(mid + n//mid -2) + break + mid -= 1" +p03796,s847404604,Wrong Answer,"n = int(input()) +power = 1 + +for i in range(1, n+1): + power *= i +print(power%10**9)" +p02912,s488117524,Wrong Answer,"N,M=map(int,input().split()) +*A,=map(int,input().split()) +A=sorted(A)[::-1] + +i=0 +while M: + A[i]//=2 + M-=1 + if A[i] 0: + ans *= p + ans %= M + v -= 1 + + +print(ans)" +p02910,s902968273,Accepted,"S = input() +f=0 +for i in range(len(S)): + if i%2==0 and S[i]==""L"": + print(""No"") + f+=1 + break + if i%2==1 and S[i]==""R"": + print(""No"") + f+=1 + break +if f==0: + print(""Yes"")" +p02847,s316855862,Wrong Answer,"S = input('曜日を入力してね! ') + +if S == 'SUN': + print('7') + +elif S == 'MON': + print('6') + +elif S == 'TUE': + print('5') + +elif S == 'WED': + print('4') + +elif S == 'THU': + print('3') + +elif S == 'FRI': + print('2') + +elif S == 'SAT': + print('1')" +p02935,s012228484,Accepted,"N=int(input()) +v=sorted(map(int,input().split())) +value=v[0] +for i in range(1,N): + value=(value+v[i])/2 +print(value)" +p02702,s740083620,Wrong Answer,"S = list(input()) +N = len(S) + +l = [0] * 2019 +temp = 0 +e = 1 +for i in range(N-1, -1, -1): + temp += int(S[i]) * e + temp %= 2019 + l[temp] += 1 + e *= 10 + e %= 2019 + +ans = l[0] + +for i in range(1, 2019): + ans += l[i] * (l[i]-1) // 2 + +print(ans)" +p03680,s033438912,Accepted,"import sys + +n = int(input()) +a = [int(input()) for i in range(n)] +a = [i for i in a] + + +switch = 1 + +c = 0 +while True: + switch = a[switch-1] + c += 1 + if switch == 2: + break + + if c > 10**6: + print(-1) + sys.exit() + break + +print(c)" +p02829,s823588803,Accepted,"#!/usr/bin/env python3 + +def main(): + *AB, = map(int, open(0).read().split()) + I = [1, 2, 3] + C = set(I) - set(AB) + print(list(C)[0]) + + +main()" +p03632,s756677923,Accepted,"a,b,c,d = map(int,input().split()) + +print(max(0,min(b,d)-max(a,c)))" +p03644,s816766709,Wrong Answer,"N = int(input()) +cnt_max = 0 +ans = 1 + +for i in range(1, N): + cnt = 0 + num = i + while True: + if num % 2 == 0: + cnt += 1 + num /= 2 + else: + break + if cnt_max < cnt: + cnt_max = cnt + ans = i + +print(ans) +" +p04034,s259642135,Accepted,"n, m = map(int, input().split()) + +red = [False] * n +ball = [1] * n + +red[0] = True +for _ in range(m): + x, y = map(lambda x: int(x) - 1, input().split()) + if red[x]: + red[y] = True + if ball[x] == 1: + red[x] = False + ball[y] += 1 + ball[x] -= 1 +print(len(list(filter(lambda x: x, red)))) +" +p03773,s357742837,Accepted,"A, B = map(int, input().split()) +print((A + B) % 24)" +p02778,s288646979,Accepted,"def main(): + s = input() + + sLen = len(s) + + s = 'x' * sLen + + print(s) + +if __name__ == '__main__': + main()" +p02918,s356709553,Wrong Answer,"n, k = map(int, input().split()) +s = list(input()) +count = 0 +for i in range(n-1): + if s[i] == s[i+1]: + count += 1 +count += k*2 +if count > n: + print(n) +else: + print(count)" +p02993,s432394692,Accepted,"from sys import exit +s=input() +for i in range(len(s)-1): + if s[i]==s[i+1]: + print(""Bad"") + exit() +print(""Good"")" +p02899,s157682082,Accepted,"from sys import stdin + +n = int(stdin.readline().rstrip()) +A = [int(x) for x in stdin.readline().rstrip().split()] + +ans = [0] * n + +for i, a in enumerate(A): + ans[a-1] = i+1 + +print(' '.join(map(str, ans)))" +p02958,s160669023,Wrong Answer,"N = int(input()) +*p, = map(int, input().split()) + +v = sum(1 for i,j in zip(range(1, N+1), p) if i!=j) +print(""Yes"" if v<=2 else ""No"")" +p03623,s873040668,Accepted,"x, a, b =map(int, input().split()) + +if abs(x-a) > abs(x-b): + print(""B"") +else: + print(""A"")" +p02713,s711129598,Accepted,"from math import gcd +k=int(input()) +ans=0 +for i in range(1,k+1): + for j in range(1,k+1): + ans_=gcd(i,j) + for l in range(1,k+1): + ans+=gcd(ans_,l) +print(ans)" +p02639,s855211465,Accepted,"x = list(map(int, input().split())) +print(x.index(0)+1) +" +p02747,s089558690,Accepted,"print('No' if input().replace('hi','') != '' else 'Yes')" +p03013,s836176100,Accepted,"N, M = map(int, input().split()) +a = [0] * M +for i in range(M): + a[i] = int(input()) +a.append(N+1) +mod = 1000000007 + +dp = [0] * (N + 1) +dp[0] = 1 +if a[0] == 1: + a.pop(0) +else: + dp[1] = 1 + +for i in range(2, N + 1): + if a[0] == i: + dp[i] = 0 + a.pop(0) + else: + dp[i] = (dp[i-1] + dp[i-2]) % mod + +print(dp[N]) +" +p02787,s314226466,Accepted,"h,n,*t = map(int,open(0).read().split()) + +dp = [0] + [10**8]* h + +for a,b in zip(*[iter(t)]*2): + for life_point in range(h +1): + + original_life = max(0,life_point - a) +# print(original_life) + magic_consum = dp[original_life]+ b +# print(magic_consum) + dp[life_point] = min(dp[life_point],magic_consum) +# print(dp) +print(dp[h])" +p03997,s660370639,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) +print((a+b)*h/2)" +p02958,s971082091,Wrong Answer,"n = int(input()) +p = [int(i) for i in input().split()] +count = 0 +for i in range(len(p)): + if i != p[i]: + count += 1 +if count <= 2: + print('YES') +else: + print('NO')" +p02771,s506436079,Wrong Answer,"data = input().split() + +a = int(data[0]) +b = int(data[1]) +c = int(data[2]) + +if a == b != c or b == c != a or a == c != b: + ans = ""Yes"" +else: + ans = ""no"" + +print(ans) +" +p03352,s985972292,Wrong Answer,"import math +a = int(input()) +mx = 0 + +for i in range(2,a): + j=2 + while i**j 1: + p[n]=1 + return p +p=prime_factorization(N) +x=0 +for v in p.values(): + y=0 + while y 0: + result += n + a[i+1] -= n + if a[i+1] < 0: + a[i+1] = 0 + +print(result)" +p02939,s883751494,Wrong Answer,"s=input() +if len(s)<=2: + print(len(set(list(s))));exit() +dp=[0]*(len(s)+ 1) +dp[0]=1 +dp[1]=1 +dp[2]=(len(set(list(s[:2])))) + +for i in range(3,1+len(s)): + dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2) +print(dp[-1])" +p02583,s334828905,Accepted,"n=int(input()) +l=list(map(int,input().split())) +l.sort() +ans=0 +for i in range(n): + for j in range(i,n): + for k in range(j,n): + if l[i]!=l[j] and l[j]!=l[k]: + if l[i]+l[j]>l[k]: + ans+=1 +print(ans)" +p02957,s054677751,Accepted,"a, b = map(int, input().split()) +if (a+b) % 2 == 0: + print((a+b) // 2) +else: + print(""IMPOSSIBLE"")" +p02777,s350683653,Accepted,"S,T=input().split() +A,B = map(int,input().split()) +U = input() +ans = """" +if U==S: + A=A-1 + a=str(A) + b=str(B) + ans = a+"" ""+b + print(ans) +else: + B-=1 + a=str(A) + b=str(B) + ans=a+"" ""+b + print(ans)" +p03095,s519335415,Accepted,"import collections +N = int(input()) +S = input() + +table = collections.defaultdict(int) +for i in range(N): + table[S[i]] += 1 +ans = 1 +mod = 10**9 + 7 +alpha = 'abcdefghijklmnopqrstuvwxyz' +for x in alpha: + ans *= table[x] + 1 + ans %= mod + +print((ans-1) % mod) +" +p02785,s174599206,Wrong Answer,"n,k = map(int, input().split()) +H = list(map(int, input().split())) +sum = 0 +l = n-k +sorted(H) +if k >= n : print(0) +else: + for i in range(l): + sum += H[i] + print(sum)" +p02768,s287339083,Accepted,"n, a, b = map(int, input().split()) +mod = 10**9 + 7 +def comb(n,k): + if n=1: + ans*=(n-k+1)%mod + for i in range(2,k+1): + inv[i]=mod-inv[mod%i]*(mod//i)%mod + ans=ans*(n-k+i)*inv[i]%mod + return ans +c = comb(n, a) +d = comb(n, b) +answer = pow(2, n, mod) - 1 +print((answer-c-d)%mod)" +p03416,s681742303,Accepted,"A,B= map(int,input().split()) + +ans=0 + +for i in range(A,B+1): + for j in range(len(str(i))): + zen = j + kou = len(str(i))-1-j + if zen >= kou: + ans+=1 + break + if str(i)[zen] != str(i)[kou]: + break + +print(ans)" +p02552,s110219107,Accepted,"x = int(input()) + +if x==0: + print(1) +else: + print(0)" +p02989,s320998317,Accepted,"n = int(input()) +d = [int(c) for c in input().split()] +e = sorted(d) +mid = n//2 +print(e[mid]-e[mid-1]) +" +p02946,s844094614,Accepted,"k,x = [int(x) for x in input().split()] +a = x-k+1 +b = x+k-1 +for i in range(a,b+1): + print(i,end="" "")" +p02714,s708916156,Wrong Answer,"from collections import Counter + +N = int(input()) +S = input() +dum = [] +mmm = [] +d = 0 +while 3 + d*2 < N: + for i in range(N - 2*(d+1)): + dum.append([S[i], S[i+d+1], S[i+2*(d+1)]]) + mmm.append([i, i+d+1, i+2*(d+1)]) + d += 1 +dum_n = len([x for x in dum if len(set(x)) == 3]) + +RGB_Counter = Counter(S) +print(RGB_Counter['R'] * RGB_Counter['G'] * RGB_Counter['B'] -dum_n)" +p02775,s274419354,Accepted,"N = input() +dp = [[0]*2 for _ in range(1001000)] +dp[0][1] = 1 +for i in range(len(N)): + d = int(N[i]) + dp[i+1][0] = min(dp[i][0] + d, dp[i][1] + 10-d) + dp[i+1][1] = min(dp[i][0] + d + 1, dp[i][1] + 10-d-1) # もらいすぎている状態を維持する +ans = dp[len(N)][0] +print(ans) +" +p03759,s350389061,Accepted,"a , b , c = map(int,input().split()) +if b - a == c - b: + print(""YES"") +else: + print(""NO"")" +p03814,s452658972,Accepted,"# https://atcoder.jp/contests/abc053/tasks/abc053_b +s = input() +a_index = s.find(""A"") +z_index = s.rfind(""Z"") +print(z_index - a_index + 1) +" +p03073,s848017028,Accepted,"data = list(input()) +count = 0 +for i in range(1, len(data)): + if data[i] == data[i-1]: + if data[i] == ""0"": + data[i] = ""1"" + else: + data[i] = ""0"" + count += 1 +print(count)" +p02578,s789493949,Accepted,"n=int(input()) +li = list(map(int,input().split())) + +now=li[0] +sum=0 +for i in li[1:]: + if now>i: + sum+=now-i + elif i>now: + now=i + +print(sum) + " +p03556,s239290581,Accepted,"n = int(input()) +i = 1 +while i * i <= n: + i += 1 +print((i - 1) * (i - 1))" +p03210,s889202988,Accepted,"x = int(input()) + +if x == 3 or x == 5 or x == 7: + print(""YES"") +else: + print(""NO"")" +p02881,s415517010,Wrong Answer,"n=int(input()) +def make_divisors(n): + lower_divisors , upper_divisors = [], [] + i = 1 + while i*i <= n: + if n % i == 0: + lower_divisors.append(i) + if i != n // i: + upper_divisors.append(n//i) + i += 1 + return lower_divisors + upper_divisors[::-1] +l=make_divisors(n) +if len(l)%2==0: + print((l[len(l)//2]+l[(len(l)//2)-1])-2) +elif len(l)%2==1: + print((l[len(l)//2-1]+l[(len(l)//2)+1])-2)" +p03679,s469839213,Wrong Answer,"x,a,b=map(int, input().split()) +date=b-a +if date<0: + print(""delicious"") +elif date<=x: + print(""safe"") +else: + print(""dangerous"")" +p02755,s614042345,Accepted,"import fractions +import sys +A,B=map(int,input().split()) + +for i in range(1,1009): + if(int(i*0.08) == A and int(i*0.1)==B): + print(i) + sys.exit() +print(-1)" +p02888,s683490937,Accepted," +n=int(input()) +l=list(map(int , input().split())) +#尺取り法 +l.sort() +s=0 +for i in range(n): + if i+2= a: + print(""Yes"") +else: + print(""No"")" +p04034,s370778601,Wrong Answer,"n,m=map(int,input().split()) +check=[False]*n +check[0]=True +ball=[1]*n +for i in range(m): + x,y=map(int,input().split()) + x-=1 + y-=1 + if check[x]: + check[y]=True + else: + continue + ball[y]+=1 + ball[x]-=1 + +ans=0 + +for i in range(n): + if ball[i]==0: + check[i]=False + +for chk in check: + if chk: + ans+=1 + +print(ans) + +" +p02933,s094717990,Accepted,"a = int(input()) +s = input() +if a >= 3200: + print(s) +else: + print(""red"")" +p02701,s386899971,Accepted,"import sys +from collections import defaultdict, Counter, deque +from itertools import accumulate, permutations, combinations +from operator import itemgetter +from bisect import bisect_left, bisect_right, bisect +from heapq import heappop, heappush +from fractions import gcd +from math import ceil, floor, sqrt, cos, sin, pi +from copy import deepcopy + +# If you use recursive call, uncomment this code +#sys.setrecursionlimit(10**6) + +def main(): + N = int(input()) + print(len(set([input() for _ in range(N)]))) + +if __name__ == '__main__': + main() +" +p03624,s426045329,Accepted,"S = list(input()) +S.sort() +l = list(""abcdefghijklmnopqrstuvwxyz"") +flag = 0 + +for i in l: + if i in S: + continue + else: + print(i) + flag = 1 + break + +if flag == 0: + print(""None"")" +p03773,s560512123,Wrong Answer,"a,b= input().split() +a,b=int(a),int(b) +if a+b <=24: + print(a+b) +elif a+b>24: + print(a+b-24)" +p02693,s636330187,Accepted,"k = int(input()) +a, b = map(int,input().split()) + +count = 0 + +for i in range(b-a+1): + if (i+a)%k == 0: + print(""OK"") + count += 1 + break + +if count == 0: + print(""NG"")" +p03555,s376448822,Accepted,"print([""NO"",""YES""][input()[::-1]==input()])" +p02705,s249780025,Accepted,"num=int(input()) +print(num*2*3.1415926535)" +p02546,s116918357,Wrong Answer,"s=input() +n=len(s) +if(n==1): + s+=""es"" + print(s) +else: + if(s[n-1]==""s""): + s+=""es"" + print(s) + else: + s+=""s"" + print(s) + " +p02847,s908571177,Wrong Answer,"S = input() + +if S == 'SUN': + print('7') +elif S == 'MON': + print('6') +elif S == 'TUE': + print('5') +elif S == 'WED': + print('4') +elif S == 'TUR': + print('3') +elif S == 'FRI': + print('2') +elif S == 'SAT': + print('1') +else: print('Error')" +p02882,s891510286,Wrong Answer,"import math +a,b,x=map(int,input().split()) +if x==a*a*b: + print(0) +elif x/2>=a*b/2: + tangent= ((a*b-x/a)*2) / a**2 + print(math.atan(tangent)*180/math.pi) +else: + tangent=(a*(b**2)) /2*x + print(math.atan(tangent)*180/math.pi) + + " +p02724,s848077957,Accepted,"# li = [[0] * 4 for i in range(3)] + +# A = list.map(int, input().split()) + +x = int(input()) + +ans = 0 +ans += (x // 500) * 1000 +temp = x % 500 +ans += (temp // 5) * 5 + +print(ans) +" +p02793,s001059339,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +MOD = 10 ** 9 + 7 + + +# 最大公約数 +def gcd(a, b): + while b: + a, b = b, a % b + return a + + +# 最小公倍数 +def lcm(a, b): + return a * b * pow(gcd(a, b), MOD - 2, MOD) + + +LCM = A[0] +for a in A: + LCM = lcm(LCM, a) +LCM %= MOD + +ans = 0 +for a in A: + ans += LCM * pow(a, MOD - 2, MOD) + ans %= MOD + +print(ans % MOD)" +p03407,s337284358,Accepted,"a,b,c=map(int,input().split()) +if a+b>=c: + print(""Yes"") +else: + print(""No"")" +p03475,s650260814,Accepted,"N=int(input()) +tmp=[list(map(int,input().split())) for i in range(N-1)] +for i in range(N-1): + time=0 + for j in range(i,N-1): + data=tmp[j] + if time12 and e>12): + print('NA') +else: + if 1<=f<=12 and e>12: + print('MMYY') + elif f>12 and 1<=e<=12: + print('YYMM') + else: + print('AMBIGUOUS') +" +p03107,s454971452,Accepted,"s=input() +n=len(s) +t=0 +for i in range(n): + if s[i]==""1"": + t+=1 +print(min(2*t,2*(n-t)))" +p02646,s113546198,Wrong Answer,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) + +if(A+V*T==B+W*T): + print(""YES"") +else: + print(""NO"")" +p02683,s406740091,Accepted,"import numpy as np +from itertools import product + +n, m, x = map(int, input().split()) +ca = np.array([list(map(int, input().split())) for _ in range(n)], dtype=""i8"") + +ans = 10 ** 20 +for bit in product([0, 1], repeat=n): + tmp = np.zeros(m + 1) + for i, j in enumerate(bit): + if j == 1: + tmp += ca[i] + f = 0 + for i in tmp[1:]: + if i < x: + f = 1 + if f == 0: + ans = min(ans, tmp[0]) + +if ans == 10 ** 20: + print(-1) +else: + print(int(ans))" +p02678,s118481773,Accepted,"from collections import deque + +n, m = map(int, input().split()) + +grid = [[] for _ in range(n + 1)] + +ans = [0] * n +visited = [False] * n +visited[0] = True + +for _ in range(m): + s, t = map(int, input().split()) + grid[s].append(t) + grid[t].append(s) + +queue = deque([1]) + +while queue: + node = queue.popleft() + for i in grid[node]: + if visited[i - 1]: + continue + visited[i - 1] = True + ans[i - 1] = node + queue.append(i) + +print('Yes') +for i in ans[1:]: + print(i)" +p02572,s193720154,Accepted,"#!/usr/bin/env python3 +N = int(input()) +A = list(map(int, input().split())) + +mod = 10 ** 9 + 7 + +s = sum(A)** 2 + +a = 0 +for i in A: + a += (i ** 2) + +ans = (s - a) // 2 +ans = ans % mod + +print(ans) +" +p02552,s483356623,Wrong Answer,"x = input() + +if x == 0: + x = 1 + +if x == 1: + x = 0 + +print(x)" +p03785,s146795208,Accepted,"N, C, K = map(int, input().split()) +T = [int(input()) for _ in range(N)] +T.sort() +s = 0 +ans = 0 +for i in range(N): + if i - s + 1 > C or T[i] - T[s] > K: + s = i + ans += 1 +print(ans+1) +" +p02790,s503985267,Wrong Answer,"a,b=map(int,input().split()) +s=0.111111111 +if a k: + print(len(a) - k) +else: + print(0)" +p02995,s016421943,Accepted,"import math +a,b,c,d=map(int,input().split()) +mc = b//c-(a-1)//c +md = b//d-(a-1)//d +cd = (c*d)//math.gcd(c,d) +mcd = b//cd - (a-1)//cd + +print(b-a+1 - mc-md+mcd) +" +p03475,s240866214,Accepted,"n = int(input()) +train = [list(map(int, input().split())) for _ in range(n-1)] + +for i in range(n): + t = 0 + for j in range(i, n-1): + c, s, f = train[j] + t = max(t, s) + t += (f - t % f) % f + t += c + print(t)" +p03059,s563189111,Accepted,"a, b, t = map(int, input().split()) +if a > t: + print(""0"") +else: + s = t//a + print(b*s)" +p02922,s219614518,Accepted,"from collections import defaultdict, deque +import sys +import heapq +import bisect +import itertools +import queue +import copy +import time +sys.setrecursionlimit(10**8) +INF = float('inf') +mod = 10**9+7 +eps = 10**-7 + +def inp(): return int(sys.stdin.readline()) + +def inpl(): return list(map(int, sys.stdin.readline().split())) + +def inpl_str(): return list(sys.stdin.readline().split()) + +a, b = inpl() +c = a-1 +d = b-1 +print((d+c-1)//c)" +p03438,s783427646,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) + +onesum=0 +twosum=0 +for i in range(n): + if(a[i]>b[i]): + onesum+=a[i]-b[i] + elif(a[i]= line2: + count += 1 + +#print(count) +if (count > M): + ans = ""Yes"" + + +print(ans)" +p02916,s726409703,Accepted,"# 問題:https://atcoder.jp/contests/abc140/tasks/abc140_a + +n = int(input()) +a = list(map(int, input().strip().split())) +b = list(map(int, input().strip().split())) +c = list(map(int, input().strip().split())) + +res = b[a[0]-1] +for i in range(1, n): + res += b[a[i]-1] + if a[i] - a[i-1] == 1: + res += c[a[i-1]-1] + +print(res) +" +p04019,s641173827,Accepted,"S = list(input()) +S = list(set(S)) + +n,w,s,e = 0,0,0,0 +for i in range(len(S)): + if(S[i] == 'N'): n = 1 + elif(S[i] == 'W'): w = 1 + elif(S[i] == 'S'): s = 1 + elif(S[i] == 'E'): e = 1 + +judge = [n,w,s,e] +if((judge == [1,0,1,0])or(judge == [0,1,0,1])or(judge == [1,1,1,1])): + print('Yes') +else: + print('No') + " +p02719,s568787968,Accepted,"a,b=map(int,input().split()) +m=a%b +if abs(b-m)= 0: + ans = min(ans, abs(r)) + if l < 0 < r: + ans = min(ans, r - l + min(abs(r), abs(l))) +print(ans) +" +p03817,s245813616,Accepted,"x=int(input()) +ans=x//11*2 +if x%11==0: + print(ans) +elif x%11<=6: + print(ans+1) +else: + print(ans+2)" +p02843,s720886359,Wrong Answer,"x=int(input()) +data=[x//105,x//104,x//103,x//102,x//101,x//100] +ans=0 +for i in range(data[0]+1): + for j in range(data[1]+1): + for k in range(data[2]+1): + for l in range(data[3]+1): + for m in range(data[4]+1): + if (x-(105*i+104*j+103*k+102*l+101*m))%100==0: + print(1) + exit() +print(0)" +p03262,s074131153,Wrong Answer,"import fractions +import math + +n,X= map(int,input().split()) +x = list(map(int, input().split())) +ins = 0 +for i in range(n): + if x[i] >=X: + ins = i + break +x.insert(ins,X) +x = sorted(x) + +print(x) + +difflis = [0] * (n) + +for i in range(n): + difflis[i] = math.fabs(x[i+1] - x[i]) + +ans = difflis[0] +for i in range(i,len(difflis)): + ans = fractions.gcd(ans,difflis[i]) +print(int(ans))" +p02880,s926687485,Wrong Answer,"N=int(input()) +no = True +for i in range(1,10): + for k in range(i,10): + if N==i*k: + print('Yes') + no = False + break +if no: + print('No') " +p02618,s396277812,Accepted,"d=int(input()) +C=list(map(int,input().split())) +S=[list(map(int,input().split())) for i in range(d)] +A=[0]*26 +for i in range(d): + cnt=[0]*26 + for j in range(26): + A[j]+=C[j] + cnt[j]=S[i][j]-A[j] + now=cnt.index(max(cnt)) + print(now+1) + A[now]=0" +p03107,s098135644,Wrong Answer,"import sys +import math +import itertools +import collections +import heapq +import re +import numpy as np +from functools import reduce + +rr = lambda: sys.stdin.readline().rstrip() +rs = lambda: sys.stdin.readline().split() +ri = lambda: int(sys.stdin.readline()) +rm = lambda: map(int, sys.stdin.readline().split()) +rl = lambda: list(map(int, sys.stdin.readline().split())) +inf = float('inf') +mod = 10**9 + 7 + + +n = ri() +s = collections.Counter(rr()) +print(min(s['0'], s['1']) * 2) + + + + + + + + + + + + + +" +p02924,s544702444,Accepted,"n = int(input()) + + +print((n-1)*(n)//2)" +p03377,s092575261,Accepted,"a,b,x = map(int, input().split()) + +if a <= x <= a+b: + print(""YES"") +else: + print(""NO"")" +p02768,s013561631,Accepted,"n, a, b = map(int, input().split()) +mod = 10**9+7 +ans = pow(2, n, mod) - 1 + +up = 1 +bo = 1 +for i in range(b): + up = up*(n-i)%mod + bo = bo*(i+1)%mod + if i == a-1: + acombs = up*pow(bo, mod-2, mod)%mod + +bcombs = up*pow(bo, mod-2, mod)%mod + +print((ans - acombs - bcombs)%mod) +" +p02970,s253753315,Wrong Answer,"n,d = map(int ,input().split()) +a = 2*d+1 + +for i in range(20): + if a*i > n: + print(i) + + break" +p02959,s687141479,Accepted,"n = int(input()) +A = list(map(int, input().split())) +B = tuple(map(int, input().split())) + +ans = 0 +for i, b in enumerate(B): + rem = max(0, b-A[i]) + ans += min(A[i], b) + ans += min(A[i+1], rem) + A[i+1] = max(0, A[i+1]-rem) + +print(ans) +" +p04031,s487800791,Accepted,"n = int(input()) +a = list(map(int, input().split())) +ans = 10**9 +for ai in range(min(a), max(a)+1): + w = 0 + for aj in a: + w += (ai - aj)**2 + ans = min(w, ans) +print(ans)" +p02641,s579663561,Accepted,"X, N = map(int,input().split()) +Ps = set(map(int, input().split())) +for i in range(N+1): + if (X-i) not in Ps: + print(X-i) + exit() + elif (X+i) not in Ps: + print(X+i) + exit() +" +p02948,s760937756,Accepted,"# coding: utf-8 +import heapq +n, m = map(int, input().split()) +jobs = [[] for i in range(m)] +for i in range(n): + a, b = map(int, input().split()) + if a > m: + continue + jobs[m-a].append(b) +ans = 0 +l = [] +for i in range(m-1, -1, -1): + for j in jobs[i]: + heapq.heappush(l, -j) + if len(l): + ans += -heapq.heappop(l) +print(ans)" +p02790,s180161348,Wrong Answer,"a, b = map(int, input().split()) +if a == b: + print(str(a) * 7) +elif a > b: + print(str(b) * a) +else: + print(str(a) * b)" +p03251,s973225074,Accepted,"N, M, X, Y = map(int, input().split()) + +cities_x = [int(x) for x in input().split()] +cities_y = [int(x) for x in input().split()] + +max_x = max(X, max(cities_x)) +min_y = min(Y, min(cities_y)) + +if min_y - max_x >= 1: + print('No War') +else: + print('War') +" +p02779,s969139116,Accepted,"n=(int)(input()) +a=sorted(list(map(int, input().split("" "")))) +for i in range(n-1): + if a[i] == a[i + 1]: + print(""NO"") + break +else: + print(""YES"")" +p02953,s347801164,Accepted,"N = int(input()) +hh = list(map(int, input().split())) + +for i in range(1, N): + if hh[i - 1] == hh[i]: + continue + else: + hh[i] -= 1 + if hh[i - 1] > hh[i]: + print(""No"") + exit() + +print(""Yes"") +" +p03435,s064842057,Accepted,"c = [list(map(int,input().split())) for _ in range(3)] +a = [] +b = [] +for i in range(3): + a.append(abs(c[i][0]-c[i][1])) + a.append(abs(c[i][1]-c[i][2])) +for i in range(3): + b.append(abs(c[0][i]-c[1][i])) + b.append(abs(c[1][i]-c[2][i])) +if a[0] == a[2] and a[2] == a[4] and b[0] == b[2] and b[2] == b[4] \ + and a[1] == a[3] and a[3] == a[5] and b[1] == b[3] and b[3] == b[5]: + print('Yes') + exit() +print('No') +" +p02823,s362031299,Wrong Answer,"def main(): + n, a, b = map(int, input().split()) + + if abs(a-b) % 2 == 0: + ans = abs(a-b) // 2 + else: + ans = min(n - a, b - 1) + + print(ans) + +if __name__ == '__main__': + main()" +p02854,s489661410,Accepted,"N = int(input()) +A = list(map(int,input().split())) +ans = 10**18 +left = 0 +right = sum(A) +for i in range(N): + ans = min(ans, abs(left-right)) + left += A[i] + right -= A[i] +print(ans)" +p02983,s665362787,Accepted,"def solve(): + N, M = map(int, input().split()) + m = 10 ** 9 + for i in range(N, min(N+2019, M)): + for j in range(N+1, min(N+2019, M)+1): + m = min(m, i * j % 2019) + return m + +print(solve())" +p02546,s978593168,Accepted,"#import +s=input() +#=int(input()) +#=map(int,input().split()) +#=list(map(int,input().split())) +#=[list(map(int,input().split())) for _ in range()] + +if s[-1] == 's': + print(s + 'es') +else: + print(s + 's')" +p03038,s435210183,Wrong Answer,"n,m=map(int,input().split()) +a=list(map(int,input().split())) +a.sort() +x=[] +for i in range(m): + b,c=map(int,input().split()) + x.append([b,c]) +y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True) + +p=0 +q=0 +for i in range(n): + if a[i]B: + B*=2 + continue + if B>C: + C*=2 + continue + if C>B and B>A: + flag=False + break +if C>B and B>A: + flag=False +print('Yes' if flag==False else ""No"")" +p03161,s545673021,Accepted,"n, k = map(int, input().split()) +step = list(map(int, input().split())) + +ans = [float('inf')]*(10**6) + +ans[0] = 0 +def dp(n): + for i in range(n): + for j in range(k+1): + if i+j < n: + ans[i+j] = min(ans[i+j], ans[i] + abs(step[i+j] - step[i])) + return ans[n-1] + +print(dp(n))" +p02910,s806400698,Wrong Answer,"S = input() +#list = S.split() +print(S) +flg = True +for s in range(0,len(S)-1): + print(s) + if s%2 == 0 and S[s] == ""L"": + flg = False + elif s%2 != 0 and S[s] == ""R"": + flg = False + +if flg: + print(""Yes"") +else: + print(""No"") +" +p03030,s775767307,Wrong Answer,"n = int(input()) + +res = [] +for i in range(n): + city, value = input().split() + value = int(value) + res.append([city, value, i]) +res_s = sorted(res, key = lambda x: (x[0], -x[1])) +for i in range(n): + print(res_s[i][2]) +" +p03821,s644611965,Accepted,"def solve(): + n = int(input()) + a = [] + b = [] + for _ in range(n): + A, B = map(int, input().split()) + a.append(A) + b.append(B) + + ans = b[-1] - a[-1]%b[-1] + if a[-1]%b[-1] == 0: ans = 0 + + for i in range(1, n): + c = a[-(i+1)]+ans + + if c%b[-(i+1)] == 0: continue + + dis = b[-(i+1)]-c%b[-(i+1)] + ans += dis + + return ans + + +print(solve()) +" +p03659,s796851794,Wrong Answer,"n = int(input()) +a = [int(x) for x in input().split()] + +l = [0]*n +l[0] = a[0] - sum(a[1:]) + +for i in range(1,n): + if a[i] >= 0: + l[i] = l[i-1] + (2 * a[i]) + else: + l[i] = l[i-1] - (2 * a[i]) + +abs_l = [abs(x) for x in l] +print(min(abs_l))" +p02602,s770562728,Accepted,"from collections import deque +N,K = map(int,input().split("" "")) +q = deque() +line = input().split("" "") +for i in range(K): + q.append(int(line[i])) +for i in range(K,N): + x = q.popleft() + y = int(line[i]) + if x < y: + print(""Yes"") + else: + print(""No"") + q.append(y)" +p03331,s219504588,Accepted,"def calc_sum_of_digits(num): + ans = 0 + + while True: + if num // 10 == 0: + ans += num + break + + ans += num % 10 + num //= 10 + + return ans + + +def main(): + N = int(input()) + min_sum = 1000 + + for A in range(1, N): + B = N - A + + A_sum = calc_sum_of_digits(A) + B_sum = calc_sum_of_digits(B) + + if A_sum + B_sum < min_sum: + min_sum = A_sum + B_sum + + print(min_sum) + + +if __name__ == ""__main__"": + main()" +p03679,s716154680,Accepted,"x,a,b=map(int,input().split()) +if b<=a: + print('delicious') +elif b<=a+x: + print('safe') +else: + print('dangerous')" +p02572,s847728211,Accepted,"n = int(input()) +a = list(map(int, input().split())) +mod = 10 ** 9 + 7 + +ans = (sum(a) % mod) ** 2 +for i in range(n): + ans -= a[i] ** 2 + ans %= mod +if ans % 2 == 0: + print(ans // 2) +else: + print((ans + mod) // 2)" +p03282,s807092318,Wrong Answer,"import sys +S = input() +K = int(input()) + +if len(S) == 1: + print(S) + sys.exit() + +for i in range(0,K): + if S[i] == ""1"": + pass + else: + print(S[i]) + sys.exit()" +p02693,s514252605,Accepted,"n = int(input()) +a, b = map(int, input().split()) +ans = 0 +for i in range(a, b + 1): + if i % n == 0: + ans += 1 + break +print(""OK"" if ans == 1 else ""NG"")" +p02862,s321963347,Wrong Answer,"fac = [0] * 700000 +finv = [0] * 700000 +inv = [0] * 700000 +mod = 1000000007 + +fac[0] = fac[1] = 1 +finv[0] = finv[1] = 1 +inv[1] = 1 +for i in range(2, 700000): + fac[i] = fac[i - 1] * i % mod + inv[i] = mod - inv[mod % i] * (mod // i) % mod + finv[i] = finv[i - 1] * inv[i] % mod + +x, y = map(int, input().split()) + +if (x + y) % 3 == 0: + k = (2 * x - y) // 3 + l = (2 * y - x) // 3 + print(fac[k + l] * (finv[k] * finv[l] % mod) % mod) +else: + print(0) +" +p03455,s536440542,Accepted,"a,b = map(int,input().split()) + +if a*b%2 == 1: + print(""Odd"") +else: + print(""Even"")" +p02613,s010876941,Accepted,"dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} +N = int(input()) +for i in range(N): + dic[input()] += 1 +for i in dic: + print(i, 'x', dic[i])" +p02714,s117864639,Accepted,"N = int(input()) +S = input() + +num_R = len([c for c in S if c == ""R""]) +num_G = len([c for c in S if c == ""G""]) +num_B = len([c for c in S if c == ""B""]) + +total = num_R * num_G * num_B + +count = 0 +for i in range(0, N - 2): + for j in range(i, N - 1): + k = (j - i) + j + if k < N: + if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]: + count += 1 + +print(total - count)" +p03472,s972394481,Wrong Answer,"from collections import deque +N,H = map(int,input().split()) +A=[] +B=[] +d=deque() +max_axe = 0 +max_throw = 0 +ans=0 +for i in range(N): + a,b = map(int,input().split()) + A.append(a) + B.append(b) + +A.sort(reverse=True) +B.sort(reverse=True) + +for i in B: + if i>=A[0]: + H-=i + ans+=1 + else: + break + +ans+=int(-(-H//A[0])) + +print(ans)" +p02584,s064957362,Accepted,"X,K,D=map(int,input().split()) +X=max(X,-X) + +mostL=X-K*D +if 0<=mostL: + print(mostL) +else: + K-=X//D + X%=D + if K%2==1: + print(abs(X-D)) + else: + print(X) + + +" +p03625,s108215967,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +A_sorted = sorted(A, reverse=True) + +counter = 0 +edge1 = 0 +edge2 = 0 +flag = 0 +for i in range(len(A_sorted)-1): + if edge1 == 0 and A_sorted[i] == A_sorted[i+1]: + edge1 = A_sorted[i] + flag = 1 + if flag == 1 and A_sorted[i] != edge1 and A_sorted[i] == A_sorted[i+1]: + edge2 = A_sorted[i] + break +print(edge1*edge2) +" +p03485,s121873764,Accepted,"n = input() +n = n.split("" "") +n = list(map(int, n)) +a = n[0] +b = n[1] + +var_ = -(-(a + b) // 2) +print(var_)" +p02983,s845648678,Wrong Answer,"L, R = map(int, input().split()) +ans = 2019 +if R - L >= 2019: + print(0) +else: + for i in range(L, R + 1): + for j in range(L + 1, R + 1): + ans = min(ans, (i * j) % 2019) + print(ans) +" +p03360,s387599390,Accepted,"*ABC, = map(int, input().split()) +K = int(input()) + +biggest = ABC.index(max(ABC)) +ans = sum(ABC) - ABC[biggest] + ABC[biggest] * 2 ** K + +print(ans) +" +p03481,s123217284,Wrong Answer,"import math +X,Y=map(int,input().split()) +key=Y//X +ans=math.floor(math.log2(key)) +print(ans+1)" +p02630,s865501339,Accepted,"n=int(input()) +#a,b=map(int,input().split()) +al=list(map(int,input().split())) +#l=[list(map(int,input().split())) for i in range(n)] +q=int(input()) +dic={} +for a in al: + dic[a]=dic.get(a,0)+1 + +total=sum(al) +ansl=[] +for i in range(q): + b,c=map(int,input().split()) + b_num=dic.get(b,0) + total=total+b_num*(c-b) + ansl.append(total) + dic[b]=0 + dic[c]=dic.get(c,0)+b_num + +for ans in ansl: + print(ans) +" +p03543,s990858700,Accepted,"s = input() +if s[1] == s[2] and (s[0] == s[1] or s[2] == s[3]): + print('Yes') +else: + print('No')" +p03799,s892196969,Accepted,"N,M=map(int,input().split()) +print((2*min(N,M//2)+M)//4) +" +p03351,s021205005,Accepted,"a,b,c,d=map(int,input().split()) +if (abs(b-a)<=d and abs(c-b)<=d) or abs(c-a)<=d: + print(""Yes"") +else: + print(""No"")" +p03013,s693307928,Wrong Answer,"n,m = map(int, input().split()) +A = [int(input()) for i in range(m)] +if m == 0: + Fib = [1,2] + for i in range(2,n): + Fib.append(Fib[i-2]+Fib[i-1]) + print(Fib) + print(Fib[n-1]%1000000007) + exit() + +B = [A[i+1]- A[i] for i in range(m-1)] +B.insert(0,A[0]+1) +B.append(n+1-A[m-1]) + +M = max(A) + +Fib = [0,1] +for i in range(2,M+10): + Fib.append(Fib[i-2]+Fib[i-1]) + +ans = 1 +for i in range(len(B)): + ans = (ans * Fib[B[i]-1])%1000000007 + +print(ans) +" +p02629,s140614958,Accepted,"n=int(input()) +T='abcdefghijklmnopqrstuvwxyz' +s='' +while n>0: + sn=n%26 + if sn>0: + s=T[sn-1]+s + n//=26 + else: + s=T[25]+s + + n=n//26-1 + +print(s)" +p02829,s741248576,Accepted,"# from collections import Counter, defaultdict +# n = int(input()) +# li = list(map(int, input().split())) +# n = int(input()) +# a, b, c = map(int, input().split()) +# d = defaultdict(lambda: 0) +s = set([1, 2, 3]) +s.discard(int(input())) +s.discard(int(input())) +print(*s)" +p03107,s639229016,Accepted,"s = input() +cnt_1 = 0 + +for i in s: + if i == '1': + cnt_1 += 1 + +print(min(cnt_1, len(s) - cnt_1) * 2)" +p03438,s737493772,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +def check(A,B): + plus,minus = 0,0 + for i in range(N): + diff = B[i]-A[i] + if diff>0: + plus += diff//2 + else: + minus -= diff + if plus >= minus: + return True + return False + +if check(A,B): + print('Yes') +else: + print('No')" +p03131,s124491327,Wrong Answer,"k,a,b=map(int,input().split()) +if b 0 else ans) +" +p02881,s668183896,Wrong Answer,"N=int(input()) +can=[] +for i in range(1,int(N**0.5)+1): + if N%i==0: + can.append(N-1+N//i-1) + + +print(min(can)) +" +p03136,s491134728,Accepted,"N = int(input()) +L = list(map(int,input().split())) +L.sort() +a = L[-1] +b = sum(L[:-1]) +if a < b: + print(""Yes"") +else: + print(""No"")" +p02571,s386891456,Wrong Answer,"s=list(str(input())) +t=list(str(input())) +ch=len(t) +for i in range(len(s)-len(t)): + temp=0 + for j in range(len(t)): + if(s[i+j]!=t[j]): + temp+=1 + if(tempn: + print(-1) + else: + print(cnt+1) " +p03672,s971867317,Wrong Answer,"from collections import Counter +s=input()[::-1] +for i in range(1,len(s)): + if all([1 if i%2==0 else 0 for i in Counter(s[i:]).values()]): + print(len(s[i:])) + break" +p03136,s258956799,Wrong Answer,"input_angle = int(input()) +input_length = input() + +length = input_length.split(' ') +length.sort() +sum = 0 + +for i in range(input_angle-1): + sum += int(length[i]) + +if sum > int(length[-1]): + print('Yes') +else: + print('No')" +p03339,s482745973,Wrong Answer,"N = int(input()) + +S = list(input()) + +ans = [0]*N +ans[0] = S.count(""E"") + +for i in range(1, N): + ans[i] += (ans[i-1] + int(S[i-1]==""W"") - int(S[i]==""E"")) + +print(min(ans)) " +p03817,s808271051,Wrong Answer,"n=int(input()) +print(n//11*2+(n%11>0)+(n%11>5))" +p02577,s509430945,Wrong Answer,"num = input() + +count = 0 +for i in range(len(num)): + count += int(num[i]) + +if count % 9 == 0: + print('yes') +else: + print('no')" +p02607,s776899029,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +cnt = 0 +for i in range(1, n, 2): + if a[i] % 2 == 1: + cnt += 1 +print(cnt)" +p03455,s596342434,Accepted,"a, b = map(int, input().split()) +if (a*b)%2 == 1: + print('Odd') +else: + print('Even') +" +p03448,s773873735,Accepted,"a=int(input()) +b=int(input()) +c=int(input()) +x=int(input()) +ans = 0 +for i in range(a+1): + for j in range(b+1): + for k in range(c+1): + ans += 1 if 500*i+100*j+50*k==x else 0 +print(ans)" +p02571,s865603580,Accepted,"s = input() +t = input() +S = [c for c in s] +T = [c for c in t] +m = len(T) +for i in range(len(S)-len(T)+1): + temp = 0 + for j in range(i,i+len(T)): + if S[j] != T[j-i]: + temp += 1 + if temp (a**2)*b/2: + t = 2*((a**2)*b-x)/(a**3) +else: + t = a*(b**2)/(2*x) + +import math +ans = math.degrees(math.atan(t)) +print(ans) +" +p02973,s068946008,Wrong Answer,"import bisect + +N=int(input()) + +line=[] + +for _ in range(N): + A=int(input()) + index=bisect.bisect_left(line,A) + if index==0: + line.insert(index,A) + else: + line.pop(index-1) + line.insert(index,A) + +print(len(line))" +p02795,s177579113,Accepted,"H = int(input()) +W = int(input()) +N = int(input()) + +ans = int( N /max([H, W])) +if N%max([H, W]) != 0: + ans += 1 +print(ans)" +p03059,s413502584,Accepted,"a,b,t = map(int,input().split()) + +print((t // a) * b)" +p03146,s628523677,Accepted,"s=int(input()) +cnt=1 +x=[s] +while True: + cnt+=1 + if s%2==0: + s//=2 + else: + s=3*s+1 + if s not in x: + x.append(s) + else: + print(cnt) + break" +p02627,s821288066,Accepted,"from string import ascii_letters, ascii_lowercase, ascii_uppercase + +ch = input().rstrip() + +if ch in ascii_uppercase: + print('A') +else: + print('a') +" +p02818,s883788701,Accepted,"a, b, k = map(int, input().split(' ')) + +if a >= k: + print(a - k, b) +elif a + b >= k: + print(0, b - (k - a)) +else: + print(0, 0)" +p03699,s016597182,Wrong Answer,"N = int(input()) +S = [] +for _ in range(N): + S.append(int(input())) + +s = sum(S) +if s % 10 != 0: + print(s) +else: + S.sort() + i = 0 + while s != 0: + s -= S[i] + if s % 10 != 0: + break + i += 1 + if s % 10 == 0: + print(0) + else: + print(s)" +p03665,s636643866,Wrong Answer,"def n_pow(a, n): + if n <= 0: + return 0 + return pow(a, n) + + +def main(): + bags, remainder = map(int, input().split()) + biscuits = list(map(int, input().split())) + count = [0, 0] + for b in biscuits: + count[b % 2] += 1 + print(n_pow(2, count[0] + count[1] - 1)) + + +if __name__ == '__main__': + main() + +" +p03633,s259599056,Accepted,"import fractions +n = int(input()) +li = [int(input()) for _ in range(n)] + +ans = li[0] +for i in range(1,n): + s = li[i] + ans = (ans * s) // fractions.gcd(ans, s) + +print(ans)" +p02622,s811288097,Accepted,"s=input() +t=input() +ans=0 +for i in range(len(s)): + if s[i]!=t[i]: + ans+=1 +print(ans)" +p02802,s188605017,Accepted,"#N=int(input()) +#N,M=map(int, input().split()) +#L=list(map(int, input().split())) +N,M=map(int, input().split()) +ifACL=[0]*N +cWAL=[0]*N +psL=[] +AC=0 +WA=0 +p=0 +s=0 +for _ in range(M): + p,s=map(str, input().split()) + p=int(p) + if ifACL[p-1]==0 and s==""WA"": + cWAL[p-1]+=1 + elif ifACL[p-1]==0 and s==""AC"": + AC+=1 + WA+=cWAL[p-1] + ifACL[p-1]=1 + +print(AC,WA)" +p03543,s084805497,Accepted,"N = input() +print(""YNeos""[not(N[1]==N[2] and (N[0]==N[1] or N[2]==N[3]))::2])" +p02570,s407843413,Accepted,"dts = input().split() + +d = int(dts[0]) +t = int(dts[1]) +s = int(dts[2]) + +time = d / s + +if time <= t: + print(""Yes"") +else: + print(""No"")" +p02880,s037963140,Accepted,"def resolve(): + n = int(input()) + ans = 'No' + for i in range(1,10): + for j in range(1,10): + if i*j == n: + ans = 'Yes' + print(ans) +resolve()" +p02660,s169716236,Wrong Answer,"import collections +n = int(input()) + + +def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + + +ans = 0 +#print(prime_factorize(n)) +a = collections.Counter(prime_factorize(n)) +for v in a.values(): + ans += (v+1)//2 + +print(ans) +" +p03592,s941983679,Wrong Answer,"N,M,K = map(int,input().split()) + +for i in range(N): + for j in range(M): + black = i * (N - j) + j * (M - i) + + if black == K: + print(""Yes"") + exit() + +print(""No"")" +p03067,s395069986,Accepted,"a,b,c = map(int,input().split()) +if (a < c < b) or (b < c < a): + print(""Yes"") +else: + print(""No"")" +p03030,s711944009,Accepted,"n = int(input()) +sp = [] +for i in range(n): + inp = input().split() + sp.append((inp[0], int(inp[1]), i + 1)) + +sp.sort(key=lambda x:(x[0], -x[1])) + +for i in sp: + print(i[2])" +p02802,s903850406,Accepted,"N, M = map(int, input().split()) +ac = [False for _ in range(N)] +wa = [0 for _ in range(N)] + +ans_wa = 0 +for _ in range(M): + p, S = input().split() + p = int(p) - 1 + if S == ""AC"": + if ac[p] == False: + ac[p] = True + ans_wa += wa[p] + else: + wa[p] += 1 + +ans_ac = ac.count(True) +print(""{} {}"".format(ans_ac, ans_wa))" +p03379,s386092036,Accepted,"def main(): + N, *X = map(int, open(0).read().split()) + l, r = sorted(X)[N // 2 - 1: N // 2 + 1] + ans = [r if x < r else l for x in X] + print(""\n"".join(map(str, ans))) + return + + +main() +" +p04030,s369455987,Wrong Answer,"s = input() +t = '' +for i in s: + if i == '0': + t = t + '0' + elif i == '1': + t = t + '0' + else: + t = t[:-1] +print(t)" +p03293,s589594520,Wrong Answer," +s1 = input() +s2 = input() +s2 = s2 * 2 +for i in range(len(s1)): + if s2[i] == s1[0]: + for j in range(len(s1)): + if s2[i + j] != s1[j]: + print(""No"") + exit() + + print(""Yes"") + exit() +" +p03013,s233967416,Accepted,"N, M = map(int, input().split()) +Q = 1000000007 +A = set() +for _ in range(M): + A.add(int(input())) + +p = [] +for i in range(1, N+1): + if i in A: + p.append(0) + elif i == 1: + p.append(1) + elif i == 2: + p.append(p[0] + 1) + else: + p.append(p[i-2] + p[i-3]) + +print(p[N-1] % Q)" +p02742,s117031468,Wrong Answer,"H, W = input().split(' ') +H = int(H) +W = int(W) +print(int(H*W/2 + 0.5))" +p02833,s754929592,Accepted,"N = int(input()) +N1 = N // 10 +if N % 2 == 1: + print(0) +else: + counter = 0 + div = 10 + while True: + num = N // div + if num == 0: + break + counter += num + div *= 5 + print(counter)" +p03720,s670611210,Wrong Answer,"from collections import defaultdict +N, M = map(int, input().split()) +d = defaultdict(int) +for i in range(1, N): + d[i] = 0 +for _ in range(M): + a, b = map(int, input().split()) + d[a] += 1 + d[b] += 1 + +for i in d.values(): + print(i)" +p02641,s200348565,Wrong Answer,"X, N = map(int, input().split()) +P = set(map(int, input().split())) +Nums = set(range(1, 101)) +Nums = Nums - P +sorted(Nums) + + +minNum = 99999; +minIndex = 0; +for n in Nums: + if abs(X - n)< minNum: + minNum = abs(X - n) + minIndex = n + +print(minIndex) + + +" +p03557,s333725110,Accepted,"import bisect + +N = int(input()) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) +#print(A) +#print(B) +#print(C) + +ans = 0 + +for i in B: + a_num = bisect.bisect_left(A,i) + c_num = bisect.bisect(C,i) + ans += a_num*(N-c_num) + + +print(ans)" +p03556,s613851976,Wrong Answer,"N = int(input()) +for i in range(1, N+1): + if i*i > N: + print((i-1)*(i-1)) + exit()" +p02578,s320746900,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +cnt = 0 +for i in range(1,N) : + if A[i-1] <= A[i] : + cnt += A[i] - A[i-1] + else : + cnt += 0 +print(cnt)" +p03289,s134631271,Accepted,"S = input() +n =len(S) +s = S.lower() + + +if S[0] != 'A': + print('WA') + exit() +else: + for i in range(2, n-1): + if S[i] != 'C': + if S[i] != s[i]: + print('WA') + exit() + +if S[n-1] != s[n-1] or S[1] != s[1]: + print('WA') + exit() + +if S.count('C') != 1: + print('WA') + exit() + +print('AC')" +p02860,s584085215,Accepted,"n = int(input()) +t = input() +if n % 2 != 0: + print('No') +else: + print('Yes' if t[:n//2] == t[n//2:] else 'No') +" +p02684,s175780273,Accepted,"from sys import exit +N,K = map(int,input().split()) +town = [None]+list(map(int,input().split())) + +flag = [None]+[0]*N +remain = K +piece = 1 +cnt = 1 +while remain > 0: + if flag[town[piece]] != 0: + q = cnt-flag[town[piece]] + piece = town[piece] + remain -= 1 + break + else: + piece = town[piece] + flag[piece] = cnt + remain -= 1 + cnt += 1 + +if remain == 0: + print(piece) + exit(0) + +remain %= q + +while remain > 0: + piece = town[piece] + remain -= 1 + +print(piece)" +p02597,s528464378,Accepted,"N = int(input()) +C = input() + +W = 0 #仕切りより左側の白い石の個数 +R = C.count('R') #仕切りより右側の赤い石の個数 + +ans = max(W, R) + +for i in range(N): + if C[i] == 'W': #仕切りの左側に'W'が移動する + W += 1 + else: #仕切りの左側に'R'が移動する + R -= 1 + ans = min(ans, max(W, R)) + +print(ans)" +p02664,s295230342,Accepted,"line = list(input()) +N = len(line) +i = 1 +for i in range(N): + if line[i] == ""?"": + line[i] = ""D"" +print("""".join(line))" +p03161,s055147410,Accepted,"def main(): + N,K=map(int,input().split()) + h=list(map(int,input().split())) + ans=[0]*N + ans[1]=abs(h[1]-h[0]) + for i in range(2,N): + ans[i]= min(abs(h[i]-h[j])+ans[j] for j in range(max(0,i-K),i)) + print(ans[-1]) +main()" +p02963,s128668844,Wrong Answer,"#!/usr/bin/env python3 +s = int(input()) +if s <= 10**9: + print(s, 0, 0, 0, 0, 1) +else: + print(10**9, 1, 10**9 - int(str(s)[-9:]), s // 10**9 + 1,0,0) +" +p03206,s218155173,Accepted,"d=int(input()) +result='Christmas' +n=25 +while n>=22: + if n>d: + result+=' Eve' + n-=1 +print(result)" +p04005,s104964994,Accepted,"from statistics import median + +A, B, C = [int(x) for x in input().split()] + +low = min(A, B, C) +mid = median([A, B, C]) +huge = max(A, B, C) + +if huge % 2 == 0: + print(0) +else: + red = low*mid*(huge//2) + blue = low*mid*(huge//2+1) + + print(blue-red) +" +p02847,s786665821,Accepted,"s = input() +week=[""SAT"",""FRI"",""THU"",""WED"",""TUE"",""MON"",""SUN""] +for i in range(0,7): + if s == week[i]: + print(i+1)" +p03627,s980786338,Accepted,"# C - Make a Rectangle +# https://atcoder.jp/contests/arc081/tasks/arc081_a + +from collections import Counter + +n = int(input()) +A = list(map(int, input().split())) + +C = sorted(list(Counter(A).items()), key=lambda x: -x[0]) + +ans = 0 +for k, v in C: + if v >= 4: + if ans == 0: + print(k ** 2) + else: + print(ans * k) + exit() + else: + if v >= 2: + if ans == 0: + ans = k + else: + print(ans * k) + exit() + +print(0)" +p02880,s345242921,Accepted,"x = int(input()) + +for n in range(1, 10): + for k in range(1, 10): + a = n * k + if a == x: + print('Yes') + exit() + else: + pass +print('No')" +p03495,s581408186,Accepted,"import collections + +n,k = map(int,input().split()) +a = list(map(int,input().split())) + +c = collections.Counter(a).most_common() +cnt = len(c) +i = 1 +ans = 0 +while cnt > k: + cnt -= 1 + ans += c[-i][1] + i += 1 + +print(ans) +" +p03557,s227206401,Accepted,"import bisect +N = int(input()) +A = list(map(int, input().split("" ""))) +B = list(map(int, input().split("" ""))) +C = list(map(int, input().split("" ""))) +A.sort() +B.sort() +C.sort() + +ans = 0 +for b in B: + i = bisect.bisect_left(A, b) + j = bisect.bisect_right(C, b) + ans += i * (N - j) +print(ans)" +p03071,s908008711,Wrong Answer,"a, b = (int(i) for i in input().split()) +if abs(a-b) > 1: + print(max(a,b)*2 - 1) +else: + print(a*2)" +p02708,s858535449,Wrong Answer,"N,K = map(int,input().split()) +#N = int(input()) +#A = list(map(int,input().split())) +p=list(range(N+1)) +c=0 +s=sum(p[:K]) +S=sum(p[:K]) + +l=sum(p[len(p)-K:]) +L=sum(p[len(p)-K:]) +for i in range(K,len(p)): + s += p[i] + S += s + #print(s,S) + #print(c) + l += p[len(p)-i-1] + L += l +# print(i) + # print(l,L) +c = L - S + (N-K+2) +print(c) +" +p02918,s523346147,Accepted,"N, K=map(int, input().split()) +S=list(input()) + +count=0 +pre=S[0] +for i in range(1,N): + if pre==S[i]: + count+=1 + pre=S[i] + + + +print(min(N-1, count+2*K)) + + +" +p03493,s248468011,Accepted,"s = input() +print(s.count(""1""))" +p02744,s653655422,Wrong Answer,"n = int(input()) +ans = [] +start = ""a"" +stack = [] +stack.append(start) +num = ord(""a"") +while stack: + v = stack.pop() + if len(v) == n: + ans.append(v) + continue + nex_num = ord(v[-1]) + for i in range(num, nex_num + 2): + tuika = chr(i) + stack.append(v + tuika) +ans.sort() +print(*ans, sep=""\n"") +" +p03309,s220898131,Accepted,"N = int(input()) +A_list = [int(item)-(index+1) for index, item in enumerate(input().split())] + +A_list.sort() +b = A_list[len(A_list)//2] + +ans = 0 +for i in A_list: + ans += abs(b-i) + +print(ans)" +p03548,s615715023,Wrong Answer,"x,y,z = map(int, input().split()) +print(x//(y+z+1))" +p02629,s970525842,Accepted,"import sys + +def main(n): + c = ""abcdefghijklmnopqrstuvwxyz"" + m = {} + for i in range(0, 26): + m[i+1] = c[i] + + s = """" + while n > 0: + if n%26 == 0: + t = 26 + n //= 26 + n -= 1 + else: + t = n%26 + n //= 26 + s = m[t] + s + return s + +n = int(sys.stdin.readline().strip()) +print(main(n)) +" +p03633,s714541821,Accepted,"#import math +import fractions +from functools import reduce + +N = int(input()) +T = [] +for i in range(N): + T.append(int(input())) + +def lcm_base(x, y): + return (x * y) // fractions.gcd(x, y) + +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) +ans = lcm_list(T) + +print(ans)" +p03073,s718144524,Accepted,"s = list(input()) +n = len(s) +c = 0 +for i in range(n - 1): + if s[i] == s[i + 1]: + if s[i] == '0': + s[i + 1] = '1' + else: + s[i + 1] = '0' + c += 1 +print(c)" +p02843,s761525319,Wrong Answer,"x=int(input()) +if x<=100: + print(0) + exit() +if x>=2100: + print(1) + exit() +else: + t=x//100 + a=x%100 + if t<=a<=t*5: + print(1) + else: + print(0)" +p02796,s683679677,Wrong Answer,"N = int(input()) +XL =[list(map(int, input().split())) for _ in range(N)] +LR = [[XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]] for i in range(N)] +LR.sort() + +cp = LR[0][1] + +ans = 0 + +for i in range(1,N): + if LR[i][0] < cp: + ans += 1 + else: + cp = LR[i][1] +print(N-ans)" +p02993,s159065943,Wrong Answer,"s = input() +print('Good' if all(s[i]==s[i+1] for i in range(3)) else 'Bad') " +p03062,s544060784,Accepted,"import heapq +n=int(input()) +a=list(map(int,input().split())) + +zero_count=0 +minus_count=0 +for i in range(n): + if a[i]<0: + minus_count+=1 + if a[i]==0: + zero_count+=1 + break + +for i in range(n): + a[i]=abs(a[i]) + +if zero_count==1 or minus_count%2==0: + ans=sum(a) +else: + heapq.heapify(a) + mn=heapq.heappop(a) + ans=sum(a)-mn + +print(ans) +" +p03557,s866812722,Accepted,"from bisect import bisect_right as br +from bisect import bisect_left as bl + +f=lambda:map(int,input().split()) +N=int(input()) +A=list(f()) +B=list(f()) +C=list(f()) +A.sort() +B.sort() +C.sort() + + +B2=[] +C2=[] +for b in B: + B2.append(bl(A,b)) +for c in C: + C2.append(bl(B,c)) + +B3=[] +for b in B2: + if B3: + B3.append(B3[-1]+b) + else: + B3.append(b) + +res=sum([B3[C2[i]-1] if C2[i]!=0 else 0 for i in range(N)]) +print(res)" +p02957,s755409516,Accepted,"a,b = map(int,input().split()) + +if (a + b) % 2 == 0: + print((a+b)//2) +else: + print(""IMPOSSIBLE"")" +p03107,s271408200,Accepted,"S = list(input()) + +i = 0 +count = 0 +while i < len(S)-1: + if S[i] != S[i+1]: + del S[i:i+2] + count += 2 + if i != 0: + i -= 1 + else: + i += 1 +print(count)" +p02657,s933123046,Accepted,"a,b = map(int,input().split()) +print(a * b)" +p03994,s803315130,Accepted,"s = input() +k = int(input()) +l = ""abcdefghijklmnopqrstuvwxyz"" +ans = """" +for i in range(len(s) - 1): + num = (26 - l.index(s[i])) % 26 + if k >= num: + ans += ""a"" + k -= num + else: + ans += s[i] +ans += l[(l.index(s[-1]) + k) % 26] +print(ans)" +p03711,s137556480,Wrong Answer,"x,y=map(int, input().split()) +if x==2 and y==2: + print('Yes') +elif x==2 or y==2: + print('No') + +a=[4,6,9,11] +if (x in a) and (y in a): + print('Yes') +elif (x not in a) and (y not in a): + print('Yes') +else: + print('No') +" +p03861,s746291459,Accepted,"a, b, x = map(int, input().split()) +print(b//x - (a-1)//x)" +p03944,s835602974,Wrong Answer,"w,h,n = map(int,input().split()) +x_max = w +x_min = 0 +y_max = h +y_min = 0 +for i in range(n): + x,y,a = map(int,input().split()) + if a == 1: + x_min = max(x_min,x) + elif a == 2: + x_max = min(x_max,x) + elif a == 3: + y_min = max(y_min,y) + elif a == 4: + y_max = min(y_max,y) + print(x_max,x_min,y_max,y_min) +S = (x_max-x_min)*(y_max-y_min) +print(S if S>=0 else 0)" +p03448,s241246745,Accepted,"A=int(input()) +B=int(input()) +C=int(input()) +X=int(input()) +ans=0 +for ai in range(A+1): + for bi in range(B+1): + for ci in range(C+1): + temp=ai*500+bi*100+ci*50 + if temp==X: + ans+=1 +print(ans)" +p03605,s037687835,Accepted,"n=input() +if ""9"" in n: + print(""Yes"") +else: + print(""No"")" +p04012,s961510657,Accepted,"w = str(input()) + +n = int(0) + +for i in w: + if w.count(i) % 2 == 1: + n += 1 + +if n == 0: + print('Yes') +else: + print('No')" +p03852,s833542994,Wrong Answer,"S = input() + +S = S.replace(""eraser"","""") +S = S.replace(""erase"","""") +S = S.replace(""dreamer"","""") +S = S.replace(""dream"","""") + +if len(S) == 0: + ans = ""YES"" +else: + ans = ""NO"" + +print(ans) +" +p02606,s099214619,Accepted,"l, r, d = map(int, input().split()) +c = 0 +for x in range(l, r+1): + if x % d == 0: + c += 1 +print(c)" +p02602,s008745353,Accepted,"n,k = [int(i) for i in input().split()] +x = [int(i) for i in input().split()] +for i in range(n - k): + if x[k+i] > x[i]: + print('Yes') + else: + print('No')" +p04033,s724064455,Accepted,"import sys + +#N = I() +#A = [LI() for _ in range(N)] + +a, b = list(map(int,sys.stdin.readline().rstrip().split())) + +if a > 0: + print('Positive') +elif a <= 0 and b >= 0: + print('Zero') +else: + if (a+b)%2 == 0: + print('Negative') + else: + print('Positive')" +p03073,s705568614,Accepted,"import numpy as np + +s = np.array(list(map(int, input()))) + +a01 = np.tile([0,1], len(s)//2+1) +a10 = np.tile([1,0], len(s)//2+1) + +if len(s)%2 != 0: + a01 = np.delete(a01, len(s)) + a10 = np.delete(a10, len(s)) +else: + a01 = np.delete(a01, [len(s)-1,len(s)]) + a10 = np.delete(a10, [len(s)-1,len(s)]) + +ans01 = np.abs(s -a01) +ans10 = np.abs(s -a10) + +if sum(ans01) >= sum(ans10): + print(sum(ans10)) +else: + print(sum(ans01))" +p02947,s468300529,Wrong Answer,"from collections import defaultdict +import math +prm = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101] +alp = {chr(i):p for i,p in zip(range(97, 97+26),prm)} +n = int(input()) +d = defaultdict(int) +nums = set([]) +for _ in range(n): + s = input() + m = 1 + for l in s: + m = m*alp[l]%10**9 + d[m] += 1 + +def comb(n, r): + if n>1]!=s[i]]))" +p04011,s424603857,Accepted,"a=[] +for i in range(4): + b=int(input()) + a.append(b) +ans=0 +for i in range(1,a[0]+1): + if i<=a[1]: + ans+=a[2] + else: + ans+=a[3] +print(ans)" +p02910,s554901614,Accepted,"s = input() +if len(set(s[::2])-{""R"",""U"",""D""}) ==0 and len(set(s[1::2])-{""L"",""U"",""D""}) ==0 : + print('Yes') +else: + print('No') + " +p02675,s566005972,Accepted,"s = input()[-1] + +if s in ['2', '4', '5', '7', '9']: + print('hon') +elif s in ['0', '6', '1', '8']: + print('pon') +else: + print('bon') +" +p02917,s245664945,Wrong Answer,"n = int(input()) +b = list(map(int, input().split())) +a = [0]*n +for i in range(n-1, 0, -1): + if i == n-1: + a[i] = b[i-1] + else: + a[i] = min(a[i+1], b[i-1]) +a[0] = b[0] +print(sum(a))" +p02910,s181892181,Accepted,"S = input() +odd_S = S[0::2] +even_S = S[1::2] +if 'L' in odd_S or 'R' in even_S: + print('No') +else: + print('Yes') + " +p03011,s099671814,Wrong Answer,"p = list(map(int,input().split())) + +mn = 200 +for i in range(2): + for j in range(i+1,3): + if (i+j < mn): + mn = i+j + +print(mn) + + +" +p04012,s080603992,Wrong Answer,"import math +import collections +import fractions +import itertools +import functools +import operator + +def solve(): + w = input() + c = collections.Counter() + for i in c: + if c[i] % 2 == 1: + print(""No"") + exit() + print(""Yes"") + return 0 + +if __name__ == ""__main__"": + solve() +" +p02719,s790372367,Accepted,"N, K = map(int, input().split()) + +res = N % K +print(min(res, abs(res - K))) +" +p03254,s040603721,Accepted,"from bisect import bisect_right +import itertools + +N, x = map(int, input().split()) +a = list(map(int, input().split())) + +a.sort() +acum = list(itertools.accumulate(a)) + +answer = bisect_right(acum, x) +if answer == N: + if acum[-1] < x: + answer -= 1 +print(answer) +" +p03548,s476762985,Wrong Answer,"x,y,z = map(int, input().split()) +if x%(y+z)>=y: + print(x//(y+z)+1) +else: + print(x//(y+z))" +p02718,s120902877,Accepted,"def main(): + n, m = [int(x) for x in input().split("" "")] + + arr = [int(x) for x in input().split("" "")] + + sum = 0 + + for i in arr: + sum += i + + arr.sort() + + if (arr[n-m] < sum/(4*m)): + print(""No"") + else: + print(""Yes"") + +main() +" +p02629,s563114352,Wrong Answer,"X=int(input()) +n=26 + +a=[] +X_dumy = X +out = '' +while X_dumy>0: + out = str(X_dumy%n) + X_dumy = int(X_dumy/n) + a.append(out) + +l = list('abcdefghijklmnopqrstuvwxyz') +N=0 +for x in a: + a[N]=l[int(a[N])-1] + N=N+1 +a.reverse() +pg = ''.join(a) +print(pg)" +p03815,s487524463,Accepted,"x = int(input()) + +time1 = x // 11 +X = x % 11 +time1 *= 2 +if X > 6: + time1 += 2 +elif X > 0: + time1 += 1 +print(time1) +" +p03493,s592614419,Accepted,"print(input().count(""1""))" +p04031,s684697228,Accepted,"_ = int(input()) +a = [int(x) for x in input().split()] + +answer = 10**100 +for y in range(-100, 100 + 1): + acc = 0 + for x in a: + acc += (x - y) * (x - y) + answer = min(answer, acc) +print(answer) +" +p02993,s494559650,Wrong Answer,"n = list(input()) +ans = ""Good"" +for i in range(len(n)): + if n[i-1] ==n[i]: + ans = ""Bad"" + else: + pass +print(ans) + +" +p02747,s714901779,Accepted,"S = input() + +if len(S) % 2 != 0: + print(""No"") +else: + N = int(len(S) / 2) + + flag = 0 + + for indx in range(N): + if ((S[indx * 2 + 0] != ""h"") or + (S[indx * 2 + 1] != ""i"")): + flag = 1 + + if flag == 0: + print(""Yes"") + else: + print(""No"")" +p03077,s575112844,Wrong Answer,"n = int(input()) +a = [int(input()) for _ in range(5)] +ind = 0 +minimum = 10 ** 18 +for i in range(5): + minimum = min(minimum, a[i]) +print((n + minimum) // minimum + 4)" +p03785,s376257581,Wrong Answer,"n,c,k = map(int,input().split()) +t_input = [int(input()) for i in range(n)] + +t_s = sorted(t_input) + +ans = 0 +c_limit = 1 +t_limit = t_s[0]*k +for i in range(n): + t = t_input[i] + #乗客が前の客の時間制限より大きいか、すでにバスが定員以上なら + if t>t_limit or c>=c_limit: + ans+=1 + c_limit=1 + t_limit = t+k + else: + c_limit+=1 +print(ans)" +p02681,s398043038,Wrong Answer,"st = input() +st2 = input() +f = st2[len(st2)-1] +lst = [] +lst2 = [] +for i in st: + lst.append(i) +for i in st2: + lst2.append(i) +lst2.remove(f) +yo = ""Yes"" +for i in range(len(st)): + if lst[i] != lst2[i] or len(lst)+1!=len(lst2): + yo = ""No"" +print(yo)" +p02973,s982577215,Accepted,"from bisect import bisect_right +N = int(input()) +A = [int(input()) for i in range(N)] +A.reverse() +X = [A[0]] + +for i in range(1, N): + if X[-1] <= A[i]: + X.append(A[i]) + else: + idx = bisect_right(X, A[i]) + X[idx] = A[i] + +print(len(X)) +" +p02787,s746598922,Accepted,"H, N = map(int, input().split()) +dp = [10**8 for i in range(H+1)] + +dp[0] = 0 + +for i in range(N): + a, b = map(int, input().split()) + + for j in range(H): + dp[min(j+a, H)] = min(dp[min(j+a, H)], dp[j] + b) + + +print(dp[H])" +p03998,s310117012,Accepted,"a= input() +b= input() +c= input() +qa=[] +qb=[] +qc=[] +for i in a: + qa.append(i) +for i in b: + qb.append(i) +for i in c: + qc.append(i) +qa.append('d') +qb.append('d') +qc.append('d') +t=qa.pop(0) +while len(qa)>0 and len(qb)>0 and len(qc)>0: + if t=='a': + t=qa.pop(0) + elif t=='b': + t=qb.pop(0) + else : + t=qc.pop(0) + +if len(qa)==0: + print('A') +elif len(qb)==0: + print('B') +else: + print('C')" +p02547,s296439360,Accepted,"# +# 179B +# +n = input() +n = int(n) +s = '' +for i in range(n): + t = input() + t = t.replace(' ','') + t = list(t) + if t[0]==t[1]: + s = s+'1' + else: + s = s+'0' + +if '111' in s: + print('Yes') +else: + print('No') +" +p02767,s184266997,Accepted,"import numpy as np +import math +N = int(input()) +X = np.array(list(map(int, input().split()))) + +P_floor = math.floor(np.sum(X)/N) +P_ceil = math.ceil(np.sum(X)/N) + +ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2)) + +print(ans)" +p03797,s669023178,Accepted,"import sys +N,M = map(int,input().split()) +if not ( 1 <= N <= 10**12 and 1 <= M <= 10**12 ): sys.exit() + +count_SCC=0 +if M > 2*N : #Mがあまる + M = M - 2*N + count_SCC = N + M//4 +elif M < 2*N : #Nがあまる + count_SCC = M//2 +print(count_SCC)" +p03471,s080685479,Accepted,"n, y = map(int, input().split()) + +for i in range(n+1): + for j in range(n+1): + num_sen = n - i - j + if num_sen < 0: + continue + + if 10000 * i + 5000 * j + 1000 * num_sen == y: + print(i, j, num_sen) + exit() +print(-1, -1, -1) + +" +p03986,s831326478,Wrong Answer,"from collections import deque +x = input() +stack = deque(x[0]) +for i in range(1,len(x)): + if x[i] == ""S"": + stack.appendleft(x[i]) + else: #x[i] == ""T"" + if len(stack) == 0: + stack.append(x[i]) + if stack[0] == ""T"": + stack.appendleft(x[i]) + else: + stack.popleft() +print(len(stack))" +p02640,s093661824,Accepted,"x,y = map(int,input().split()) +if y % 2 == 1: + print(""No"") +elif 2*x - y/2 < 0: + print(""No"") +elif y /2 - x < 0: + print(""No"") +else: + print(""Yes"") +" +p03657,s096196180,Accepted,"A,B = map(int,input().split()) + +if A%3==0 or B%3==0 or (A+B)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p02784,s952003046,Accepted,"H, N = map(int, input().split()) +A = list(map(int, input().split())) + + +def answer(H: int, N: int, A: list) -> str: + damage = 0 + for i in range(0, N): + damage += int(A[i]) + i += 1 + if damage < H: + return 'No' + else: + return 'Yes' + +print(answer(H, N, A)) +" +p03696,s812489609,Accepted,"N=int(input()) +S=input() +x=0 +m=0 +for i in range(N): + if S[i]=='(': + x+=1 + else: + x-=1 + m=min(x,m) + +a=-m +b=x-m +print('('*a+S+')'*b) +" +p03076,s349959647,Wrong Answer,"a = [int(input()) for _ in range(5)] +z = max(a) +ans = 0 +for i in a: + if i%10!=0:z = min(z,i%10) + ans += 10*((i+10-1)//10) +print(ans+z-10 if z!=0 else ans)" +p03359,s726213843,Accepted,"a,b=map(int,input().split()) +print(a if a<=b else a-1)" +p03994,s799263493,Wrong Answer,"alphabet = 'abcdefghijklmnopqrstuvwxyz' +s = input() +K = int(input()) +ans = '' +for i in range(len(s) - 1): + s_i = alphabet.index(s[i]) + if s_i == 0: + ans += s[s_i] + continue + if 26 - s_i < K: + K -= 26 - s_i + s_i = 0 + ans += alphabet[s_i] +s_i = (alphabet.index(s[-1]) + K) % 26 +ans += alphabet[s_i] +print(ans)" +p02660,s709959663,Accepted,"N = int(input()) +n, p, score = N, 2, 0 +while p ** 2 <= N: + e = 1 + while n % (p ** e) == 0: + n //= (p ** e) + score += 1 + e += 1 + else: + while n % p == 0: + n //= p + p += 2 - (p == 2) +else: + score += (n > 1) +print(score)" +p02615,s660783292,Accepted,"import sys +n=int(input()) +a=list(map(int,input().split())) +def nibai(n): + return n*2 +a.sort(reverse=True) +sc=a[0] +if n==2: + print(sc) + sys.exit() +a=a[1:] +b=list(map(nibai,a)) +sc+=sum(b[:(n//2)-1]) +if n%2==0: + print(sc) +else: + print(sc+a[(n//2)-1]) + + " +p02957,s826302920,Accepted,"a, b = map(int, input().split()) +diff = abs(a - b) +if diff % 2 == 0: + print(max(a, b) - diff // 2) +else: + print('IMPOSSIBLE')" +p02785,s068440786,Accepted,"N,K=(int(x) for x in input().split()) +H = list(map(int, input().split())) + +H.sort() + +H_= H[:-K] + + +if N==K: + print(0) +elif K==0: + print(sum(H)) +else: + print(sum(H_))" +p03799,s402881031,Accepted,"n, m = list(map(int, input().split())) + +if m >= n * 2: + x = m - 2 * n + print(n + x // 4) + +else: + print(m // 2)" +p02843,s665447048,Accepted,"X = int(input()) + +dp = [0] * (100200) +dp[0] = 1 + +for i in range(X + 1): + if dp[i] == 1: + for j in range(6): + dp[i + 100 + j] = 1 + if i + 100 + j == X: + print(1) + exit() +print(0) +" +p03456,s514004018,Accepted,"a,b = map(int,input().split()) + +x = int(str(a)+str(b)) + +for i in range(x): + if i**2 == x: + print(""Yes"") + break + elif i**2 A[i - K]: + print(""Yes"") + else: + print(""No"") + +if __name__ == ""__main__"": + main() +" +p02879,s441605655,Wrong Answer,"def LI(): + return [int(s) for s in input().split()] + +A,B = LI() + +print(A*B)" +p02647,s937460930,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +fin = min(A) == N +for j in range(K): + if fin: + break + T = [0] * (N + 1) + for i in range(N): + T[max(i - A[i], 0)] += 1 + T[min(i + A[i] + 1, N)] -= 1 + A[0] = T[0] + fin = A[0] == N + for i in range(1, N): + A[i] = A[i - 1] + T[i] + if A[i] < N: + fin = False +print(' '.join(list(map(str, A)))) +" +p02726,s352564321,Accepted,"n,x,y=map(int,input().split()) +lst=[0]*(n-1) +for i in range(1,n): + for j in range(i+1,n+1): + lst[min(j-i,abs(x-i)+1+abs(y-j))-1]+=1 +for element in lst: + print(element)" +p02597,s380436327,Accepted,"N = int(input()) +S = input() + +r = S.count('R') +w = 0 +ans = [max(r,w)] + +for i in range(N): + if S[i] == 'W': + w += 1 + else: + r -= 1 + ans.append(max(w,r)) + +print(min(ans)) +" +p02675,s694410678,Wrong Answer,"n = input() +if n[-1] == '3': + print('bon') +if n[-1] in ['0','1','6','8']: + print('pon') +else: + print('hon')" +p04029,s150914455,Accepted,"# 必要なキャンディーの個数の合計を出力せよ +# 1からNまでの和はN/2(N+1)で表される + +N = int(input()) + +print(N * (N+1) // 2) +" +p02658,s852117596,Accepted,"n, *a = map(int, open(0).read().split()) +res = 1 +if 0 in a: + print(0) + exit() +for a in a: + res *= a + if res > 1e18: + res = -1 + break +print(res) +" +p02717,s689828431,Accepted,"a = list(input().split(' ')) +print(a[2], a[0], a[1])" +p02916,s936397667,Wrong Answer,"n = int(input()) +alis = list(map(int, input().split())) +blis = list(map(int, input().split())) +clis = list(map(int, input().split())) +cache = 0 +ans = 0 +if n == 2 and alis[0] ==1: + ans = sum([blis[0] + blis[1] + clis[0]]) +else: + for i in range(n): + a = alis[i] + b = blis[a - 1] + ans += b + if cache + 1 == a: + ans += clis[a - 2] + cache = a +print(ans)" +p02772,s406525327,Accepted,"N=int(input()) +A=list(map(int,input().split())) +a=[i for i in A if i%2==0] +b=len([i for i in a if i%3==0 or i%5==0]) +if len(a)==b: + print('APPROVED') +else: + print('DENIED')" +p02835,s104068948,Accepted,"print(""bust"" if sum(list(map(int,input().split())))>=22 else ""win"")" +p02732,s118291998,Accepted,"n = int(input()) +l = list(map(int,input().split())) +d = {} +for i in l: + if i in d: + d[i]+=1 + else: + d[i] = 1 +cp = 0 +for i in d.values(): + cp+= i*(i-1)//2 +for i in l: + print(cp-d[i]+1)" +p02677,s292821835,Accepted,"import math + +def main(): + A,B,H,M = [int(x) for x in input().split()] + degH = (0.5*H*60 + 0.5*M) + degM = 6*M + theta = abs(degH-degM) + if theta == 180: + print(A+B) + return + if theta > 180: + theta = 180 - (theta - 180) + # print(degH,degM,theta) + # print(math.cos(math.radians(theta))) + print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))) + +if __name__ == '__main__': + main() +" +p03076,s056653971,Wrong Answer,"import math +ans=0 +A=[int(input()) for i in range(5)] +a=10 +for i in range(5): + if a>(A[i]%10): + p=i + a=A[i] +for i in range(5): + if i==p: + ans+=A[i] + else: + ans+=10*(math.ceil(A[i]/10)) +print(ans)" +p02640,s621364758,Accepted,"# 2020/06/14 +# AtCoder Beginner Contest 170 - B + +# Input +x, y = map(int,input().split()) + +# Calc +# i is Tsuru +ans = 'No' +for i in range(0, 101): + # j is Kame + for j in range(0, 101): + if i + j == x and i * 2 + j * 4 == y: + ans = 'Yes' + break + +# Output +print(ans) +" +p03625,s624701083,Accepted,"n=int(input()) +A=list(map(int,input().split())) +ans1=0 +ans2=0 +A.sort(reverse=True) +flag = False +for i in range(n-1): + if flag == True: + flag = False + continue + if i < n-1 and A[i+1] == A[i]: + flag = True + if A[i] >= ans1: + ans2 = ans1 + ans1 = A[i] + elif A[i] > ans2: + ans2 =A[i] +print(ans1*ans2) +" +p02835,s537823176,Accepted,"n,a,b=map(int,input().split()) +print(""bust"" if n+a+b>=22 else ""win"")" +p02615,s704617218,Accepted,"def main(): + n = int(input()) + a = sorted(list(map(int,input().split())),reverse=True) + ans = a[0] + for i in range(1,n-1): + if i%2!=0: + ans += a[(i+1)//2] + else: + ans += a[i//2] + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02691,s553559794,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +P = {} +Q = {} + +for i in range(N): + if i+1 - A[i] in P: + P[i+1 - A[i]] += 1 + else: + P[i+1 - A[i]] = 1 + if i+1 + A[i] in Q: + Q[i+1 + A[i]] += 1 + else: + Q[i+1 + A[i]] = 1 + +res = 0 +for k,v in P.items(): + if k in Q: + res += v * Q[k] + +print(res) + +" +p02786,s243707047,Wrong Answer,"import math + +h = int(input()) + +def f(hp): + if(hp == 1): + return 1 + else: + return (2 * f(math.ceil(hp / 2)) + 1) + +print(f(h))" +p03206,s819983540,Accepted,"D = int(input()) +if D == 22: + print('Christmas Eve Eve Eve') +elif D == 23: + print('Christmas Eve Eve') +elif D == 24: + print('Christmas Eve') +else: + print('Christmas')" +p02747,s259700786,Accepted,"S = input() +if len(S) % 2 == 1: + print(""No"") +else: + while (len(S) != 0): + if S[0] == 'h' and S[1] == 'i': + S = S[2:] + else: + break + if len(S) != 0: + print(""No"") + else: + print(""Yes"")" +p03071,s386649966,Wrong Answer,"A,B=map(int,input().split()) + +if (A-1)<=B: + print(A+B) +else: + print(A+(A-1)) +" +p03611,s005369165,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = [0 for _ in range(100005)] + +for aa in a: + ans[aa] += 1 + ans[aa+1] += 1 + ans[aa+2] += 1 + +# prt = 0 +# for i,v in enumerate(ans): +# if v > prt: + +print(max(ans)) +" +p04029,s789041807,Accepted,"n = int(input()) +print((n*(n+1))//2)" +p02663,s889354031,Accepted,"h,m,H,M,k = map(int,input().split()) + +t1 = 60*h + m +t2 = 60*H + M + +ans = t2 - t1 - k +print(ans) +" +p02622,s321100326,Accepted,"s = input() +t = input() + +cnt = 0 +for i in range(len(s)): + if s[i] != t[i]: + cnt += 1 + +print(cnt)" +p02881,s768154602,Wrong Answer,"n = int(input()) + +def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + +m = 1+n +for v in prime_factorize(n): + if v+(n//v)0: + t+=f-t%f + t+=c + print(t)" +p02598,s193303550,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + + +def C(x): + return sum([max((Ai + x - 1) // x - 1, 0) for Ai in A]) + + +A.sort() +left = 1 +right = A[-1] +while left + 1 < right: + mid = (left + right) // 2 + S = C(mid) + if S <= K: + right = mid + else: + left = mid +print(left if C(left) <= K else right) +" +p02597,s821462878,Accepted,"n = int(input()) +stone = input() +r = stone.count(""R"") +print(stone.count(""W"", 0, r))" +p02603,s715309594,Accepted,"#------------- +N = int(input()) +A = list(map(int, input().split())) +#------------- + +kabu = 0 +money = 1000 +for i in range(N-1): + if A[i] < A[i+1]: + mod,money = divmod(money , A[i]) + kabu += mod + if A[i] > A[i+1]: + money = money + A[i] * kabu + kabu = 0 + +money = money + A[N-1]*kabu +print(money)" +p02959,s481214558,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) +monster = 0 +hero = 0 +for i in range(N): + allhero = B[i] + hero + if allhero<=A[i]: + monster += allhero + hero = 0 + else: + monster += A[i] + if hero>A[i]: + hero = B[i] + else: + hero = allhero-A[i] + #print(monster,allhero,hero) + +if hero>0: + monster += min(hero,A[N]) +print(monster)" +p03062,s115738284,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) + +cnt=0 +ans=0 + +for i in range(n): + if a[i]<0: + cnt+=1 + a[i]*=-1 + +print(a) + + + +if cnt%2==0: + ans=sum(a) + +else: + ans=sum(a)-2*min(a) + +print(ans) +" +p03386,s289265037,Accepted,"a,b,k=map(int,input().split()) +if a+k<=b-k: + for i in range(k): + print(a+i) + for i in range(k): + print(b-k+1+i) +else: + for i in range(a,b+1): + print(i) +" +p03001,s324616995,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Tue May 12 00:13:44 2020 + +@author: shinba +"""""" +import sys + +w,h,x,y = map(int,input().split()) + +if w%2 == 0 and h%2 == 0: + if w//2 == x and h//2 == y: + print((h*w)/2,1) + sys.exit() + +print(h*w/2,0)" +p02695,s577626313,Accepted,"from itertools import combinations_with_replacement + +N, M, Q = map(int, input().split()) +abcd = [list(map(int, input().split())) for _ in range(Q)] + +ans = 0 +for v in combinations_with_replacement(range(1, M+1), N): + A = list(v) + temp = 0 + for a, b, c, d in abcd: + if A[b-1] - A[a-1] == c: + temp += d + ans = max(ans, temp) + +print(ans) +" +p02759,s631188888,Accepted,"n = input() +n = int(n) +if n % 2 == 0: + print(int(n/2)) +else: + print(int((n/2)+1)) + " +p03645,s962263094,Accepted,"N, M = map(int, input().split()) +start = set() +goal = set() + +for i in range(M): + a, b = map(int, input().split()) + if(a == 1): + start.add(b) + elif(b == N): + goal.add(a) +print(""IMPOSSIBLE"" if(len(start & goal) == 0) else ""POSSIBLE"") +" +p02860,s730908448,Accepted,"N = int(input()) +S = input() +if(S[:N//2] == S[N//2:]): + print('Yes') +else: + print('No')" +p03433,s184352172,Wrong Answer,"N = int(input()) +A = int(input()) + +b = N%500 + +if A > b: + print(""Yes"") +else: + print(""No"")" +p02933,s985209938,Accepted,"a = int(input()) +s = input() + +if a >= 3200 : + print(s) +else : + print(""red"") +" +p02912,s729837620,Accepted,"import heapq +n, m = map(int, input().split()) +price = list(map(lambda x: int(x) * (-1), input().split())) + +heapq.heapify(price) +for _ in range(m): + max_price = -heapq.heappop(price) + heapq.heappush(price, -(max_price//2)) + +ans = -sum(price) +print(ans)" +p03719,s246514895,Accepted,"A, B, C = map(int, input().split()) +print('Yes' if A <= C <= B else 'No') +" +p03605,s677243918,Wrong Answer,"N = input() +if ""9"" in N: + print(""YES"") +else: + print(""NO"")" +p03611,s940442802,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +dict = {} + +for i in range(n): + if a[i] not in dict: + dict[a[i]] = 1 + else: + dict[a[i]] += 1 + +newd = sorted(dict.items()) +ans = 0 + +for j in range(len(dict)-2): + ans = max(ans,newd[j][1]+newd[j+1][1]+newd[j+2][1]) + +print(ans) + " +p03250,s580558503,Accepted,"n = list(map(int,input().split())) +n =sorted(n) +x = (n[-1])*10+(n[0]+n[1]) +print(x)" +p03061,s382565277,Wrong Answer,"# coding: UTF-8 +import sys +import numpy as np +import math + + +n = int(input()) +aList = list(map(int, input().split())) +gcdListLeft = [0 for i in range(n)] +gcdListRight = [0 for i in range(n)] + +tmp = aList[0] +for i in range(n): + gcdListLeft[i] = math.gcd(tmp, aList[i]) + +tmp = aList[n-1] +for i in range(n-1, -1, -1): + gcdListRight[i] = math.gcd(tmp,aList[i]) + +ans = gcdListRight[1] +for i in range(1,n-1): + ans = max(ans, math.gcd(gcdListLeft[i-1], gcdListRight[i+1])) +ans = max(ans, gcdListLeft[n-2]) +print(ans)" +p02642,s860618948,Accepted,"import collections + +n=int(input()) +arr=list(map(int,input().split())) +arr=sorted(arr) +s=set() +cnt=collections.Counter(arr) + +for i in range(n): + if arr[i] in s: + continue + if cnt[arr[i]]>=2: + s.add(arr[i]) + for j in range(2,10**6//arr[i]+1): + s.add(arr[i]*j) +ans=0 +for i in range(n): + if arr[i] in s: + continue + ans+=1 + +print(ans)" +p02714,s895399911,Accepted,"from itertools import product +n = int(input()) +s = input() +ans = s.count('R')*s.count('G')*s.count('B') +for i in range(n-2): + for j in range(i+1, n): + k = 2*j-i + if k <= n-1 and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: ans -= 1 +print(ans)" +p03760,s714974279,Accepted,"O = input() +E = input() +ans = '' +for i in range(len(E)): + ans += O[i] + ans += E[i] +if len(O)-len(E) == 1: + ans += O[len(O)-1] +print(ans)" +p03860,s989582779,Accepted,"a, s, c = map(str,input().split()) + +print(""A""+ s[0] +""C"")" +p03317,s072840475,Wrong Answer,"from math import ceil, floor + +N, K = map(int, input().split()) +A = list(map(int, input().split())) + +if N == K: + print(1) + exit() + +idx = 0 +for i in range(N): + if A[i] == 1: + idx = i + break + +cnt = 0 +if idx + 1 == K: + cnt += 1 +else: + cnt += ceil((idx + 1) / (K - 1)) + +if N - idx == K: + cnt += 1 +else: + cnt += ceil((N - idx) / (K - 1)) + +print(cnt) +" +p03251,s297420387,Accepted,"n,m,X,Y = map(int,input().split()) +#print(n,m,X,Y) +x=list(map(int,input().split())) +x.append(X) +y=list(map(int,input().split())) +y.append(Y) +#print(max(x),min(y)) +if X < Y: + if max(x) < min(y): + print('No War') + else: + print('War') +else: + print('War') +" +p03951,s380605135,Wrong Answer,"N=int(input()) +S=input() +T=input() +s=[str(c) for c in (S)] +t=[str(c) for c in (T)] +flag=0 +score=N +for i in range (N,2*N+1): + for j in range(N+N-i): + flag=0 + if s[i-N+j]!=t[j]: + flag=1 + if flag==0: + score=i + flag=2 + if flag==2: + break +if flag==1: + score=2*N +print(score)" +p02729,s715375079,Wrong Answer,"N,M = map(int, input().split()) +print(((N * (N - 1)) / 2 ) + ((M * (M - 1)) / 2 )) +" +p02675,s942077487,Accepted,"n = str(input()) +if int(n[-1]) in [2, 4, 5, 7, 9]: + print('hon') +elif int(n[-1]) in [0, 1, 6, 8]: + print('pon') +else: + print('bon')" +p02952,s376026089,Wrong Answer,"n = int(input()) +ans = 0 +if n < 10: + ans += n +else: + ans += 9 + if n < 1000: + ans += max(0, n-100) + else: + ans += 900 + if n < 100000: + ans += max(0, n-10000) + else: + ans += 90000 +print(ans) +" +p02726,s791326765,Accepted,"import collections +n, x, y = map(int, input().split()) +d = [[0]*(i+1) for i in range(n)] +x -= 1 +y -= 1 +for i in range(n): + for j in range(i+1): + d[i][j] = min(i-j, abs(x-j)+abs(y-i)+1) +L = [] +for i in range(n): + for dd in d[i]: + L.append(dd) +C = collections.Counter(L) +for i in range(1, n): + print(C[i])" +p03419,s824157415,Accepted,"N,M = map(int,input().split()) + +def solve(n,m): + if n == 1 and m == 1: + return 1 + elif n == 1: + return m - 2 + elif m == 1: + return n - 2 + else: + return (n-2)*(m-2) + +print(solve(N,M)) + " +p03795,s339501685,Accepted,"n = int(input()) +n1 = n*800 +n2 = n//15 +print(n1-(n2*200))" +p02706,s741322184,Accepted,"N,M=map(int,input().split()) +A=list(map(int, input().split())) + +r = N-sum(A) +if r < 0:r=-1 +print(r)" +p02859,s254922301,Wrong Answer,"# -*- coding: utf-8 -*- + +S1 = 1 + +r = input('radius = ') +R = int(r) +S2 = R ** 2 + +result = S2 / S1 +print(int(result)) +" +p02963,s288004466,Accepted,"def resolve(): + S = int(input()) + # S == 10 ** 9 * i + mod + i, mod = divmod(S, 10 ** 9) + # 求めたいのは、10 ** 9 * i - modなるiとmodの組 + # mod == 0のときはそのまま + if mod == 0: + print(0, 0, 10 ** 9, mod, 1, i) + # そうでないときはiをインクリしてmodの項を負にしてしまえばいい + else: + print(0, 0, 10 ** 9, 10 ** 9 * (i + 1) - S, 1, i + 1) + + +resolve()" +p02548,s218669277,Accepted,"ln=10**6+10 +sieve=[i for i in range(ln)] +p=2 +while p**2<=ln: + if sieve[p]==p: + for q in range(p*2,ln,p): + if sieve[q]==q: + sieve[q]=p + p+=1 +import collections +def primef(n): + prime_count=collections.Counter() + while n>1: + prime_count[sieve[n]]+=1 + n//=sieve[n] + return prime_count +n=int(input()) +ans=0 +for i in range(1,n): + t=1 + for j in primef(i).values(): + t=t*(j+1) + ans+=t +print(ans)" +p02917,s129649951,Accepted,"N = int(input()) +B = list(map(int, input().split())) +ans = 0 +ans+=B[0] + +for i in range(N-1): + if i= K: break +print(lst[i][0])" +p02854,s700396545,Accepted,"N = int(input()) +A = list(map(int, input().split())) +s = sum(A) +c = 0 +d = 10000000000000000 +a = 0 +for i in range(N): + c += 2*A[i] + if abs(c - s) < d: + a = i + d = abs(c - s) +a1 = sum(A[:(a+1)]) +a2 = sum(A[(a+1):]) +ans = abs(a1-a2) +print(ans)" +p03338,s324782126,Accepted,"n = int(input()) +s = input() +ans = 0 +for i in range(n-1): + cnt = 0 + for alp in range(ord('a'),ord('z')+1): + if chr(alp) in s[:i+1] and chr(alp) in s[i+1:]: + cnt += 1 + ans = max(ans, cnt) +print(ans) +" +p02718,s480222564,Wrong Answer,"line = input().rstrip().split("" "") +N = [str(i) for i in line] + +vote = input().rstrip().split(' ') +V = [str(i) for i in vote] +flag = 0 +C = N[0] +for i in range(int(C)): + if int(V[i]) > (1/(4*int(N[1]))): + flag = flag + 1 + +if flag >= int(N[1]) : + print(""Yes"") + +else: + print('No') + " +p02946,s542773765,Wrong Answer,"K,X=map(int,input().split()) +M=[] +for i in range (X-K+1,X+K): + M.append(i) +M.sort() +print(''.join(map(str,M)))" +p03767,s274358069,Accepted,"N = int(input()) +A = list(map(int, input().split())) +A.sort(reverse=True) +sum=0 +for i in range(2*N): + if i%2==1: + sum+=A[i] + +print(sum) + +" +p03109,s781385374,Accepted,"y, m, d = map(int, input().split('/')) + +if y < 2019: + print(""Heisei"") +elif y == 2019: + if m < 4 or (m == 4 and d <= 30): + print(""Heisei"") + else: + print(""TBD"") +else: + print(""TBD"")" +p03433,s900060069,Accepted,"n = int(input()) +a = int(input()) + +temp = n%500 +if temp<=a: + print(""Yes"") +else: + print(""No"")" +p02697,s156955879,Accepted,"N, M = map(int,input().split()) +res = [] +for i in range(M): + if i%2==0: + j = i//2 + #res.append(M-2*j) + print(""{} {}"".format(1+j,M+1-j)) + else: + j = i//2 + #res.append(M-1-2*j) + print(""{} {}"".format(M+2+j,2*M+1-j))" +p02676,s548748329,Accepted,"K = int(input()) +S = input() + +if(len(S) <= K): + print(S) +else: + for i in range(K): + print(S[i], end="""") + print(""..."") +" +p03030,s642611528,Wrong Answer,"n=int(input()) +R=[list(input().split()) + [i+1] for i in range(n)] +R.sort(key=lambda x: (x[0],-int(x[1]))) +print(R) +for r in R: + print(r[2])" +p03211,s722177237,Wrong Answer,"s= raw_input() +m = +float('inf') +for i in range(len(s)): + if len(s[i:i+3]) ==3: m = min(abs(int(s[i:i+3]) - 753), m) + if len(s[i:i+4]) ==4: m = min(abs(int(s[i:i+4]) - 753), m) +print m" +p02552,s743303137,Accepted,"x = int(input()) + +if x == 0: + print(1) +elif x == 1: + print(0) " +p02761,s286338360,Accepted,"n,m = map(int, input().split()) +s, c = [], [] +for i in range(m): + _s, _c = map(int, input().split()) + s.append(_s-1) + c.append(_c) + +for i in range(1000): + *t, = map(int, list(str(i))) + + if len(t) != n: + continue + + ok = True + for j in range(m): + if t[s[j]] != c[j]: + ok = False + break + + if ok: + print(i) + quit() + +print(-1)" +p03352,s151154197,Accepted,"def main(): + X = int(input()) + + ans = 1 + for i in range(2, 11): + for j in range(32): + if j ** i <= X: + if j ** i > ans: + ans = j ** i + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03557,s841926022,Accepted,"import itertools +import bisect +n = int(input()) +a=sorted(list(map(int, input().split()))) +b=sorted(list(map(int, input().split()))) +c=sorted(list(map(int, input().split()))) +cnt=0 + +for i in range(0,len(b)): + a_index = bisect.bisect_left(a,b[i]) + c_index = bisect.bisect_right(c,b[i]) + cnt+=a_index*(len(c)-c_index) + +print(cnt)" +p03456,s813335491,Accepted,"import sys +import math +import itertools +import bisect +from copy import copy +from collections import deque,Counter +from decimal import Decimal +def s(): return input() +def i(): return int(input()) +def S(): return input().split() +def I(): return map(int,input().split()) +def L(): return list(input().split()) +def l(): return list(map(int,input().split())) +def lcm(a,b): return a*b//math.gcd(a,b) +sys.setrecursionlimit(10 ** 9) +INF = 10**9 +mod = 10**9+7 + +a,b = S() +num = int(a+b) +for i in range(1,1000): + if i**2 == num: + print('Yes') + exit() +print('No')" +p04034,s940201460,Accepted,"n,m = map(int,input().split()) +canred = set() +canred.add(1) +balls = [1 for i in range(n)] +for i in range(m): + x,y = map(int,input().split()) + if x in canred: + canred.add(y) + balls[x-1]-=1 + balls[y-1] += 1 + if balls[x-1] == 0: + canred.discard(x) + + +print(len(canred))" +p03109,s025791524,Accepted,"s = input() +ss = s.split(""/"") +if int(ss[1]) < 5: + print (""Heisei"") +else: + print (""TBD"")" +p02601,s831416999,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) +c = 0 +while A >= B: + B *= 2 + c += 1 +while B >= C: + C *= 2 + c += 1 +print(""Yes"" if c<=K else ""No"")" +p02753,s432023850,Wrong Answer,"s = input() + +if s=='AAA' or s == 'BBB': + print('NO') +else: + print('YES')" +p02623,s740919022,Wrong Answer,"import numpy as np +n,m,k=map(int,input().split()) +A=[0]+list(map(int, input().split())) +B=[0]+list(map(int, input().split())) +ans=0 +a=np.cumsum(np.array(A)).tolist() +b=np.cumsum(np.array(B)).tolist() +for i in range(n+1): + if kk-a[i]: + j-=1 + ans=max(ans,i+j) +print(ans)" +p03126,s458725753,Accepted,"N, M = map(int, input().split()) +Ans = list(map(int, input().split())) +Ans = Ans[1:] +Ans = set(Ans) + +for _ in range(N-1): + A = list(map(int, input().split())) + A = set(A[1:]) + Ans = Ans & A +print(len(Ans))" +p03835,s460487532,Accepted,"K,S = list(map(int,input().split())) + +ans = 0 +for x in range(K+1): + for y in range(K+1): + z=S-x-y + if z <= K and z >= 0: + ans+=1 +# print(x,y,z) +print(ans)" +p02989,s125586869,Wrong Answer,"n = int(input()) +d = sorted(list(map(int, input().split()))) +h = int(len(d) / 2) +ans = 0 + +if d[h-1] != d[h]: + if d[h-2] != d[h-1] or d[h] != d[h+1]: + ans = d[h] - d[h-1] + +print(ans)" +p02688,s000617043,Accepted,"import math +from sys import stdin,stdout +#% 998244353 +from heapq import heapify,heappop,heappush + + +# T = int(stdin.readline()) +# for i in range(T): + #N=int(stdin.readline()) +N,K=list(map(int,stdin.readline().split())) +vis=set() +for k in range(K): + dk=int(stdin.readline()) + ar=list(map(int,stdin.readline().split())) + for sn in ar: + vis.add(sn) + +print(N-len(vis)) " +p02995,s081489187,Accepted,"a,b,c,d=map(int,input().split()) +import fractions +lcm=c*d//fractions .gcd(c,d) +C=b//c-(a-1)//c +D=b//d-(a-1)//d +CD=b//lcm-(a-1)//lcm +al=b-a+1 +print(al-C-D+CD)" +p02681,s380578700,Accepted,"S = list(str(input())) +T = list(str(input())) + +if S == T[:-1]: + print(""Yes"") +else: + print(""No"")" +p03544,s580562870,Accepted,"n = int(input()) +l = [] +if n == 0: + l.append(2) +elif n == 1: + l.append(1) +elif n >= 2: + l = [2, 1] + for i in range(2, n+1): + l.append(l[i-2]+l[i-1]) +print(l[-1])" +p03011,s078049412,Accepted,"# p,q,rに時間を整数で入力 +p,q,r = map(int,input().split()) +# それぞれ要する時間のリストを作成 +time = [p,q,r] +# 各時間の合計値から、地点間の最大の時間数を引く +print(sum(time)-max(time))" +p03206,s984260289,Wrong Answer,"d=int(input()) +if d==22: + print('Christmas Eve Eve Eve') +elif d==23: + print('Christmas Eve Eve') +elif d==24: + print('Christams Eve') +else: + print('Christams')" +p03042,s113357403,Accepted,"s = input() +if 1 <=int(s[0:2]) <= 12 and 1<= int(s[2:4]) <= 12: + print(""AMBIGUOUS"") +elif 1<= int(s[2:4]) <= 12: + print(""YYMM"") +elif 1<= int(s[0:2]) <= 12: + print(""MMYY"") +else : + print(""NA"")" +p03210,s010073430,Accepted,"x=int(input()) +if x==3 or x==5 or x==7:print('YES') +else:print('NO')" +p03387,s692579195,Wrong Answer,"A,B,C = map(int,input().split()) +candidates = [i for i in range((A+B+C)%3*2+(A+B+C),151,6)] +for i in candidates: + x = i/3 + if A<= x and B<= x and C<=x and ((x-A)+(x-B)+(x-C))%2==0: + print(int((i-(A+B+C))/2)) + break" +p02647,s754499112,Wrong Answer,"N, K = map(int, input().split()) +A = [int(i) for i in input().split()] + +for _ in range(43): + S = [0] * (N + 1) + for i, a in enumerate(A): + l = min(N-1, max(0, i-a)) + r = min(N-1, i+a) + S[l] += 1 + S[r+1] -= 1 + t = 0 + for i in range(N): + t += S[i] + A[i] = t +print(*A) +" +p02958,s763216235,Wrong Answer,"N = int(input()) +p = list(map(int, input().split())) +c = 0 +for i in range(1, N+1): + if i == p[1]: + c += 1 +if c == 0 or c == 2: + print(""YES"") +else: + print(""NO"")" +p03481,s120363859,Wrong Answer,"x,y=map(int,input().split()) +n=1 +while 2**n<=y/x: + n+=1 +print(n)" +p03644,s316845781,Wrong Answer,"N = int(input()) + +count_dic = {} +for i in range(N+1): + i_tmp = i + count = 0 + while True: + if i == 0: + break + elif i_tmp % 2 == 0: + i_tmp = i_tmp / 2 + count += 1 + else: + break + count_dic[i] = count + +print(max(count_dic, key=count_dic.get)) +" +p03107,s981391041,Accepted,"s = input() +x = s.count(""0"") +print(2 * min(x, len(s) - x))" +p02923,s749490340,Accepted,"n = int(input()) +h = list(map(int, input().split())) +ans = [] +res = 0 +nh = h[0] +for i in range(1, n): + if nh >= h[i]: + res += 1 + nh = h[i] + else: + ans.append(res) + res = 0 + nh = h[i] +ans.append(res) +print(max(ans))" +p02720,s969625966,Wrong Answer,"lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9] +k = int(input()) +index = 0 +while True: + if len(lun_luns) >= k: + break + num = lun_luns[index] + mod = num % 10 + n = num * 10 + if mod == 9: + lun_luns.extend([n+mod-1, n+mod]) + else: + lun_luns.extend([n+mod-1, n+mod, n+mod+1]) + index += 1 +print(lun_luns[k-1])" +p02973,s996072460,Wrong Answer,"import bisect +from collections import deque +def LIS(a): + lis = deque() + lis.append(-1) + for i in range(len(a)): + index = bisect.bisect_left(lis,a[i]) + if i == 0: + lis.appendleft(a[i]) + else: + lis[index-1] = a[i] + return len(lis) + +def main(): + n = int(input()) + a = [int(input()) for _ in range(n)] + print(LIS(a)) + +if __name__ == ""__main__"": + main()" +p02784,s345022881,Accepted,"H, N = map(int, input().split()) +A = list(map(int, input().split())) + +s = sum(A) +if s >= H: print('Yes') +else: print('No')" +p02645,s200832360,Accepted,"import sys +input = sys.stdin.readline +def main(): + S = input().rstrip() + print(S[:3]) + +if __name__ == '__main__': + main()" +p02631,s107360561,Accepted,"#!python3 + +import sys +iim = lambda: map(int, sys.stdin.readline().rstrip().split()) +from operator import xor +from functools import reduce + +def resolve(): + it = map(int, sys.stdin.read().split()) + N = next(it) + A = list(it) + x1 = reduce(xor, A) + + print(*map(lambda x: x ^ x1, A)) + + +if __name__ == ""__main__"": + resolve() +" +p03456,s491349201,Wrong Answer,"a,b=input().split() +c = int(a+b) +for i in range(1, 101): + if c == i*i: + print('Yes') + exit() +print('No') +" +p02555,s472843969,Accepted,"S=int(input()) + +MOD = 10 ** 9 + 7 + +if S <= 2: + print('0') + exit(0) +elif 3 <= S <= 5: + print('1') + exit(0) + +s = [0] * (S+1) +s[1] = 0 +s[2] = 0 +s[3] = 1 +s[4] = 1 +s[5] = 1 + + +def calc(n): + tmp = 0 + for i in range(n-3,2,-1): + tmp += s[i]%MOD + return tmp+1 + +result = 0 +for i in range(5,S+1): + s[i] = calc(i) + +print(s[S]%MOD)" +p03281,s250827567,Accepted,"N = int(input()) +count = 0 +from math import sqrt +for i in range(1,N+1)[::-1]: + if i%2==1: + yakusu = 0 + for j in range(1,i+1): + if i%j==0: + yakusu += 1 + + if yakusu == 8: + count += 1 +print(count)" +p03437,s228681172,Wrong Answer,"x,y=map(int,input().split()) +if(x%y==0 or y%x==0): + print('-1') +else: + for i in range(1, 1000000): + if(x*i%y != 0): + print(x*i) + break" +p03433,s049466759,Accepted,"n=int(input()) +a=int(input()) +print(""Yes"" if n%500<=a else ""No"")" +p02707,s919870084,Accepted,"import collections + +N=int(input()) +X=list(map(int, input().split())) +c = collections.Counter(X) + +for A in range(1,N+1): + print(c[A])" +p03679,s434726960,Accepted,"x, a, b = list(map(int, input().split())) +if b-a<=x: + if a-b>=0: + print('delicious') + else: + print('safe') +else: + print('dangerous') +" +p03352,s408742389,Wrong Answer,"from collections import Counter +import sys + +X = int(input()) +num = [] + +if X == 1: + print(1) + sys.exit() + +for j in range(1, X): + tmp = j + 1 + lis = [] + while tmp != 1: + for i in range(2, tmp+1): + if tmp % i == 0: + lis.append(i) + tmp = tmp // i + break + if len(Counter(lis)) == 1 and len(lis) > 1: + num.append(j+1) + +print(max(num))" +p02689,s095254129,Accepted,"N, M = map(int, input().split()) +graph = dict(zip( + list (range(1, N+1)), + [set() for i in range(N)] +)) +height=list(map(int, input().split())) + +for i in range(M): + src, dest = map(int, input().split()) + graph[src].add(dest) + graph[dest].add(src) + + +count = 0 +for currNode in graph: + flag = True + for node in graph[currNode]: + if height[currNode-1] <= height[node-1]: + flag = False + + if flag: + count += 1 + + +print(count)" +p02639,s667705360,Wrong Answer,"a = list(map(int, input().split())) + +for i in range(len(a)): + if a[i] == 0: + print(i) + break + " +p02791,s650232607,Accepted,"# -*- coding: utf-8 -*- + +N = int(input()) +P = [int(i) for i in input().split()] + +# 最小の値を記録していく +minimum = P[0] +count = 0 + +for p in P: + if p <= minimum: + count += 1 + minimum = p + +print(count)" +p02888,s174933428,Wrong Answer,"import bisect +N = int(input()) +l = [int(i) for i in input().split()] +count = 0 +l_new = sorted(l) +for i in range(N-2): + for j in range(i+1,N-1): + left = bisect.bisect_right(l_new,abs(l_new[i]-l_new[j])) + right = bisect.bisect_left(l_new,l_new[i] + l_new[j]) + count += right - left + + if left <= i < right: + count -= 1 + if left <= j < right: + count -= 1 +print(count//3)" +p02946,s725438617,Accepted,"# input +K, X = map(int, input().split()) +R_max = -(10 ** 6) +L_max = 10 ** 6 + +# check +result = [X] +for R, L in zip(range(K - 1, -1, -1), range(0, K, 1)): + result += [X - r for r in range(1, R + 1) if X - r >= R_max and X - r not in result] + result += [X + l for l in range(1, L + 1) if X + l <= L_max and X + l not in result] + +# output +result.sort() +op = """" +for res in result: + op += str(res) + op += "" "" + +print(op[:-1])" +p04005,s707490922,Accepted,"A, B, C = map(int, input().split()) +x = max(A, B, C) +y = min(A, B, C) +z = A+B+C-(x+y) +if x % 2 == 0: + ans = 0 +else: + ans = y*z +print(ans) +" +p02582,s050453731,Wrong Answer,"s = input() +s = list(s) +streak = 0 +max_streak = 0 +for i in s: + if s == ""R"": + streak += 1 + max_streak = max(streak, max_streak) + else: + streak = 0 +print(streak)" +p03012,s136208514,Accepted,"n = int(input()) +l = list(map(int,input().split())) +ans = 100 + +for i in range(n-1): + if abs(sum(l[:i+1]) - sum(l[i+1:])) < ans: + ans = abs(sum(l[:i+1]) - sum(l[i+1:])) +print(ans)" +p02730,s098229568,Accepted,"s = input() + +s_1=s[:((len(s)-1)//2)] +s_2=s[((len(s)+3)//2)-1:] +#print(s_1) +#print(s_2) + +flag = True + +for a in range(len(s)//2): + if s[a] != s[-(a+1)]: + flag =False + +for a in range(len(s_1)//2): + if s_1[a] != s_1[-(a+1)]: + flag =False + +for a in range(len(s_2)//2): + if s_2[a] != s_2[-(a+1)]: + flag =False + +if flag: + print(""Yes"") +else: + print(""No"") +" +p02843,s653546571,Accepted,"n = str(input()) +if len(n) <= 2: + print(0) +else: + a = n[0:-2] + tens = int(n[-2]) + need = tens*2 + ones = int(n[-1]) + if ones == 0: + need +=0 + elif ones <= 5: + need += 1 + else: + need +=2 + if need <= int(a): + print(1) + else: + print(0) +" +p02787,s048465253,Wrong Answer,"H,N = map(int,input().split()) +AB = [list(map(int,input().split())) for _ in range(N)] +A = [AB[i][0] for i in range(N)] +B = [AB[i][1] for i in range(N)] +dp = [10**9]*(2*10**4+1) + +for h in range(H): + for i in range(N): + if h != 0: + dp[h+A[i]] = min(dp[h+A[i]],dp[h]+B[i]) + else: + dp[A[i]] = min(dp[A[i]],B[i]) + +ans = 10**9 +for i in range(H,2*H+1): + ans = min(ans,dp[i]) + +print(ans)" +p03951,s951640508,Accepted,"N = int(input()) +s = input() +t = input() + +for i in range(0, 101): + temp = s[:i] + t + if temp[:N] == s: + print(N + i) + break" +p02832,s030833131,Accepted,"n = int(input()) +a = list(map(int, input().split())) +r, cnt = 1, 0 +for i in a: + if r == i: + r += 1 + else: + cnt += 1 + +print(cnt) if a.count(1) else print(-1) +" +p03379,s098060272,Accepted,"n=int(input()) +x=list(map(int,input().split())) +s=sorted(x) +p,q=s[n//2-1],s[n//2] +for i in x: + if i<=p: + print(q) + else: + print(p)" +p02577,s871007662,Accepted,"N = int(input()) + +if N % 9 == 0: + print('Yes') +else: + print('No') +" +p02682,s351566781,Wrong Answer,"import math + +a,b,c,k=map(int,input().split()) + +if k<=a+b: + print(a) + exit() +print(a-(k-a-b))" +p02628,s749573324,Accepted,"n,k=map(int,input().split()) +ps=sorted(list(map(int,input().split()))) +print(sum(ps[:k])) +" +p02882,s411358922,Accepted,"import numpy +a,b,x=map(int,input().split()) +V=a*a*b +if x<=V/2: + y=2*x/b/a + theta=numpy.arctan(b/y) + print(theta*360/2/numpy.pi) +else: + x=V-x + y=2*x/a/a + theta=numpy.arctan(y/a) + print(theta*360/2/numpy.pi) +" +p02958,s875363829,Accepted,"N = int(input()) +p = list(map(int, input().split())) + +p_sorted = sorted(p) + +is_changed = [0 if x==y else 1 for x,y in zip(p, p_sorted)] + +if sum(is_changed) <= 2: + print(""YES"") +else: + print(""NO"")" +p03163,s900270329,Accepted,"N, W = map(int, input().split()) +wv = [list(map(int, input().split())) for _ in range(N)] + +dp = [[0] * (W + 1) for _ in range(N + 1)] + +for i in range(0, N): + w = wv[i][0] + v = wv[i][1] + for j in range(W + 1): + if j - w >= 0: + dpp = dp[i][j - w] + v + dp[i + 1][j] = max(dp[i + 1][j], dpp) + dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) + +print(max(dp[-1]))" +p02665,s557703849,Wrong Answer,"def main(): + N = int(input()) + A = list(map(int, input().split())) + perfect = [2**n for n in range(N+1)] + for n in range(N): + if perfect[n] <= A[n]: + print(-1) + break + remain = N - n + deleted = [2**(i+1) for i in range(remain)] + for i in range(remain): + perfect[n+i+1] -= deleted[i]*A[n] + else: + print(sum(perfect)) +main()" +p03785,s576770975,Wrong Answer,"n,c,k = map(int,input().split()) +t = list(int(input()) for i in range(n)) +t.sort() + +bus = 1 +leave = t[0] + k +temp = 1 +ans = 0 + +for i in range(1,n): + if temp == 0 or leave < t[i]: + ans += 1 + temp = 1 + leave = t[i] + k + else: + bus += 1 + +print(ans+1) " +p03387,s234803677,Accepted,"a,b,c = map(int,input().split()) +m1 = max(a,b,c) +m3 = min(a,b,c) +m2 = a+b+c-m1-m3 +m = m2-m3 +n = m1-m2 +if m%2 == 0: + print((m+2*n)//2) +else: + print((m+2*n+3)//2)" +p03433,s711586858,Accepted,"N=int(input()) +A=int(input()) + +if (N%500) <=A: + print('Yes') +else: + print('No')" +p02705,s001123202,Accepted,"import math + +r = int(input()) + +l = (r*2) * math.pi + +print(l)" +p02719,s548110887,Accepted,"N, K = map(int,input().split()) +A = 0 +A = N % K +print(min(A, K - A))" +p03042,s413833771,Wrong Answer,"s = list(input()) +ans = 'NA' +if 12 < int(s[0]+s[1]): + if 1<=int(s[2]+s[3]) and int(s[2]+s[3])<=12: + ans = 'YYMM' +else: + if 1<=int(s[0]+s[1]) and int(s[0]+s[1])<=12: + ans = 'AMBIGUOUS' +print(ans)" +p03437,s956739698,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10 ** 8) +INF = float('inf') +MOD = 10 ** 9 + 7 + + +def main(): + X, Y = map(int, readline().split()) + if X % Y == 0: + print('-1') + else: + print(X) + + +if __name__ == '__main__': + main() +" +p02631,s054910690,Accepted,"N = int(input()) +A = list(map(int, input().split())) + + +x = 0 +for a in A: + x ^= a +ans = [x ^ a for a in A] + +print(*ans)" +p03943,s804896561,Accepted,"a=list(map(int,input().split())) +a.sort() +if a[0]+a[1]==a[2]: + print('Yes') +else: + print('No')" +p03252,s079695411,Accepted,"import sys +from collections import defaultdict + +s, t = sys.stdin.read().split() +n = len(s) + +def main(): + correspondence = defaultdict(str) + for i in range(n): + if not correspondence[s[i]]: + correspondence[s[i]] = t[i] + else: + if correspondence[s[i]] != t[i]: + return 'No' + + v = correspondence.values() + return 'Yes' if len(v) == len(set(v)) else 'No' + +if __name__ == '__main__': + ans = main() + print(ans)" +p02796,s056334689,Accepted,"def main(): + N = int(input()) + L = [] + for i in range(N): + xi, li = map(int, input().split()) + s = xi - li + f = xi + li + L.append((f, s)) + + L.sort() + + ans = 0 + finish = -float(""inf"") + for i in L: + if finish <= i[1]: + ans += 1 + finish = i[0] + + print(ans) + +if __name__ == ""__main__"": + main() + +" +p02708,s627433054,Accepted,"N,K=map(int, input().split()) +ans=0 +mod=10**9+7 +for i in range(K,N+2): + if i==K: + MIN=sum(list(range(0,K)))%mod + MAX=sum(list(range(N,N-K,-1)))%mod + else: + MIN+=(i-1)%mod + MAX+=(N+1-i)%mod + ans+=(MAX-MIN+1)%mod + ans%=mod + +print(ans)" +p03208,s008158706,Accepted,"N , M = (map(int , input().split())) +tree = [] +for i in range(N): + tree.append(int(input())) +sort_tree = sorted(tree) +print(min([sort_tree[i+M-1] - sort_tree[i] for i in range(N-M+1)]))" +p03796,s207950323,Wrong Answer,"n=int(input()) +m=n +for i in range(1,n): + m=n*i + continue +print(m%(10**9+7))" +p03211,s802465272,Wrong Answer,"table = list(map(int, input())) +diff_nagomi = 1000 +for i in range(len(table)-2): + diff = table[i] * 100 + table[i + 1] * 10 + table[i + 2] - 753 + if diff_nagomi > diff: + ans = diff +print(abs(ans)) +" +p02811,s403919800,Wrong Answer,"K,X=list(map(int,input().split(' '))) +if X>=K*500: + print('Yes') +else: + print('No')" +p02767,s929634637,Accepted,"N = int(input()) +X = list(map(int, input().split())) +_min = min(X) +_max = max(X) +_sum = 1000000000 +for i in range(_min, _max+1): + temp = 0 + for x in X: + temp += (x - i) * (x - i) + if temp < _sum: + _sum = temp +print(_sum) +" +p03017,s875813766,Accepted,"n, a, b, c, d = map(int, input().split()) + +s = input() + +if s.find('##',a,max(c, d)) < 0: + if c=0: + print('Yes') + else : + print('No') +else : + print('No')" +p02952,s650586748,Accepted,"N = int(input()) + +count = 0 +for n in range(1, N+1): + if (len(str(n)) % 2 == 1): + count += 1 + +print(count)" +p02660,s431500998,Wrong Answer,"def main(): + n = int(input()) + ans = 0 + + e = 1 + for fac in (2, *(x * 2 + 3 for x in range(1000))): + while n % (div := pow(fac, e)) == 0: + n //= div + ans += 1 + e += 1 + + while n % fac == 0: + n //= fac + + if fac * 3 > n: + break + e = 1 + + if n != 1: + ans += 1 + + print(ans) + + +if __name__ == '__main__': + main() +" +p02862,s841462726,Wrong Answer,"m = 10 ** 9 + 7 +def cmb(x,y): + r=1 + for i in range(1,y+1): + r=(r*(x-i+1)*pow(i,m-2,m))%m + return r + +x, y = map(int, input().split()) +if (2 * x - y) % 3 == 0 and (2 * y - x) % 3 == 0: + print(cmb(int((x + y) / 3), int((2 * y - x) / 3))) +else: + print(0)" +p02695,s025723104,Wrong Answer,"N, M, Q = map(int, input().split()) +X = [] +for _ in range(Q): + a, b, c, d = map(int, input().split()) + X.append((a, b, c, d)) + +def calc(L): + s = 0 + for a, b, c, d in X: + if L[b] - L[a] == c: s += d + return s + +def rec(L): + if len(L) == N + 1: + return calc(L) + ma = 0 + for i in range(L[-1], M+1): + ma = max(ma, rec(L + [i])) + return ma + +print(rec([0]))" +p02665,s706586688,Accepted,"N=int(input()) +*A, = map(int,input().split()) + +if N==0 and A[0] == 1: + print(1) + exit() +if A[0] != 0: + print(-1) + exit() + +INF = 1e18 +B = [1]*(N+1) +for i,a in enumerate(A[1:],1): + B[i] = min(INF,B[i-1]*2 - a) + +ans = 0 +p = 0 +for i,a in enumerate(A[::-1]): + i = N - i + m = B[i] + if p>2*m: + ans = -1 + break + p = min(m,p)+a + ans += p + +print(ans)" +p03943,s429191205,Wrong Answer,"a, b, c = map(int, input().split()) +list = [a, b, c] +list.sort() +if list[0] + list[1]: + print(""Yes"") +else: + print(""No"") +" +p03146,s482370263,Wrong Answer,"s = int(input()) + +lis = list() + +while True: + if (s % 2) == 0: + s = s / 2 + if s in lis: + break + lis.append(int(s)) + else: + s = 3*s + 1 + if s in lis: + break + lis.append(int(s)) + +print(len(lis)+2)" +p02820,s609804442,Wrong Answer,"n, k = map(int, input().split()) +r, s, p = map(int, input().split()) +t = input() + +dp = [0] * (n) + +for i in range(n): + if t[i] == ""r"": + dp[i] = p + elif t[i] == ""s"": + dp[i] = r + elif t[i] == ""p"": + dp[i] = s + + if k <= i: + if dp[i] == dp[i-k]: + dp[i] = 0 + +print(sum(dp))" +p03472,s125291786,Accepted,"from math import ceil +n,h = map(int,input().split()) +lst = [list(map(int,input().split())) for _ in range(n)] +max_a = max([lst[i][0] for i in range(n)]) +b = sorted(lst[i][1] for i in range(n))+[0] +for i in range(n-1,-1,-1): + b[i] += b[i+1] +ans = 10**10 +for i in range(n+1): + hp = h-b[i] + t = max(0, ceil(hp/max_a)) + t += n-i + ans = min(ans, t) +print(ans)" +p03127,s573602868,Accepted,"from math import gcd + +n = int(input()) +a = list(map(int, input().split())) + + +for i in range(n-1): + a[i+1] = gcd(a[i], a[i+1]) + +print(a[n-1])" +p03623,s653946362,Accepted,"x, a, b = map(int, input().split()) + +if abs(x-a) > abs(x-b): + print('B') +else: + print('A')" +p03220,s523573314,Accepted,"n=int(input()) +t,a=[int(x) for x in input().split()] +h=[int(x) for x in input().split()] + +avg = [abs(t-hi*0.006-a) for hi in h] + +print(avg.index(min(avg))+1)" +p02594,s184518149,Accepted,"# H, N = [int(i) for i in input().split()] +X = int(input()) +if X >= 30: + print(""Yes"") +else: + print(""No"") +" +p02797,s693973927,Accepted,"# -*- coding: utf-8 -*- +n,k,s = map(int, input().split()) + +if s==10**9: + ans = [s]*k + [1]*(n-k) +else: + ans = [s]*k + [10**9]*(n-k) + +print(*ans)" +p03720,s774557599,Accepted,"n, m = map(int, input().split()) + +m_a = [] +m_b = [] +for i in range(m): + m_a_tmp, m_b_tmp = map(int, input().split()) + m_a.append(m_a_tmp) + m_b.append(m_b_tmp) + +n_n = [0 for i in range(n)] + +for a,b in zip(m_a, m_b): + n_n[a-1] += 1 + n_n[b-1] += 1 + +for n in n_n: + print(n) + + " +p03011,s205198389,Accepted,"time = list(map(int,input().split())) + +time.sort() + +print(time[0]+time[1])" +p04019,s189474377,Wrong Answer,"s = input() +if s.count('N') == s.count('S'): + if s.count('W') == s.count('E'): + print('Yes') + exit() +print('No')" +p02888,s000853490,Accepted,"import bisect +n = int(input()) +*l, = sorted(map(int, input().split())) + +ans = 0 +for i in range(n): + for j in range(i+1, n): + bc = l[i]+l[j] + ans += bisect.bisect_left(l, bc)-(j+1) + +print(ans) +" +p04011,s643019382,Wrong Answer,"n,k,x,y=[int(input()) for _ in range(4)] +print(x*k+x*max(0,n-k))" +p03486,s722825369,Accepted,"s = input() +t = input() + +s = sorted(s) +t = sorted(t,reverse = True) +ans = ""Yes"" if s < t else ""No"" +print(ans)" +p03286,s078522265,Accepted,"import math +N = int(input()) +if N == 0: + print(0) + exit() +ans = """" +while N != 1: + if N % 2 == 0: + N //= (-2) + ans = ""0"" + ans + else: + if N > 0: + N //= (-2) + N += 1 + ans = ""1"" + ans + else: + N //= (-2) + N += 1 + ans = ""1"" + ans +ans = ""1"" + ans +print(ans) +" +p02791,s501605162,Wrong Answer,"n=int(input()) +p=list(map(int,input().split())) +c=0 +min=2*10**5 +for i in range(n): + if (p[i]= m: + ans = m//2 +else: + ans = n + (m - 2*n)//4 +print(ans)" +p03607,s960171606,Wrong Answer,"n = int(input()) +a = [] +for i in range(n): + a.append(int(input())) +a.sort() +jud = 1 +q = a[0] +ans = 0 +for i in range(n): + if(q==a[i]): + jud += 1 + else: + if(jud%2==1): + ans += 1 + jud = 1 +if (jud%2==1)and(jud>2): + ans += 1 +print(ans) +" +p02787,s362566548,Accepted,"H,N = map(int,input().split()) +magic = [list(map(int,input().split())) for i in range(N)] + +INF = 10**10 + +dp = [INF for i in range(H+1)] +dp[0] = 0 + +for i in range(1,H+1): + for j in range(N): + dp[i] = min(dp[max(0,i-magic[j][0])]+magic[j][1],dp[i]) +print(dp[H]) +" +p02553,s889177548,Accepted,"a, b, c, d = map(int, input().split()) + +ac = a * c +ad = a * d +bc = b * c +bd = b * d + +ans = max(ac, ad, bc, bd) + +print(ans)" +p03309,s395463601,Accepted,"n = int(input()) + +a = list(map(int, input().split())) + +sorted_num = sorted([a[i] - i for i in range(len(a))]) + +b = sorted_num[len(sorted_num)//2] +print(sum([abs(b-i) for i in sorted_num])) +" +p03797,s574085229,Wrong Answer,"N,M = list(map(int,input().strip().split())) + +if N > M*2: + res = M // 2 +else: + res = (M - 2*N)//4 + N + +print(res)" +p03821,s566627436,Wrong Answer,"import sys +import numpy as np +input = sys.stdin.readline + +N = int(input()) +A = [] +B = [] +for _ in range(N): + a,b = list(map(int,input().split())) + A.append(a) + B.append(b) +cnt = 0 +for i in range(N-1,-1,-1): + if A[i]%B[i] == 0: + cnt += 0 + else: + cnt += B[i] - (A[i]+cnt)%B[i] +print(cnt) +" +p03243,s659647995,Wrong Answer,"n = input() +for i in range(int(n), 1000): + if str(i).count(n[0]) == 3: + print(i) + exit()" +p02720,s018071654,Accepted,"import collections + +k = int(input()) + +li = [str(i) for i in range(1,10)] +q = collections.deque(li) +count = 0 +n = 10 ** 6 + +for i in range(1, n): + a = q.popleft() + count += 1 + if count == k: + print(a) + exit(0) + num = int(a[-1]) + if num != 0: + aa = a + str(num-1) + q.append(aa) + aa = a + str(num) + q.append(aa) + if num != 9: + aa = a + str(num+1) + q.append(aa)" +p03059,s750418508,Accepted,"a,b,c=map(int,input().split()) +n=len([i for i in range(1,c+1) if i%a==0]) +print(b*n) +" +p02708,s131179647,Accepted,"def main(): + n, k = [int(e) for e in input().split()] + mod = 10 ** 9 + 7 + + ans = 0 + for ki in range(k, n + 2): + ans += n * (n + 1) // 2 - (n - ki) * (n - ki + 1) // 2 - \ + (ki * (ki + 1) // 2 - ki) + 1 + ans %= mod + + print(ans) + + +if __name__ == '__main__': + main() +" +p02747,s673137766,Accepted,"S = input() + +HI ='hi' + +flag = False + +for i in range(5): + if S == HI * (i +1): + flag = True + break + +if flag == True: + print('Yes') +else: + print('No')" +p03486,s277693670,Accepted,"s,t=list(input()),list(input()) +if s==t: print('No');exit() +s.sort();t.sort(reverse=True) +l=[''.join(s),''.join(t)] +r=sorted(l) +print('Yes' if l==r else 'No')" +p03071,s017520883,Accepted,"A,B = map(int,input().split()) +if abs(A-B) >= 2: + print(max(A,B)*2-1) +else: + print(A+B)" +p02818,s734786739,Wrong Answer,"a,b,k = map(int,input().split()) +if a >= k: + print(a-k,b) +else: + print(0,b-(k-a))" +p02793,s499693489,Accepted,"from functools import reduce +import fractions + +def lcm_base(x, y): + return (x * y) // fractions.gcd(x, y) + +def lcm(*numbers): + return reduce(lcm_base, numbers, 1) + +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +N = int(input().rstrip()) +As = input().rstrip().split("" "") +As = [int(p) for p in As] + +cand = lcm_list(As) + +sum = 0 + +for num in As: + sum = sum + cand // num + +print(sum % int(1e9+7) ) +" +p02756,s962723069,Accepted,"S = input() +Q = int(input()) + +T = """" +for i in range(Q) : + Query = list(input().split()) + if Query[0] == ""1"" : + S, T = T, S + elif Query[0] == ""2"" : + if Query[1] == ""1"" : + T = T + Query[2] + elif Query[1] == ""2"" : + S = S + Query[2] + +T = T[::-1] +T = T + S +print(T)" +p03693,s016595497,Accepted,"#!/usr/bin/env python3 + +r, g, b = input().split() + +n = int(r+g+b) + +if n % 4 == 0: + print('YES') +else: + print('NO') +" +p02988,s162009702,Wrong Answer,"n=int(input()) + +t = input().split() + +count = 0 + +for i in range(n-2): + if t[i] <= t[i+1] and t[i+1] <= t[i+2] or t[i] >= t[i+1] and t[i+1] >= t[i+2]: + count += 1 +print(count) " +p03796,s526539912,Accepted,"import math +N = int(input()) +print(math.factorial(N) % (10**9+7)) +" +p02727,s549817261,Accepted,"def main(): + x, y, a, b, c = map(int, input().split()) + red_apples = sorted(list(map(int, input().split())), reverse=True)[:x] + green_apples = sorted(list(map(int, input().split())), reverse=True)[:y] + colorless_apples = sorted(list(map(int, input().split())), reverse=True)[:min(x+y, c)] + + print(sum(sorted(red_apples + green_apples + colorless_apples, reverse=True)[:x+y])) + + +if __name__ == '__main__': + main() +" +p03434,s568129326,Accepted,"n=int(input()) +l=list(map(int,input().split())) +l.sort(reverse=True) +x,y=0,0 +for i in range(n): + if(i%2==0): + x+=l[i] + else: + y+=l[i] +print(abs(x-y))" +p02771,s553801301,Accepted,"print('Yes' if len(set(map(int, input().split()))) == 2 else 'No')" +p02606,s694840016,Wrong Answer,"L,R,d= map(int, input().split()) +if d==0: + print(0) +else: + print((R-L+1)//d)" +p02996,s561657989,Accepted,"import numpy as np + +N = int(input()) +AB = [] +for _ in range(N): + a, b = map(int, input().split()) + AB.append((a, b)) +AB = sorted(AB, key=lambda x: x[1]) +A, B = list(zip(*AB)) +B = np.array(B) +cumsum_A = np.array(A).cumsum() +# print('cumsum_A', cumsum_A) + +ans = 'Yes' if np.count_nonzero(B >= cumsum_A) == N else 'No' +print(ans) +" +p03449,s147447462,Wrong Answer,"n = int(input()) +a = [] +for _ in range(2): + a.append(list(map(int, input().split("" "")))) + +res = 0 +for i in range(n): + res += a[0][i] + + row_1 = sum(a[0][i + 1:n]) + row_2 = sum(a[1][i + 1:n]) + if row_1 <= row_2: + res += sum(a[1][i:n]) + break + +print(res) +" +p03696,s367159470,Wrong Answer,"from collections import deque +N = int(input()) +S = list(input()) +T = deque(S[:]) +ins = [] +for i in range(N-1): + if not (S[i]=='(' and S[i+1]==')'): + if S[i] == '(': + T.append(')') + else: + T.appendleft('(') + +print(''.join(T)) + +" +p02718,s712527641,Accepted,"n,m = map(int,input().split()) +a = list(map(int,input().split())) +count = 0 +for i in range(n): + if sum(a)/(4*m) <= a[i]: + count+=1 +if count >= m: + print('Yes') +else: + print('No')" +p03371,s326883898,Accepted,"A, B, C, X, Y = map(int, input().split()) +ans = float('inf') +for c_2 in range(10**5 + 1): + a = max(X - c_2, 0) + b = max(Y - c_2, 0) + ans = min(ans, a * A + b * B + c_2 * C * 2) +print(ans)" +p03286,s152337421,Wrong Answer,"N = int(input()) +ans = """" +while N: + if N % 2: + ans += ""1"" + N = -((N - 1) // 2) + else: + ans += ""0"" + N = -(N // 2) +print(ans)" +p02688,s057215072,Accepted,"N, K = map(int, input().split()) +okashi_set = set([]) +for i in range(K): + d_i = int(input()) + A_d = list(map(int, input().split())) + for A_d_j in A_d: + okashi_set.add(A_d_j) +print(N-len(okashi_set))" +p02923,s395666848,Wrong Answer,"N = int(input()) +H = list(map(int, input().split())) +ans = 0 +for i in range(N-1): + if H[i] < H[i+1]: + ans = 0 + else: + ans += 1 +print(ans) +" +p02802,s560629788,Wrong Answer,"n, m = map(int, input().split()) +ans_ac = 0 +ans_wa = 0 +lst = [] +for i in range(m): + p, s = input().split() + if p in lst: + continue + if s == 'WA': + ans_wa += 1 + else: + ans_ac += 1 + lst.append(p) +print(ans_ac, ans_wa)" +p03485,s645686621,Wrong Answer,""""""" +author : halo2halo +date : 29, Jan, 2020 +"""""" + +import sys +import itertools + +# import numpy as np + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +A, B = map(int, readline().split()) + +print((A+B-1)//2) +" +p03472,s895668792,Wrong Answer,"N, H = map(int, input().split()) +A = 0 +B = [] + +for i in range(N): + a, b = map(int, input().split()) + A = max(A, a) + B.append(b) + +B = sorted(B, reverse=True) + [0] + +i = 0 +while B[i] > A: + i += 1 +B = B[:i] + +for i in range(len(B)): + H -= B[i] + if H < 0: + print(i + 1) + exit() + +print(i + 1 + (H - 1) // A + 1) +" +p03073,s356528783,Wrong Answer,"s = input() +n = len(s) +w = 0 +for i in range(n): + w += (s[i]!=""0"")**(i%2) +print(min(w,n-w))" +p02836,s881373415,Accepted,"s = input() +res = 0 +for i, j in zip(s, s[::-1]): + if i != j: + res += 1 +print(res // 2) +" +p03545,s196349745,Accepted,"num = list(map(int,list(str(input())))) + +for i in range(2**3): + temp = 0 + + for j in range(len(num)): + if j == 0: + temp = num[j] + ans = str(num[j]) + continue + + if ((i >> j-1)&1): + temp = temp + num[j] + ans = ans + ""+"" + str(num[j]) + + elif not ((i >> j-1)&1): + temp = temp - num[j] + ans = ans + ""-"" + str(num[j]) + + if temp == 7: + ans = ans + ""=7"" + print(ans) + break" +p03417,s091065651,Wrong Answer,"n,m=map(int, input().split()) +n-=2 +m-=2 +if n<0 and m<0: + n,m=0,0 +elif n<=0: + n=1 +elif m<=0: + m=1 +print(n*m)" +p03095,s061474452,Wrong Answer,"from collections import Counter + +N = int(input()) +S = input() + +d = Counter(S) + +# print(d) +ans = 1 +for k, v in d.items(): + ans *= v + 1 +print(ans - 1) + +" +p02582,s652075608,Accepted,"def Next(): return input() +def NextInt(): return int(Next()) +def NextInts(): return map(int,input().split()) +def Nexts(): return map(str,input().split()) +def NextIntList(): return list(map(int,input().split())) +def RowInts(n): return [input() for i in range(n)] + +s = input() +ans = 0 +tmp = 0 +for i in s: + if i == 'R': + tmp += 1 + ans = max(ans, tmp) + else: + tmp = 0 + +print(ans)" +p03723,s792307086,Accepted,"a,b,c=map(int,input().split()) +cnt=0 +if any((a%2==1,b%2==1,c%2==1)): + print(0) + exit() +if a==b==c and a%2==0: + print(-1) + exit() +while a%2==b%2==c%2==0: + a,b,c=(b+c)/2,(a+c)/2,(a+b)/2 + cnt+=1 +print(cnt) +" +p02676,s281190643,Accepted,"#-*-coding:utf-8-*- + +def main(): + k = int(input().strip()) + s = input().strip() + if len(s) <= k: + print(s) + elif len(s) > k: + print(s[:k]+""..."") + +if __name__==""__main__"": + main()" +p03042,s003516453,Accepted,"S=input() +a=int(S[:2]) +b=int(S[2:]) +ans=0 +lab=[""NA"",""MMYY"",""YYMM"",""AMBIGUOUS""] + +if a>=1 and a<=12: + ans+=1 + +if b>=1 and b<=12: + ans+=2 + +print(lab[ans])" +p03262,s015378213,Accepted,"from fractions import gcd + + +def main(): + n, x = map(int, input().split()) + a = list(map(int, input().split())) + for i in range(n): + a[i] =abs(a[i] - x) + + ans = 0 + for aa in a: + ans = gcd(aa, ans) + print(ans) + + +if __name__ == '__main__': + main()" +p02771,s124773881,Accepted,"a, b, c = map(int, input().split("" "")) + +if (((a == b) and (b != c)) or + ((b == c) and (c != a)) or + ((c == a) and (a != b))): + print(""Yes"") +else: + print(""No"")" +p03637,s227399949,Accepted,"N = int(input()) +odd = [] +even = [] +four = [] +for x in map(int,input().split()): + if x % 4 == 0: + four.append(x) + elif x % 2 == 0: + even.append(x) + else: + odd.append(x) +if len(four) >= len(odd): + print(""Yes"") +elif len(four) == len(odd)-1 and len(even) == 0: + print(""Yes"") +else: + print(""No"")" +p02576,s508709812,Accepted,"import sys +input = sys.stdin.readline + +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) + +def main(): + mod=10**9+7 + N,X,T=MI() + + cnt=(N+X-1)//X + ans=cnt*T + print(ans) + +main() +" +p02989,s405812181,Accepted,"n = int(input()) +D = list(map(int, input().split())) +D.sort() + +d1, d2 = D[n // 2 - 1], D[n // 2] +ans = 0 +if d1 != d2: + ans = len(range(d1 + 1, d2 + 1)) + +print(ans)" +p04043,s414526008,Wrong Answer,"from sys import stdin, stdout +from time import perf_counter + +import sys +sys.setrecursionlimit(10**9) +mod = 10**9+7 + + + +n = sorted([int(item) for item in input().split()]) +print(""Yes"" if n[2] == 7 else ""No"")" +p02760,s754466547,Accepted,"a = [list(map(int,input().split())) for _ in range(3)] +n = int(input()) +b = [int(input()) for _ in range(n)] +ati=[[a[0][i],a[1][i],a[2][i]] for i in range(3)] +an1 = [a[0][0],a[1][1],a[2][2]] +an2 = [a[2][0],a[1][1],a[0][2]] +for i in a: + if all(j in b for j in i): + print('Yes') + exit() +for i in ati: + if all(j in b for j in i): + print('Yes') + exit() +for i in [an1,an2]: + if all(j in b for j in i): + print('Yes') + exit() +print('No')" +p02727,s964260452,Wrong Answer,"X,Y,A,B,C=map(int,input().split()) +P=sorted(list(map(int,input().split()))) +Q=sorted(list(map(int,input().split()))) +R=sorted(list(map(int,input().split()))) +S=sorted(P[A-X:]+Q[B-Y:]) +i=0 +while S[i]i or len(S)>i: + break + i+=1 +if i==0: + R=[] +print(sum(S[i:])+sum(R[-i:]))" +p03761,s798231551,Wrong Answer,"import collections as c +n=[c.Counter(input()) for _ in range(int(input()))];r=n[0] +for i in range(1,len(n)): r=r&n[i] +print(*[i*j for i,j in r.items()][::-1],sep='')" +p02547,s714725791,Accepted,"n=int(input()) +xy = [map(int, input().split()) for _ in range(n)] +x, y = [list(i) for i in zip(*xy)] +a=0 +for i in range(n): + if x[i]==y[i]: + a+=1 + if a==3: + break + else: + a=0 + +if a>=3: + print(""Yes"") +else: + print(""No"") +" +p03817,s596063230,Wrong Answer,"x = int(input()) +#6と5を繰り返す +if x%11 < 6: print(x//11*2+1) +else: print(x//11*2+2)" +p03324,s221050018,Wrong Answer,"A = [1, 100, 10000] +d, n = map(int, input().split()) + +print(A[d] * n)" +p02618,s301661566,Accepted,"import math +#import numpy as np +import queue +from collections import deque,defaultdict +import heapq as hpq +from sys import stdin,setrecursionlimit +#from scipy.sparse.csgraph import dijkstra +#from scipy.sparse import csr_matrix +ipt = stdin.readline +setrecursionlimit(10**7) + +def main(): + d = int(ipt()) + c = [int(i) for i in ipt().split()] + s = [[int(i) for i in ipt().split()] for _ in range(d)] + for i in s: + print(i.index(max(i))+1) + + return + +if __name__ == '__main__': + main() +" +p02700,s293901335,Accepted,"T_HP, T_AT, A_HP, A_AT = map(int, input().split()) +while True: + A_HP -= T_AT + if A_HP <= 0: + print(""Yes"") + break + T_HP -= A_AT + if T_HP <= 0: + print(""No"") + break" +p02818,s171857387,Accepted,"a,b,k = map(int,input().split()) +print(max(0,a-k),min(b,max(0,a+b-k)))" +p03351,s464002878,Accepted,"a,b,c,d = map(int, input().split()) +x = abs(a - b) +y = abs(b - c) +z = abs(a - c) +if x <= d and y <= d or z <= d: + print(""Yes"") +else: + print(""No"")" +p02993,s074958009,Wrong Answer,"S = input() + +if (S[0]==S[1]) or (S[2]==S[1]) or (S[2]==S[3]): + print(""Bad"") + exit() + +print(""Yes"") +" +p02924,s835931334,Wrong Answer,"N = int(input()) + + +print(int(N*(N+1)/2-N))" +p03438,s967738242,Accepted,"import sys +n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) + +asum = sum(a) +bsum = sum(b) + +if bsum - asum < 0: + print(""No"") + sys.exit() + +kai = 0 +for i in range(n): + if b[i] > a[i]: + kai += (b[i]-a[i]+1) // 2 + +if kai > bsum - asum: + print(""No"") +else: + print(""Yes"")" +p02963,s024199493,Accepted,"i9 = 10 ** 9 +S = int(input()) +if S == i9 ** 2: + print(i9, 0, 0, i9, 0, 0) +else: + print(i9 - (S % i9), S // i9 + 1, i9, 1, 0, 0) +" +p03721,s353627244,Accepted,"n,k = map(int,input().split()) +num = [0] * 100000 +for i in range(n): + c,d = map(int,input().split()) + num[c-1] += d +sum = 0 +for i in range(100000): + sum += num[i] + if sum >= k: + print(i + 1) + exit()" +p03150,s789997095,Accepted,"S = input() +N = len(S) +for i in range(N): + for j in range(i, N): + if S[:i] + S[j:] == 'keyence': + print('YES') + exit() +print('NO') +" +p03986,s516662964,Wrong Answer," +X = input() +N = len(X) +t = 0 +ans = N +for c in X[::-1]: + if c == 'T': + t += 1 + elif t > 0: + ans -= 2 +print(ans)" +p03785,s923068994,Accepted,"n,c,k = map(int,input().split()) +list = [int(input()) for _ in range(n)] +sorted_list = sorted(list) +bus = 1 +customer = 1 +max_hour = sorted_list[0]+k +for i in sorted_list[1:]: + if i > max_hour or customer >= c: + bus+=1 + customer=1 + max_hour = i+k + else: + customer += 1 +print(bus)" +p03696,s509896752,Accepted,"n = int(input()) +s = input() + +opens = 0 +l = 0 +for i in range(n): + if s[i] == ""("": + opens += 1 + else: + opens -= 1 + + if opens < 0: + l += 1 + opens = 0 + +print(""(""*l + s + "")""*opens)" +p02948,s279028695,Wrong Answer,"# D - Summer Vacation + +# 価値、日数で降順ソートして上から取ってく + +n, m = map(int, input().split()) +w = [] +for _ in range(n): + w.append(list(map(int, input().split()))) + +w = sorted(w, key=lambda x: (x[1], x[0]), reverse=True) + +ans = 0 +for w1 in w: + if m >= w1[0]: + ans += w1[1] + else: + continue + m -= 1 + +print(ans)" +p03109,s621664541,Accepted,"s = input() +if int(s[5 : 7]) <= 4: + print(""Heisei"") +else: + print(""TBD"")" +p03639,s632462638,Wrong Answer,"import sys + +n = int(input()) +s = [int(i)%4 for i in sys.stdin.read().split()] +s0 = s.count(0) +s2 = s.count(2) +if s0 >= n//2 or (s2 >= (n-s0+1)//2): + print(""Yes"") +else: + print(""No"") +" +p03681,s027657783,Wrong Answer,"mod = 10**9+7 + +def mod_factorial(n): + ret = 1 + for i in range(1, n+1): + ret = ret * i % mod + return ret + +def main(): + n, m = map(int, input().split()) + if abs(n-m) > 1: + return 0 + + l = max(n, m) + f = mod_factorial(l-1) + + if n == m: + return(2*f*f%mod) + else: + return(f*f*l%mod) + +print(main())" +p02613,s216997945,Accepted,"N=int(input()) + +list=[] +ac=0 +wa=0 +re=0 +tlc=0 + +for i in range(N): + list.append(input()) + +for i in range(N): + if list[i]==""AC"": + ac+=1 + elif list[i]==""WA"": + wa+=1 + elif list[i]==""RE"": + re+=1 + else: + tlc+=1 + +print(""AC x ""+str(ac)) +print(""WA x ""+str(wa)) +print(""TLE x ""+str(tlc)) +print(""RE x ""+str(re))" +p02958,s429133861,Accepted,"input() +*p,=map(int,input().split()) +print('NO' if 2=abs(S-SS-2*a[i]): + S=S-a[i] + SS=SS+a[i] + mi=abs(S-SS) +print(mi) +" +p02678,s493312982,Accepted,"f=lambda:map(int,input().split());n,m=f();g=[[] for _ in range(n)] +for _ in [0]*m:a,b=f();g[a-1]+=[b-1];g[b-1]+=[a-1] +p=[0]*n;from queue import*;q=Queue();q.put(0) +while not q.empty(): + v=q.get() + for c in g[v]: + if p[c]<1:p[c]=v+1;q.put(c) +print('Yes',*p[1:],sep='\n')" +p02873,s500098308,Accepted,"S = list(input().replace(""><"", "">,<"").split("","")) +ans = 0 +for s in S: + n = s.count(""<"") + m = s.count("">"") + ans += (n * (n - 1)) // 2 + (m * (m - 1)) // 2 + max(n, m) +print(ans) +" +p02786,s218018150,Accepted,"h=int(input()) +for i in range(200): + if h==1: + print((2**(i+1))-1) + exit() + h=h//2" +p03161,s858263906,Accepted,"[N,K] = list(map(int,input().split())) +h = list(map(int,input().split())) + + +#配るdp +inf = float('inf') +dp = [inf]*N + +dp[0] = 0 +for i in range(0,N-1): + for j in range(i+1, min(i+K+1,N)): + dp[j] = min(dp[i]+abs(h[i]-h[j]), dp[j]) + +print(dp[N-1]) +" +p03319,s262541969,Accepted,"from math import ceil +n,k=map(int,input().split()) +a=list(map(int,input().split())) +print(ceil((n-1)/(k-1)))" +p03861,s530580154,Accepted,"def f(n): + if x == -1: + return 0 + else: + return n//x+1 + +a,b,x = map(int,input().split()) +print(f(b)-f(a-1))" +p02792,s384504605,Accepted,"import sys +def input(): return sys.stdin.readline().rstrip() +def main(): + n=int(input()) + lis=[[0]*9 for _ in range(9)] + for i in range(1,n+1): + si=str(i) + if int(si[-1])>0: + lis[int(si[0])-1][int(si[-1])-1]+=1 + cunt=0 + for i in range(9): + for j in range(9): + cunt+=lis[i][j]*lis[j][i] + print(cunt) + + + +if __name__=='__main__': + main()" +p03289,s341632525,Wrong Answer,"s = input() +if s[0] == 'A' and s[2:-1].count('C') == 1 and s.count('C') == 1: + list(s).remove(""A"") + list(s).remove(""C"") + if s.islower() == 0: + print('AC') + exit() + else: + print('WA') +else: + print('WA')" +p03434,s528340003,Accepted,"n = int(input()) +if n ==1: + print(input()) +else: + a = list(map(int, input().split())) + a.sort(reverse=True) + print(sum(a[0::2])-sum(a[1::2]))" +p02606,s813675886,Accepted,"l, r, d = map(int, input().split()) + +cnt = 0 +tmp = d +while tmp <= r: + if tmp <= r and tmp >= l: + cnt += 1 + tmp += d +print(cnt)" +p02596,s453478035,Accepted,"def main(k): + size, res = 1, 7 % k + while res and size <= k: + res = (res * 10 + 7) % k + size += 1 + return -1 if size > k else size + + +if __name__ == '__main__': + k = int(input()) + print(main(k)) +" +p02628,s995970929,Accepted,"n,k = map(int,input().split()) +p = list(map(int,input().split())) +ans = 0 +p.sort() +for i in range(k): + ans += p[i] +print(ans)" +p02658,s902645961,Accepted,"n = int(input()) + +a = [*map(int, input().split())] +for e in a: + if e == 0: + print(0) + exit(0) + +ans = 1 +for e in a: + ans *= e + if ans > 10**18: + print(-1) + exit(0) + +print(ans) +" +p03208,s972100911,Accepted,"n,k = map(int,input().split()) +h = [int(input()) for i in range(n)] +h.sort() +l = [h[i+k-1]-h[i] for i in range(n-k+1)] +print(min(l))" +p04012,s096212778,Accepted,"w = input() +D = {} + +for i in range(len(w)): + if w[i] in D: + D[w[i]] += 1 + else: + D[w[i]] = 1 +for x in D.values(): + if x % 2 == 1: + print(""No"") + break +else: + print(""Yes"")" +p03037,s929091710,Wrong Answer,"n, m = list(map(int, input().split())) +#b = list(map(int, input().split())) +l = [] +r = [] +for i in range(m): + x, y = list(map(int, input().split())) + l.append(x) + r.append(y) +L = l[0] +R = r[0] +for i in range(1, m): + if not((R < l[i] and R < r[i]) or (r[i] < L and l[i] < L)): + L = max(L, l[i]) + R = min(R, r[i]) + +print(R-L+1) +" +p03289,s159592725,Wrong Answer,"#!/usr/bin/env python3 + +s = str(input()) + +flag = 1 +if s[0] != ""A"": + flag = 0 +if s[2] != ""C"": + flag = 0 + + +num_C = 0 +for i in s[1:-1]: + if i == ""C"": + num_C += 1 +if num_C >= 2 or num_C == 0: + flag = 0 + +if flag == 0: + print(""WA"") +else: + print(""AC"") +" +p03127,s054737754,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +while (len(a) > 1): + a.sort() + a = [a[i] if i==0 else a[i]%a[0] for i in range(len(a))] + a = [x for x in a if x != 0] + +print(a[0]) +" +p03317,s803566334,Wrong Answer,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +if N == K: + y = 0 +else: + minA = min(A) + count_minA = sum([x == minA for x in A]) + + n_target = N - count_minA + n_1 = n_target // (K - 1) + n_2 = n_target % (K - 1) + y = n_1 + n_2 +print(y)" +p02705,s540457279,Wrong Answer,"import math +n = int(input()) +print(math.pi*n)" +p03309,s862555644,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) + +b = 0 +if N%2 == 0: + b = int((A[N//2]+A[N//2+1])/2 - (N//2 - 0.5)) +else: + b = A[N//2] - N//2 - 1 +ans = 0 +for i in range(N): + ans += abs(A[i]-(b+i+1)) + +print(int(ans))" +p02777,s282906419,Wrong Answer,"S, T = input().split() +A, B = map(int, input().split()) +U = input() + +print(A-1, B if S==U else A, B-1) +" +p02820,s592826039,Wrong Answer,"# -*- coding: utf-8 -*- + +n, k = map(int, input().split()) +r, s, p = map(int, input().split()) +t = input() + +num = [] +for i in range(len(t)): + char = t[i] + if char == ""r"": + point = p + elif char ==""s"": + point = r + else: + point = s + + if i > (k-1): + if point == num[i -k]: + point = 0 + num.append(point) + +print(sum(num))" +p03289,s540282417,Wrong Answer,"import re + +S = input() +if('A' in S[0]): + if('C' in S[2:-2]): + if(len(re.findall('[A-Z]',S)) == 2): + print('AC') + else: + print('WA') + else: + print('WA') +else: + print('WA') +" +p02693,s231005403,Wrong Answer,"a = int(input()) +b, c = map(int, input().split()) + +if (c-b)/a>=1: + print(""OK"") +elif c-b==0 and c%a==0: + print(""OK"") +else: + print(""NG"")" +p03059,s128744201,Accepted,"a,b,t = map(int,input().split()) +print(int(((t+0.5)//a)*b))" +p02793,s174039094,Wrong Answer,"def gcd(a,b): + while b!=0: + a,b=b,a%b + return a + +def lcm(a,b): + return a*b//gcd(a,b) + +N = int(input()) +A = list(map(int, input().split())) + +lcm_A = 1 +for i in range(N): + lcm_A = lcm(lcm_A, A[i]) + +ans = 0 +for i in range(N): + ans += lcm_A // A[i] + +mod = 10**9+7 +print(ans & mod)" +p04045,s754278845,Accepted,"n, k = map(int,input().split()) +a = input().split() +while True: + if all(c not in str(n) for c in a): + print(n) + break + else: + n += 1" +p03592,s680959784,Wrong Answer,"N, M, K = map(int, input().split()) + +for n in range(N + 1): + for m in range(M + 1): + if n * N + m * M - max(n, m) * 2 == K: + print('Yes') + exit() + +print('No')" +p03814,s290094640,Wrong Answer,"s = input() +a_index = 0 +z_index = 0 + +for i in range(0, len(s)): + if s[i] == ""A"": + a_index = i + break + +for i in range(0, len(s)): + if s[len(s)-i-1] == ""Z"": + z_index = len(s)-i + break +print(s[a_index:z_index])" +p02730,s349564487,Wrong Answer,"S = list(input()) +N = len(S) +flag = True +for i in range((N+1)//2-1): + if S[i] != S[-1-i]: + flag = False + break + +for i in range((N+1)//4-1): + if S[i] != S[(N+1)//2-2-i]: + flag = False + break + +for i in range((N+3)//2, (N+5)//4-1): + if S[i] != S[-2-i]: + flag = False + break + +if flag == True: + print('Yes') +elif flag == False: + print('No')" +p03282,s521194188,Accepted,"s = str(input()) +k = int(input()) +if k <= len(s) and s[:k] == '1' * k: + ans = 1 +else: + ans = s.replace('1', '')[0] +print(ans)" +p03289,s798825238,Accepted,"s=input() + +if s[0]==""A"": + pass +else: + print(""WA"") + exit() + +k=s[2: -1] +if k.count(""C"")==1: + pass +else: + print(""WA"") + exit() + +new_string=s.replace(""A"", """") +new_string=new_string.replace(""C"", """") + +if new_string.islower(): + print(""AC"") +else: + print(""WA"")" +p03455,s041359914,Accepted,"a, b = map(int, input().split()) +if (a * b)%2 == 0: + print(""Even"") +else: + print(""Odd"") +" +p02724,s566954067,Wrong Answer,"price = int(input()) +num500 = int(price / 500) +price = price - (num500 * 500) +num5 = int(price % 5) +print(num500 * 1000 + num5 * 5)" +p02838,s746995152,Accepted,"N = int(input()) +A = list(map(int,input().split())) +mod = 10 ** 9 + 7 +cnt = [0 for _ in range(60)] +for a in A: + for i in range(60): + cnt[i] += a & 1 + a >>= 1 +cnt = [x * (N - x) % mod for x in cnt] +power = 1 +ans = 0 +for i in range(60): + ans += power * cnt[i] + power *= 2 + power %= mod +ans %= mod +print(ans)" +p04012,s902178421,Wrong Answer,"w=input() +flag=True +for i in str(w): + if str(w).count(i)==2: + continue + else: + flag=False +print(""Yes"" if flag==True else ""No"") +" +p02784,s065569665,Accepted,"H, N = map(int, input().split()) +A = list(map(int,input().split())) + +if sum(A) >= H: + print(""Yes"") +else: + print(""No"") +" +p02917,s404938403,Accepted,"n = int(input()) +B = list(map(int, input().split())) + +a = [-1] * n + +for i, b in enumerate(B): + if a[i] > B[i]: + a[i] = b + a[i+1] = b + elif a[i] != -1: + a[i+1] = b + elif a[i] == -1: + a[i] = b + a[i+1] = b + +print(sum(a))" +p03639,s962850430,Wrong Answer,"print(""Yes"")" +p02793,s889435768,Accepted,"import fractions + +N = int(input()) +nums = list(map(int, input().split())) + +def lcm(x, y): + return (x * y) // fractions.gcd(x, y) + +num = nums[0] +for i in range(N - 1): + num = lcm(num, nums[i + 1]) +print(sum([num // i for i in nums]) % (10 ** 9 + 7))" +p02779,s761056644,Accepted,"from collections import Counter + +N = input() +A = map(int, input().split()) + +ans = Counter(A) +max_value = max(ans.values()) + +if max_value == 1: + print('YES') +else: + print('NO') +" +p03254,s483350380,Accepted,"if __name__ == ""__main__"": + n, x = map(int, input().split()) + a = list(map(int, input().split())) + + if sum(a) == x: + print(n) + exit() + + a.sort() + + ans = 0 + for i in range(n): + if sum(a[:i+1]) <= x: + ans = i+1 + else: + print(i) + exit() + + if sum(a[:ans]) == x: + print(ans) + else: + print(ans-1) +" +p02983,s618273204,Accepted,"L,R = map(int,input().split()) + +ans = 2019 +for i in range(L,min(L+2019,R)): + for j in range(i+1,min(L+2019,R+1)): + ans = min(ans,(i*j)%2019) + +print(ans)" +p03317,s293630163,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +import math +ans = math.ceil((n - 1) / (k - 1)) +print(ans) +" +p03457,s265492592,Wrong Answer,"n = int(input()) + +flag = 0 +t = [0] * n +x = [0] * n +y = [0] * n + +for i in range(n): + t[i], x[i], y[i] = map(int, input().split()) + + if t[i] > x[i]+y[i]: + flag += 1 + if t[i]%2 != (x[i]+y[i])%2: + flag +=1 + if i > 1: + if abs(t[i-1]-t[i]) > abs(x[i-1]+y[i-1])-abs(x[i]+y[i]): + flag +=1 + +if flag > 0: + print(""No"") +else: + print(""Yes"")" +p02959,s926984135,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +b = [int(i) for i in input().split()] + +ans = 0 +for i in range(n): + if a[i] <= b[i]: + all_enemy = a[i] + a[i + 1] + if all_enemy > b[i]: + ans += b[i] + a[i+1] = all_enemy - b[i] + else: + ans += all_enemy + a[i+1] = 0 + else: + ans += b[i] + +print(ans)" +p02732,s110899192,Accepted,"import sys +from bisect import * +from heapq import * +from collections import * +from itertools import * +from functools import * +from math import * + +sys.setrecursionlimit(100000000) +input = lambda: sys.stdin.readline().rstrip() + +N = int(input()) +A = list(map(int, input().split())) + +counter = Counter(A) +ans = sum(i * (i - 1) // 2 for i in counter.values()) + +for a in A: + c = counter[a] + print(ans - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2) + + +" +p02836,s519063490,Accepted,"s=input() +ans=0 +for i in range(len(s)//2): + if s[i]!=s[-i-1]: + ans+=1 +print(ans)" +p02756,s365249376,Accepted,"S = input() +Q = int(input()) + +jun = True +head = """" + +for _ in range(Q): + T = input().split() + if T[0] == ""1"": + jun = not jun + + else: + + if (T[1] == ""1"" and jun) or (T[1] == ""2"" and not jun): + head += T[2] + continue + + else: + S += T[2] + +if jun: + print(head[::-1] + S) +else: + print(S[::-1] + head)" +p03160,s065640980,Accepted,"n = int(input()) +a = list(map(int, input().split())) +dp = [0]*n +for i in range(n): + if i == 0: + pass + elif i == 1: + dp[i] = abs(a[i]-a[i-1]) + dp[i-1] + else: + dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]) +print(dp[-1])" +p02665,s316455608,Accepted,"import math +import sys +a=int(input()) +List=list(map(int,input().split())) +s=sum(List) +r=1 +count=0 +for i in range(a+1): + count+=r + r-=List[i] + s-=List[i] + if r<0: + print(-1) + sys.exit() + r=min(s,2*r) +print(count) + +" +p03543,s735880162,Accepted,"str = input().split() +n = str[0] +if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]: print(""Yes"") +else: print(""No"")" +p03944,s710859616,Accepted,"w,h,n=map(int, input().split()) +sx=sy=0 +for i in range(n): + x,y,a=map(int,input().split()) + if a==1: sx=max(sx,x) + elif a==2: w=min(w,x) + elif a==3: sy=max(sy,y) + elif a==4: h=min(h,y) +print(max(0,w-sx)*max(0,h-sy))" +p03069,s106330197,Accepted,"n = int(input()) +s = list(input()) + +l = [[0, 0] for i in range(n + 1)] +for i in range(n): + preB, preW = l[i] + if s[i] == '#': + l[i + 1] = [preB + 1, preW] + else: + l[i + 1] = [preB, preW + 1] + +SUM_W = l[-1][1] +ans = 10 ** 10 +for i, j in l: + temp = i + SUM_W - j + if temp < ans:ans = temp +print(ans)" +p03210,s237028296,Accepted,"x = int(input()) +if x == 7 or x == 5 or x == 3: + print('YES') +else: + print('NO')" +p02681,s408405665,Accepted,"s = input() +t = input() + +al = ""abcdefghijklmnopqrstuvwxyz"" + +for x in al: + if s + x == t: + print('Yes') + break + +else: + print('No')" +p02724,s851352582,Accepted,"X = int(input()) +print(1000 * (X // 500) + 5 * ((X % 500) // 5) )" +p03338,s327616765,Accepted,"n=int(input()) +s=input() +count = 0 +for i in range(n-1): + a=s[:i + 1] + b=s[i+1:] + temp = 0 + for j in range(27): + if chr(96+j) in a and chr(96+j) in b: + temp += 1 + count = max(temp, count) +print(count)" +p02695,s927553425,Accepted,"n,m,q = list(map(int,input().split())) +query = [list(map(int,input().split())) for _ in range(q)] +ans = 0 + +import itertools +for con in itertools.combinations_with_replacement(list(range(m)),n): + tmp = 0 + for i in query: + a,b,c,d = i + if con[b-1] - con[a-1] == c: + tmp += d + ans = max(ans, tmp) + +print(ans)" +p03721,s931593706,Accepted,"N, K = map(int, input().split()) +AB = [list(map(int, input().split())) for _ in range(N)] + +count = 0 +for a, b in sorted(AB): + count += b + if count >= K: + print(a) + break +" +p02983,s219497925,Accepted,"import itertools +l,r = map(int,input().split()) +if r-l >= 2019: + print(0) + exit() +w = [] +q = list(itertools.combinations(range(l,r+1),2)) +for i in range(len(q)): + w.append((q[i][0]*q[i][1])%2019) + +print(min(w))" +p03455,s840725221,Accepted,"a, b = map(int, input().split()) +print(""Even"" if a * b % 2 == 0 else ""Odd"")" +p02747,s694419620,Accepted,"def resolve(): + S = input() + + S_list = list(S) + + if len(S_list) % 2 == 0: + s_len = int(len(S_list) / 2) + if S == s_len * 'hi': + print('Yes') + return + + print('No') + return + +if __name__ == ""__main__"": + resolve()" +p02554,s706573202,Wrong Answer,"n = int(input()) +ans = 0 +ans += 8**(n-2) % (10**9 + 7) +print(ans)" +p03408,s981931533,Accepted,"from collections import Counter +n = int(input()) +s = Counter([input() for _ in range(n)]) + +m = int(input()) +t = Counter([input() for _ in range(m)]) + +keys = s.keys() & t.keys() +for key in keys: + s[key] -= t[key] + +print(max(max(s.values()), 0)) +" +p03262,s082309757,Accepted," +n, x= map(int, raw_input().split(' ')) +def gcd(a,b): return a if b == 0 else gcd(b, a % b) +print reduce(gcd,map(lambda c: abs(c - x), map(int, raw_input().split(' '))))" +p03286,s083527927,Wrong Answer,"import math, sys +from bisect import bisect_left, bisect_right +from collections import Counter, defaultdict, deque +from copy import deepcopy +from functools import lru_cache +from heapq import heapify, heappop, heappush +from itertools import accumulate, combinations, permutations +input = sys.stdin.readline +mod = 10**9 + 7 +ns = lambda: input().strip() +ni = lambda: int(input().strip()) +nm = lambda: map(int, input().split()) +nl = lambda: list(map(int, input().split())) + +n = ni() +ans = '' +while n != 0: + r = n % 2 + if r < 0: + r += 2 + n = (n - r) // (-2) + ans += str(r) +print(ans[::-1])" +p02796,s521613134,Accepted,"n=int(input()) +a=[list(map(int,input().split())) for _ in range(n)] +b=[[a[i][0]+a[i][1],a[i][0]-a[i][1]] for i in range(n)] +b.sort() +ans=1 +tmp=b[0][0] +for i in range(n): + if tmp<=b[i][1]: + ans+=1 + tmp=b[i][0] +print(ans)" +p03475,s146233773,Wrong Answer,"N = int(input()) +C, S, F = [], [], [] + +for _ in range(N-1): + c, s, f = map(int, input().split()) + C.append(c) + S.append(s) + F.append(f) + +for station in range(N): + now = station + time = 0 + + while now < N-1: + if time < S[now]: + time = S[now] + C[now] + else: + tmp = time - S[now] + wait_time = tmp % F[now] + time += wait_time + C[now] + + now += 1 + + print(time) +" +p02817,s503543679,Accepted,"S, T = input().split() + +print(T+S)" +p03679,s318793601,Wrong Answer,"x, a, b = map(int,input().split()) + +if a > b: + print('delicious') +elif b - a < x+1: + print('safe') +else: + print('dangerous')" +p03962,s894772947,Accepted,"a=input().split() + +print(len(set(a)))" +p02691,s220394622,Wrong Answer,"N = int(input()) + +height = input() +height = height.split() +height = [int(s) for s in height] + +count = 0 + +iAi = [0] * N +jAj = [0] * N + +for i in range(N): + iAi[i] = i+1 + height[i] + jAj[i] = i+1 -height[i] + +for i in range(N): + if jAj.count(iAi[i]) >= 1: + count +=1 + + +print(count)" +p04033,s155715067,Accepted,"import sys +a,b = map(int,input().split()) +c = 0 +if (a+b) == 0: + print(""Zero"") + sys.exit() +elif a < 0 and b < 0: + if (a-b) % 2 == 1: + print(""Positive"") + sys.exit() +elif a < 0 and b >= 0: + if a%2 == 0: + print(""Positive"") + sys.exit() +elif b < 0 and a >= 0: + if b % 2 == 0: + print(""Positive"") + sys.exit() +if (a+b) > 0: + print(""Positive"") +else: + print(""Negative"")" +p03243,s785861703,Wrong Answer,"N = input() +if len(set(list(N))) == 1: + print(N) +else: + print(str(int(N[0])+1)*3)" +p03481,s301290500,Accepted,"X,Y=map(int, input().split()) +print((Y//X).bit_length())" +p02742,s837962971,Wrong Answer,"h,w=map(int,input().split()) +#b=[[0]*h for i in range(w)] +#print(b)->b[width][height] +print((h*w+1)//2)" +p03137,s473227540,Accepted,"def main(): + N,M = map(int,input().split()) + X = list(map(int,input().split())) + X.sort() + if N >= M: + print(0) + exit() + L = X[-1]-X[0] + Y = [X[i+1]-X[i] for i in range(M-1)] + Y.sort() + Y.reverse() + Z = Y[:N-1] + ans = X[-1]-X[0] + for z in Z: + ans -= z + print(ans) + + +if __name__ == ""__main__"": + main()" +p02951,s578097886,Accepted,"a,b,c=map(int,input().split()) +print(c-min(a-b,c)) +" +p03475,s729623172,Wrong Answer,"n = int(input()) + +C, S, F = [0] * n, [0] * n, [0] * n + +for i in range(n - 1): + C[i], S[i], F[i] = map(int, input().split()) + +for i in range(n): + time = 0 + for j in range(i, n - 1): + if time < S[j]: + time = S[j] + C[j] + elif time % F[j] == 0: + time += C[j] + else: + time = time + F[j] - (time % F[j]) + C[i] + print(time) + +" +p02595,s561078418,Accepted,"def main(): + n, d = map(int, input().split()) + ans = 0 + for _ in range(n): + x, y = map(int, input().split()) + if x ** 2 + y ** 2 <= d ** 2: + ans += 1 + print(ans) + + +if __name__ == '__main__': + main() +" +p04005,s623557959,Accepted,"import sys +input = sys.stdin.readline + +A,B,C=map(int,input().split()) + +if A % 2 == 0 or B%2 == 0 or C%2==0: + print(0) +else: + AB=A*B + BC=B*C + CA=C*A + print(min(AB,BC,CA)) + + +" +p02756,s584442380,Accepted,"import sys +S = input() +Q = int(input()) +pin = 0 +left = '' +right = '' +for i in range(Q): + t = list(sys.stdin.readline().split()) + if int(t[0]) == 1: + pin += 1 + else: + if int(t[1]) % 2 == pin % 2 : + right = right + t[2] + else: + left = t[2] + left +S = left + S + right +if pin % 2 == 1: + S = S[::-1] +print(S) +" +p02983,s745258690,Accepted,"L, R = map(int,input().split()) + +x = [] +for i in range(L,R+1): + if i % 2019 in x: + break + + x.append(i % 2019) + +ans = 9999 +for i in range(len(x)): + for j in range(i+1,len(x)): + ans = min(ans, x[i] * x[j] %2019) + +print(ans)" +p02701,s511526587,Accepted,"inputLine=input() +N=int(inputLine) + +S = [] + +for i in range(N): + inputLine=input() + S.append(inputLine) + +S.sort() + +result=1 + +for i in range(1, len(S)): + if S[i-1] != S[i]: + result += 1 + +print(result)" +p03161,s568185020,Wrong Answer,"N, K= map(int, input().split()) +h = list(map(int, input().split())) + +for i in range(K): + h.append(float('inf')) + +dp = [0] +for i in range(N+K): + dp.append(float('inf')) + +for i in range(N): + for j in range(1,K+1): + + dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j])) + print(dp) + +print(dp[N-1])" +p03494,s023179591,Accepted,"def function(N): + cnt=0 + while N%2==0: + N/=2 + cnt+=1 + return cnt + +N=int(input()) +a=map(int, input().split()) +cnt=min(map(function, a)) +print(cnt)" +p03719,s139774397,Accepted,"a, b, c = map(int, input().split()) +if a <= c <= b: + print(""Yes"") +else: + print(""No"") +" +p03760,s269252123,Accepted,"O = list(input()) +E = list(input())+[""""] +for x, y in zip(O, E): + print(x+y,end="""")" +p02582,s148964827,Accepted,"S=input() +if S== 'RRR': + print(3) +elif S=='RRS' or S=='SRR': + print(2) +elif S=='SSS': + print(0) +else: + print(1) +" +p02688,s168830860,Wrong Answer,"n, k = map(int, input().split()) +snk = [-1] * (n + 1) +ans = -1 +for j in range(k): + d = int(input()) + lis = list(input().split()) + for i in range(d): + y = int(lis[i]) + snk[y] = 0 +for j in range(n): + if snk[j] == -1: + ans += 1 +print(ans)" +p03679,s944844002,Accepted,"X, A, B = map(int, input().split()) + +if A >= B: + print(""delicious"") +elif X + 1 <= B - A: + print(""dangerous"") +else: + print(""safe"") +" +p03407,s161521956,Wrong Answer,"a,b,c = map(int,input().split()) +if c == a or c == b or c == a+b: + print('Yes') +else: print('No')" +p02916,s342084443,Accepted,"n = int(input()) +ans = 0 +p = -999 +a = [i - 1 for i in map(int, input().split())] +b = list(map(int, input().split())) +c = list(map(int, input().split())) +for i in a: + ans += b[i] + if i == p + 1: + ans += c[p] + p = i +print(ans)" +p03323,s550795192,Accepted,"a,b = map(int,input().split()) +if a <= 8 and b <= 8: + print(""Yay!"") +else: + print("":("")" +p03797,s417772008,Accepted,"def cin(): + in_ = list(map(int,input().split())) + if len(in_) == 1: return in_[0] + else: return in_ + +N, M = cin() +if M // 2 >= N: + ans = N + M -= 2 * N +else: + ans = M // 2 + M = 0 +ans += M // 4 +print(ans)" +p03779,s149422373,Wrong Answer,"x = int(input()) +i = 1 +dist = 0 +while dist+2*i+1 <= x: + dist += i + i += 1 +else: + ans = x-dist +print(ans)" +p02873,s386574189,Accepted,"s = input() +n = len(s) +t = [0]*(n+1) +tmp=0 +for i in range(n): + tmp+=1 + if s[i]==""<"": + t[i]=tmp-1 + t[i+1]=tmp + else: + tmp=0 + +tmp=0 +for j in range(n)[::-1]: + tmp+=1 + if s[j]=="">"": + t[j+1]=max(tmp-1,t[j+1]) + t[j]=max(tmp,t[j]) + else: + tmp=0 +#print(t) +print(sum(t)) +" +p03721,s325748472,Wrong Answer,"n,k = map(int, input().split()) +num = 0 +ab = [] +x = 'Y' +for i in range(n): + a,b = map(int, input().split()) + num += b + if k <= num and x == 'Y': + y = a + x = 'N' + else: + ab.append((a,b)) +print(y)" +p03472,s652959745,Wrong Answer,"from heapq import heappop, heappush + +N, H = map(int, input().split()) +a = [None] * N +b = [None] * N +for i in range(N): + a[i], b[i] = map(int, input().split()) + +a.sort() +b.sort() +q = [] +for i in range(N): + if b[i] > a[-1]: + heappush(q, -b[i]) + +ans = 0 +while q: + H += heappop(q) + ans += 1 + if H < 0: + print(ans) + exit() + +print(ans + (H+a[-1]-1)//a[-1])" +p03767,s117790177,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +a.sort() +point_sum = 0 + + +for i in range(n): + point_sum += a[n + i] + +print(point_sum)" +p02630,s019790270,Accepted,"n = int(input()) +lis = list(map(int,input().split())) +q = int(input()) +now = [0 for i in range(10 ** 5)] +for num in lis: + now[num-1] += 1 +ans = 0 +for i in range(10 ** 5): + ans += now[i] * (i+1) + # print(ans) +for turn in range(q): + b,c = map(int,input().split()) + num = now[b-1] + now[b-1] = 0 + now[c-1] += num + print(ans-b*num+c*num) + ans -= b*num + ans += c*num + # print(now)" +p03030,s567948046,Accepted," +N = int(input()) +SP = [] +for i in range(N): + s, n = input().split() + n = int(n) + SP.append((s, -n, i)) +SP.sort() + +for s, n, i in SP: + print(i+1) +" +p02713,s535906289,Accepted,"from math import gcd + +K = int(input()); +sum = 0; + +for a in range(1,K+1): + for b in range(1,K+1): + for c in range(1,K+1): + sum += gcd(gcd(a,b),c); + +print(sum) +" +p02755,s324741986,Wrong Answer,"# coding: utf-8 + +a, b = map(int, input().split()) + +a_target1 = a / 0.08 +a_target2 = (a + 1) / 0.08 + +b_target1 = b / 0.1 +b_target2 = (b + 1) / 0.1 + + +result_list = [] + +for i in range(int(a_target1), int(a_target2)): + if i >= b_target1 and i < b_target2: + result_list.append(i) + +if result_list == []: + print(-1) +else: + result = min(result_list) + print(result) +" +p02720,s779772837,Accepted,"k = int(input()) + +a = [list(range(1, 10))] +while True: + new = [] + for aa in a[-1]: + mod = aa % 10 + if mod != 0: + new.append(aa * 10 + mod - 1) + new.append(aa * 10 + mod) + if mod != 9: + new.append(aa * 10 + mod + 1) + a.append(new) + + if sum([len(aa) for aa in a]) > k: + break +flat = sorted(sum(a, [])) + +print(flat[k - 1]) +" +p03719,s735728748,Wrong Answer,"a, b, c = map(int, input().split()) + +if a <= c and c <= b: + ans = 'YES' +else: + ans = 'NO' + +print(ans)" +p02916,s011798931,Wrong Answer,"n = int(input()) +a = [int(i)-1 for i in input().split()] +b = [int(i) for i in input().split()] +c = [int(i) for i in input().split()] +#ここまで入力 +manzoku = 0 +for i in range(n): + if a[i] ==n-1 or i == n-1: + manzoku += b[a[i]] + else: + manzoku += (b[a[i]]+c[a[i]]) +print(manzoku)" +p03281,s369628132,Accepted,"def div(N): + div = set() + for i in range(1, int(N ** 0.5 + 0.5) + 1): + if N % i == 0: + div.add(i) + div.add(N // i) + return len(div) + + +N = int(input()) +ans = 0 +for x in range(1, N + 1, 2): + if div(x) == 8: + ans += 1 +print(ans)" +p02718,s851644509,Accepted," +def main(): + N, M = [int(_) for _ in input().split()] + slist = list(map(int, input().split())) + sort_list = sorted(slist) + thr = sum(sort_list) / (4 * M) + + cnt = 0 + for i in sort_list: + if i >= thr: + cnt += 1 + + if cnt >= M: + print(""Yes"") + else: + print(""No"") + +main()" +p02547,s585253379,Accepted,"n = int(input()) +z = [] +y = 0 +for i in range(n): + line = input().split("" "") + if int(line[0])==int(line[1]): + z.append(i) + +for i in range(len(z)-2): + if z[i]==z[i+1]-1: + if z[i+1]==z[i+2]-1: + y += 1 +if y > 0: + print(""Yes"") +else: + print(""No"")" +p02873,s641562873,Accepted,"s = input() +res = [0] * (len(s)+1) + +for i in range(len(s)): + if s[i] == ""<"": + res[i +1] = res[i] +1 + +for i in range(len(s)-1,-1,-1): + if s[i] == "">"": + res[i] = max(res[i], res[i+1]+1) + +print(sum(res))" +p03545,s926019982,Accepted,"if __name__ == ""__main__"": + s = input() + + op = ['+1', '-1'] + + for i in op: + for j in op: + for k in op: + if int(s[0]) + int(s[1])*int(i) + int(s[2])*int(j) + int(s[3])*int(k) == 7: + print(s[0] + i[0] + s[1] + j[0] + + s[2] + k[0] + s[3] + '=7') + exit() +" +p03264,s112697695,Wrong Answer,"n = int(input()) +print((n/2)*((n+1)/2)) +" +p02696,s934245659,Wrong Answer,"#D +a,b,n = map(int,input().split()) +x = n-1 +ans1 = ((a*x)//b) - (a*(x//b)) +x = n-1 +ans2 = ((a*x)//b) - (a*(x//b)) +x = n-b +ans3 = ((a*x)//b) - (a*(x//b)) +x = n//b +ans4 = ((a*x)//b) - (a*(x//b)) +x = n//2 +ans5 = ((a*x)//b) - (a*(x//b)) +x = 1 +ans6 = ((a*x)//b) - (a*(x//b)) +print(max(ans1,ans2,ans3,ans4,ans5,ans6))" +p03565,s075022517,Accepted,"import sys + +s = input() +t = input() + +tl = len(t) ; sl = len(s) + +c = 1 +for i in range(sl,tl-1,-1) : + st = s[i-tl:i] + c = 0 + for j in range(tl) : + if st[j] == '?' : + continue + elif st[j] != '?' and st[j] == t[j] : + continue + c = 1 + break + if c == 0 : + s = s[:i-tl] + t + s[i:] + break + +if c == 1 : + print('UNRESTORABLE') +else : + print(s.replace('?', 'a'))" +p03061,s725917154,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +def gcd(a,b): + while b: + a,b = b,a%b + return a + +left_gcd = [0]*(n+1) +right_gcd = [0]*(n+1) +left_gcd[1] = a[0] +right_gcd[1] = a[-1] + +for i in range(1,n): + left_gcd[i+1] = gcd(left_gcd[i],a[i]) + right_gcd[i+1] = gcd(right_gcd[i],a[-1-i]) + +ans = right_gcd[n-1] +for i in range(n): + ans = max(ans,gcd(left_gcd[i],right_gcd[n-1-i])) +print(ans) +" +p03109,s010127461,Wrong Answer,"S = input() +print('TBD' if S > '2019/4/30' else 'Heisei') +" +p02783,s477342738,Wrong Answer,"class Main: + s = list(map(int, input().split())) + h = s[0] + a = s[1] + cnt = 1 + if h <= a: + print(cnt) + else: + while h > a: + h -= a + cnt += 1 + print(cnt) +" +p03774,s939304748,Wrong Answer,"N,M = map(int,input().split()) +sts = [list(map(int, input().split())) for i in range(N)] +checkp = [[i+1]+list(map(int, input().split())) for i in range(M)] +rt = [None] * N +distances = [2*(10**8)] * N +for s in range(N): + for c in checkp: + dist = abs(sts[s][0]-c[1]) + abs(sts[s][1]-c[2]) + if rt[s] is None: + rt[s] = c[0] + distances[s] = dist + else: + if distances[s] > dist: + rt[s] = c[0] + distances[s] = dist +print(rt)" +p03206,s721989351,Accepted,"print(""Christmas""+"" Eve""*(25-int(input()))) +" +p03773,s661481648,Accepted,"a,b=map(int,input().split()) + +print((a+b)%24)" +p02910,s284581890,Wrong Answer,"s=list(str(input())) +tmp=0 +for i in range(0,len(s)): + if i%2==0 and s[i]=='L': + tmp+=1 + if i%2!=0 and s[i]=='R': + tmp+=1 +if tmp==1: + print('No') +if tmp==0: + print('Yes') + + + +" +p03785,s038700433,Accepted,"N, C, K = map(int, input().split()) +arr = sorted([int(input()) for _ in range(N)]) +start_t = arr[0] +bus_n = 0 +ans = 1 +for i in range(N): + if arr[i] <= start_t + K and bus_n < C: + bus_n += 1 + else: + bus_n = 1 + start_t = arr[i] + ans += 1 +print(ans) +" +p03324,s921980484,Wrong Answer,"D,N=map(int,input().split()) +print(N*100**D)" +p02765,s782354911,Accepted,"n, r = input().split() +n = int(n) +r = int(r) + +if n > 10: + print(r) + +else: + print((10 - n)* 100 + r) +" +p02811,s593093473,Wrong Answer,"x = [x for x in input().split()] +print('Yes') if x[0]*500>x[1] else print('No')" +p02951,s706085283,Wrong Answer,"a, b, c = map(int, input().split()) + +print(c-a+b) +" +p03319,s427467083,Accepted,"import math +n,k = map(int,input().split()) +print(math.ceil((n-k) / (k-1)) + 1)" +p03069,s572535667,Accepted,"n = int(input()) +s = input() +c = s.count(""."") +ans = c +for i in range(n): + if s[i] ==""#"": + c +=1 + else: + c -=1 + ans = min(ans,c) +print(ans)" +p02641,s183007103,Accepted,"# -*- coding: utf-8 -*- +import sys + +X,N = list(map(int, input().rstrip().split())) +p_list = list(map(int, input().rstrip().split())) +#----- + +p_set = set(p_list) +delta = 0 + +while True: + for d in [-delta, delta]: + n = X + d + + if n in p_set: + continue + else: + print(n) + sys.exit() + + delta += 1 +" +p03386,s362053979,Wrong Answer," +import math +import itertools +import statistics +#import numpy as np +#import collections +a, b, k = list(map(int, input().split())) +l = [] + +if k > b-a: + k = b-a + +for i in range(k): + l.append(a+i) + l.append(b-i) + + +ans = list(set(l)) +ans.sort() +for i in range(len(ans)): + print(ans[i])" +p03360,s175539032,Accepted,"a, b, c = map(int, input().split()) +k = int(input()) +ma = max(a,b,c) + +if ma == a: + print(a*(2**k)+b+c) +elif ma == b: + print(b*(2**k)+a+c) +elif ma == c: + print(c*(2**k)+a+b) +" +p03243,s346259297,Accepted,"N = input() +if (N[0] == N[1]) and (N[1]==N[2]) and (N[2]==N[0]): + print(N) +elif int(N[0]) == int(N[1]) and int(N[1]) > int(N[2]): + print(N[0]*3) +elif int(N[0]) > int(N[1]): + print(N[0]*3) +else: + print(str(int(N[0])+1)*3)" +p02756,s085389365,Accepted,"from collections import deque +D=deque(input().rstrip()) +Q=int(input()) +count=0 +for _ in range(Q): + Y=list(input().split()) + if Y[0]==""1"": + count=(count+1)%2 + else: + if Y[1]==""1"": + if count==0: + D.appendleft(Y[2]) + else: + D.append(Y[2]) + else: + if count==0: + D.append(Y[2]) + else: + D.appendleft(Y[2]) +D=list(D) +if count==0: + print("""".join(D)) +else: + D.reverse() + print("""".join(D))" +p02584,s583705667,Accepted,"a=list(map(int,input().split())) +if a[0]<0: + a[0]=-a[0] +x=a[0]%a[2] +y=a[0]//a[2] +if y>=a[1]: + print(a[0]-a[1]*a[2]) +elif (a[1]-y)%2==1: + print(a[2]-x) +else: + print(x)" +p03327,s237247866,Accepted,"N = int(input()) +if N > 999: + print(""ABD"") +else: + print(""ABC"")" +p03759,s954096756,Accepted,"a,b,c = map(int, input().split()) +print(""YES"" if b-a==c-b else ""NO"")" +p03106,s755070886,Accepted,"def main(): + a, b, k = map(int,input().split()) + cnt = 0 + for i in range(max(a,b), 0, -1): + if a % i == 0 and b % i == 0: + #print(i) + cnt += 1 + if cnt == k: + print(i) + return + +if __name__ == ""__main__"": + main()" +p03339,s866318224,Wrong Answer,"n = int(input()) +s = input() +e_cnt = 0 +for i in range(n): + if s[i] == ""E"": + e_cnt += 1 +ans = e_cnt +w_cnt = 0 +for i in range(n): + ans = min(w_cnt + e_cnt - 1, ans) + if s[i] == ""W"": + w_cnt += 1 + else: + e_cnt -= 1 + +print(ans) + + +" +p02972,s764669551,Accepted,"n=int(input()) + +A=[0]+list(map(int,input().split())) + +for i in reversed(range(1,n+1)): + if sum(A[::i])%2!=A[i]: + A[i]^=1 + +print(sum(A)) +if sum(A)!=0: + for i,a in enumerate(A): + if a==1: + print(i)" +p03352,s739490261,Accepted,"from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby +from math import floor, ceil, sqrt, factorial, log +from bisect import bisect_left, bisect_right +from collections import Counter, defaultdict +from heapq import heappop, heappush, heappushpop +from itertools import product +import sys +stdin = sys.stdin +mod = 10**9 + 7 + + +def ns(): return stdin.readline().rstrip() + + +def ni(): return int(ns()) + + +def na(): return list(map(int, stdin.readline().split())) + + +x = ni() +ans = 1 +for b in range(2, 100): + for p in range(2, 10): + if b**p <= x: + ans = max(ans, b**p) +print(ans) +" +p02699,s743785649,Accepted,"s,w=map(int,input().split()) +if s<=w: + print('unsafe') +else: + print('safe')" +p02598,s458212161,Wrong Answer,"import math +N, K = map(int,input().split()) +A = [int(i) for i in input().split()] + +low = 1 +high = 10 ** 9 +if K == 0: + print(max(A)) +else: + while high - low > 1: + mid = (low + high) / 2 + times = 0 + for a in A: + times += math.ceil(a / mid) - 1 + if K >= times: + high = mid + else: + low = mid + #print(mid) + + print(math.ceil(mid)) +" +p03455,s343823997,Wrong Answer,"s=input() +if (int(s[0])*int(s[-1]))%2 == 1: + print(""Odd"") +else: + print(""Even"")" +p02939,s021453164,Wrong Answer,"S = list(input()) + +cnt = 1 +L = [0]*len(S) +flag = False + +for i in range(len(S)-1): + if flag == True: + L[i] ,L[i+1] = 1, 1 + flag = False + elif S[i] != S[i+1]: + if i+2 == len(S): + L[i+1] = 1 + L[i] = 1 + cnt += 1 + elif S[i] == S[i+1]: + flag = True + + +print(sum(L))" +p03494,s596724077,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +count = 0 +while True: + A, mod = zip(*[divmod(a, 2) for a in A]) + if sum(mod) > 0: + break + count += 1 +print(count)" +p02861,s174063742,Accepted,"import itertools +import math + + +N = int(input()) +ls2 = [] +for i in range(N): + ls1 = list(map(int,input().split())) + ls2.append(ls1) + +lis = [x for x in range(N)] +permutations_lis = itertools.permutations(lis) + +dis = 0 +for one_case in permutations_lis: + for i in range(1,N): + dis += ((ls2[one_case[i]][0]-ls2[one_case[i-1]][0])**2+(ls2[one_case[i]][1]-ls2[one_case[i-1]][1])**2)**(1/2) + +print(dis/(math.factorial(N)))" +p02754,s835216486,Wrong Answer,"n,b,r= map(int,input().split()) +if b==0 and r==0: + print(n) +elif b==0: + print(0) +else: + print(n-r) +" +p02843,s265437301,Accepted,"n = int(input()) + +x = n//100 +m = n%100 + +if 5*x= '3200': + print('s') + +else: + print('red')" +p03338,s453831273,Accepted,"ni = lambda: int(input()) +nm = lambda: map(int, input().split()) +nl = lambda: list(map(int, input().split())) + +n=ni() +s=[_ for _ in input()] + + +mx=0 + +for i in range(n): + sr =s[:i] + sl = s[i:] + r=set(sr) + l=set(sl) + + nn=len(r & l) + mx = max(nn,mx) + +print(mx) + +" +p02554,s854117219,Accepted,"n=int(input()) +print((10**n-2*9**n+8**n)%int(1e9+7))" +p02682,s918759876,Accepted,"A, B, C, K = map(int, input().split()) +num_A = min(A, K) +num_B = min(B, K - num_A) +num_C = K - num_A - num_B +ans = num_A - num_C +print(ans) +" +p02993,s122640852,Accepted,"a,b,c,d = input() +if a==b or b==c or c==d: + print('Bad') +else: + print('Good')" +p03211,s286493635,Accepted,"S=input() +ans=1000 +for i in range(len(S)-2): + s=int(S[i:i+3]) + ans=min(ans,abs(753-s)) +print(ans)" +p03438,s640618182,Wrong Answer,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +n = int(readline()) +a = list(map(int, readline().split())) +b = list(map(int, readline().split())) +cnt = 0 +for i in range(n): + if a[i] > b[i]: + cnt += a[i] - b[i] + else: + cnt += (b[i] - a[i]) // 2 +if sum(b) - sum(a) >= cnt: + print('Yes') +else: + print('No') +" +p03435,s858186425,Accepted,"C = [list(map(int, input().split())) for _ in range(3)] +x = C[1][0]-C[0][0] == C[1][1]-C[0][1] == C[1][2]-C[0][2] +y = C[2][0]-C[0][0] == C[2][1]-C[0][1] == C[2][2]-C[0][2] +if x and y: + print('Yes') +else: + print('No')" +p03721,s961232452,Accepted,"#!/usr/bin/env python3 + +def main(): + n, k = map(int, input().split()) + arr = sorted([list(map(int, input().split())) for i in range(n)]) + for ab in arr: + k -= ab[1] + if k <= 0: + ans = ab[0] + break + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03059,s772498103,Wrong Answer,"a,b,t=map(int,input().split()) +print((t+0.5)//a*b)" +p02935,s544487960,Wrong Answer,"N = int(input()) +v = [int(i) for i in input().split()] +ans=v[0] +for i in range(1,N): + ans = (ans+v[i])/2 +print(ans) +" +p03338,s328317909,Wrong Answer,"n = int(input()) +s = input() +ans = 0 +for i in range(1,len(s)-1): + ans = max(ans, len(set(s[:i]) & set(s[i+1:]))) +print(ans)" +p02606,s056330482,Accepted,"L, R, d = map(int, input().split()) + +count = 0 +for i in range(L, R + 1): + if i % d == 0: + count += 1 + + +print(count)" +p03607,s621968808,Accepted,"n=int(input()) +s=set() +for i in range(n): + x=input() + if x in s: + s.discard(x) + else: + s.add(x) +print(len(s))" +p02767,s254880440,Accepted,"import sys + +stdin = sys.stdin + +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(stdin.readline().rstrip()) +nm = lambda: map(int, stdin.readline().split()) +nl = lambda: list(map(int, stdin.readline().split())) + +n = ni() +l = nl() +print(min(sum((x-y)**2 for x in l) for y in range(101))) +" +p02693,s719019946,Wrong Answer,"K = int(input()) +A, B = list(map(int, input().split())) + +# A =< K =< Bの場合 +if K >= A and K <= B: + print('OK') +elif K < (B - A): + print('OK') +elif (K * 2) >= A and (K * 2) <= B: + print('OK') +elif K == 1: + print('OK') +else: + print('NG')" +p03433,s328268044,Accepted,"N = int(input()) +A = int(input()) + +a = N % 500 +if a <= A: + print('Yes') +else: + print('No')" +p03632,s086862556,Accepted,"A, B, C, D = map(int, input().split()) +print(max(min(B, D) - max(A, C), 0)) +" +p02602,s731563653,Wrong Answer,"N, K = input().split("" "") +A = [int(i) for i in input().split("" "")] +N = int(N) +K = int(K) + +res = N - K +last = A[K-3] * A[K-2] * A[K-1] + +for i in range(1, res+1): + mul = A[K+i-3] * A[K+i-2] * A[K+i-1] + if mul > last: + print(""Yes"") + else: + print(""No"") + last = mul" +p03105,s249719441,Wrong Answer,"# -*- coding: utf-8 -*- + +S = input().strip() +#----- + +num_red = S.count(""0"") +num_blue = len(S) - num_red + +print( min(num_red,num_blue) * 2 ) +" +p03624,s585672749,Accepted,"s=set(input()) +a=set([chr(ord('a') + i) for i in range(26)]) +b=sorted(s ^ a) +if len(b)!=0: + print(b[0]) +else: + print('None')" +p03221,s505973153,Accepted,"n, m = map(int, input().split()) +py = sorted([[i] + list(input().split()) for i in range(m)], key=lambda x: (int(x[1]), int(x[2]))) + +x = 1 +a = 1 +ans = [] +for i, p, y in py: + if x != int(p): + x = int(p) + a = 1 + + ans.append([i, p.zfill(6)+str(a).zfill(6)]) + a += 1 + +for i, v in sorted(ans): + print(v)" +p03208,s238297489,Accepted,"n,k = map(int,input().split()) +h = [0]*n + +for i in range(n): + h[i] = int(input()) +ans = [] +h.sort() +for i in range(0,n-k+1): + ans.append(h[i+k-1]-h[i]) + #print(i,i+k) +print(min(ans))" +p03095,s939095763,Accepted,"import sys +input = sys.stdin.readline +mod = 10**9 + 7 + +n = int(input()) +s = input().rstrip() + +from collections import Counter + +c = Counter(s) + +n_ = len(c.keys()) + +ans = 1 + +for i in c.keys(): + ans *= (c[i] + 1) + ans %= mod + +ans -= 1 + +print(ans)" +p03469,s934131777,Accepted,"s = input() +print('2018/01/'+s[-2:]) +" +p03472,s999521317,Accepted,"import math + +N, H = map(int, input().split()) +a_l = [] +b_l = [] +for _ in range(N): + a, b = map(int, input().split()) + a_l.append(a) + b_l.append(b) + +a_l.sort(reverse=True) +b_l.sort(reverse=True) +ans = 0 +for i in range(N): + if a_l[0] >= b_l[i]: + break + else: + ans += 1 + H = max(H - b_l[i], 0) + if H <= 0: + break +ans += math.ceil(H / a_l[0]) +print(ans)" +p03821,s482259727,Wrong Answer,"n = int(input()) +a = [] +b = [] +for i in range(n): + x, y = map(int, input().split()) + a.append(x) + b.append(y) +a = a[::-1] +b = b[::-1] + +ans = 0 +for i in range(n): + if b[i]==1: + continue + else: + t = abs((a[i]+ans) % b[i]) + ans += b[i]-t + +print(ans)" +p03852,s695466858,Wrong Answer,"c = input() +if 97 <= ord(c) <= 111: + print('vowel') +else: + print('consonant')" +p02766,s765041973,Wrong Answer,"N, K = map(int, input().split()) + +i = 1 +while True: + if N > K ** i: + i += 1 + else: + i -= 1 + break +print(i + 1) +" +p03419,s423487816,Wrong Answer,"n, m = map(int, input().split()) + +if n >= 3 and m >= 3: + print((n-2)*(m-2)) +elif (n >= 3 and m == 2) or (n == 2 and m >= 3) or (n == 2 and m == 2): + print(0) +elif (n == 1 and m >= 3) or (n >= 3 and n == 1): + print(max(n, m)-2) +elif (n == 1 and m == 2) or (n == 2 and m == 1): + print(0) +elif n == 1 and m == 1: + print(1)" +p02820,s861198917,Accepted,"n,k = map(int, input().split()) +r,s,p = map(int, input().split()) +t = list(input()) + +rsp = {""r"":p, ""s"":r, ""p"":s} +ans = 0 +for i in range(n): + if i < k: ans += rsp[t[i]] + else: + if t[i] != t[i-k]: ans += rsp[t[i]] + else: t[i] = ""a"" +print(ans)" +p03835,s884624357,Accepted,"K,S = map(int,input().split()) + +ans = 0 +for X in range(K+1): + for Y in range(K+1): + Z = S - (X+Y) + if 0 <= Z <= K: + ans += 1 + +print(ans)" +p02725,s767791236,Accepted,"def main(k,n,a): + lst = [] + lst.append(a[0]+(k-a[-1])) + for i in range(n-1): + lst.append(a[i+1]-a[i]) + return k-max(lst) + +k,n = map(int,input().split()) +a = list(map(int,input().split())) +print(main(k,n,a))" +p02768,s029830496,Wrong Answer,"MOD = 10**9 + 7 +n, a, b = map(int, input().split()) + +def comb(n, k): + x, y = 1, 1 + for i in range(n, n-k, -1): + x = x * i % MOD + for i in range(2, k+1): + y = y * pow(i, MOD-2, MOD) % MOD + return x*y % MOD + +ans = pow(2, n, MOD)-1 +ans -= comb(n,a) + comb(n,b) +if ans < 0: + ans += MOD + +print(ans)" +p02994,s246025448,Wrong Answer,"import math +n, l = map(int, input().split()) +a_l = [l + i for i in range(n)] + +min1 = 100 +min2 = 10000 + +for j in a_l: + if j ** 2 <= min2: + min2 = j **2 + min1 = j +print(sum(a_l) - j) + " +p02707,s860057724,Wrong Answer,"num_all = int(input()) +list = input().split("" "") +list_int = [] +for i in list: + list_int.append(int(i)) +print(list_int) + +for j in range(num_all): + a = list_int.count(j) + print(a)" +p02601,s151877422,Accepted,"A,B,C= map(int, input().split()) +K = int(input()) + +for i in range(0,K): + if C <= B or C <= A: + C = C * 2 + continue + + if B <= A: + B = B * 2 + continue + +if C > B and B > A: + print(""Yes"") +else: + print(""No"") +" +p02730,s821657544,Accepted,"from sys import stdin + + +def main(): + input = lambda: stdin.readline()[:-1] + S = input() + + flag = 0 + n = len(S) + if S == S[::-1]: + flag += 1 + s = S[:n//2] + if s == s[::-1]: + flag += 1 + s = S[(n+3)//2-1:] + if s == s[::-1]: + flag += 1 + if flag == 3: + print('Yes') + else: + print('No') + + +main() +" +p03162,s056289217,Accepted,"N = int(input()) +T = [list(map(int, input().split())) for i in range(N)] +dp = [[0 for i in range(3)] for j in range(N+1)] +dp[1] = T[0] +for i in range(2,N+1): + dp[i][0] = max(dp[i-1][1]+T[i-1][0],dp[i-1][2]+T[i-1][0]) + dp[i][1] = max(dp[i-1][0]+T[i-1][1],dp[i-1][2]+T[i-1][1]) + dp[i][2] = max(dp[i-1][0]+T[i-1][2],dp[i-1][1]+T[i-1][2]) +print(max(dp[-1]))" +p03339,s265136984,Accepted,"n=int(input()) +s=input() +lst=[0]*n +lst[0]=s[1:].count(""E"") +for i in range(1,n): + lst[i] = lst[i-1] + if s[i-1]==""W"": + lst[i]+=1 + if s[i]==""E"": + lst[i]-=1 +print(min(lst))" +p03329,s006719456,Accepted,"N = int(input()) +ans = [0] + +for i in range(1, N+1): + dp = [] + k = 1 + while i >= k: + dp.append(ans[i-k]+1) + k *= 6 + k = 1 + while i >= k: + dp.append(ans[i-k]+1) + k *= 9 + ans.append(min(dp)) +print(ans[-1])" +p03317,s831390934,Accepted,"import math +n,k = map(int,input().split()) +a_list = list(map(int,input().split())) +print(math.ceil((n-1)/(k-1)))" +p02888,s260144709,Accepted,"import sys +from bisect import bisect_left + +sys.setrecursionlimit(10 ** 6) +INF = float(""inf"") +MOD = 10 ** 9 + 7 + + +def input(): + return sys.stdin.readline().strip() + + +def main(): + N = int(input()) + L = list(map(int, input().split())) + L.sort() + ans = 0 + for i in range(N): + a = L[i] + for j in range(i + 1, N): + b = L[j] + ans += max(bisect_left(L, a + b) - (j + 1), 0) + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03338,s552291570,Accepted,"N=int(input()) +S=input() + +ans = 0 +for i in range(N): + s1,s2=set(S[:i]),set(S[i:]) + tmp = len(s1.intersection(s2)) + if tmp > ans:ans=tmp + + +print(ans)" +p03543,s542698184,Accepted,"n = input() + +count = 1 +for i in range(len(n)-1): + if n[i] == n[i+1]: + count += 1 + if count >= 3: + break + else: + count = 1 + +if count >= 3: + print('Yes') +else: + print('No')" +p02917,s687600235,Accepted,"n = int(input()) +b = list(map(int,input().split())) + +a = [0 for _ in range(n)] + +for i in range(n-1): + if i == 0: + a[i] = b[i] + a[i+1] = b[i] + if b[i] < b[i-1] and i > 0: + a[i] = b[i] + a[i+1] = b[i] + elif b[i] >= b[i-1] and i > 0: + a[i+1] = b[i] + +print(sum(a)) +" +p02690,s020682335,Accepted,"from math import sqrt + +x = int(input()) + +for i in range(-int(sqrt(sqrt(x))), int(sqrt(sqrt(x))) + 1): + for j in range(-int(sqrt(sqrt(x))), int(sqrt(sqrt(x))) + 1): + if i ** 5 - j ** 5 == x: + print(i, j) + exit() +" +p03011,s504884295,Accepted,"p,q,r=map(int,input().split()) +print(p+q+r-max(p,q,r))" +p03438,s096756424,Accepted,"import math +n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +if sum(a) > sum(b): + print ('No') + exit() +elif sum(a) == sum(b): + for i in range(n): + if a[i] != b[i]: + print ('No') + exit() + print ('Yes') + exit() + +s = sum(b)-sum(a) +c = 0 +for i in range(n): + if a[i] < b[i]: + c += math.ceil((b[i]-a[i])/2) +if c > s: + print ('No') +else: + print ('Yes')" +p02922,s315213216,Accepted,"import math +A, B = map(int, input().split()) + +# B <= 1 + (A - 1) * n +# n >= (B - 1) / (A - 1) + +print(math.ceil((B - 1) / (A - 1)))" +p03000,s914167225,Accepted,"N,X = map(int,input().split()) +L = list(map(int,input().split())) +count = 1 +posi = 0 +for i in L: + posi +=i + if(posi<=X): + count+=1 + else: + break +print(count)" +p02860,s541441484,Accepted,"n = int(input()) +s = input() +if n >= 2 and n % 2 == 0: + half = s[:n//2] +else: + print('No') + exit() + +if half * 2 == s: + print('Yes') +else: + print('No')" +p02678,s786282327,Wrong Answer,"N,M = map(int,input().split()) + +ar = [0]*(N+1) + +for _ in range(M): + a,b = map(int,input().split()) + if ar[a] != 0: + ar[a] = min(ar[a],b) + else: + ar[a] = b + if ar[b] != 0: + ar[b] = min(ar[b],a) + else: + ar[b] = a + +print(""Yes"") +for i in range(1,N): + print(ar[i+1]) +" +p03261,s721438353,Accepted,"dic = {} +N = int(input()) +pre = input() +dic[pre] = 0 +flag = True +for i in range(N-1): + s = input() + if list(pre)[len(pre)-1]!=list(s)[0]: + flag=False + + if s in dic: + flag=False + else: + dic[s]=0 + + pre = s + +print(""Yes"" if flag else ""No"")" +p03486,s860278415,Wrong Answer,"j = ''.join +s = sorted +i = input +l = [j(s(i())), j(s(i(), reverse=True))] +print([""No"", ""Yes""][l == s(l)])" +p03557,s182802769,Accepted,"from bisect import bisect_right, bisect_left +import numpy as np + +n = int(input()) + +top = map(int, input().split()) +mid = map(int, input().split()) +bot = map(int, input().split()) +top = np.array(sorted(top)) +mid = np.array(sorted(mid)) +bot = np.array(sorted(bot)) + +ans = 0 +for i in mid: + top_num = len(top[:bisect_left(top,i)]) + bot_num = len(bot[bisect_right(bot,i):]) + ans += top_num * bot_num + +print(ans)" +p03672,s526173984,Accepted,"S = input() +n = len(S)-1 + +while n > 1: + n = len(S) + S = S[:n-1] + if len(S)%2 != 0: + continue + m = len(S)//2 + x = S[:m] + y = S[m:] + if x == y: + n =len(S) + break + +print(n)" +p03994,s739865108,Wrong Answer,"s = input() +K = int(input()) + +ans = '' +for i, c in enumerate(s): + dif = ord('z') - ord(c) + 1 + if i == len(s) - 1: + K %= 26 + if ord(c) + K > ord('z'): + K -= 26 + ans += chr(ord(c) + K) + elif dif <= K: + ans += 'a' + K -= dif + else: + ans += c +print(ans) +" +p03407,s716642816,Wrong Answer,"a,b,c = map(int, input().split()) + +if a+b>c: + print('Yes') +else: + print('No')" +p02802,s311693081,Accepted,"n,m = [int(x) for x in input().split()] +ans = [0]*(n+1) +w = [0]*(n+1) +for _ in range(m): + a,b = input().split() + a = int(a) + if ans[a] == 1: + continue + if b == ""AC"": + ans[a] = 1 + else: + w[a] += 1 + +aa = 0 +ww = 0 +for i in range(1,n+1): + if ans[i]==1: + aa += 1 + ww += w[i] +print(aa,ww) +" +p02818,s682628524,Accepted,"A, B, K = map(int, input().split()) + +a = max(A - K, 0) #食べ残しと0とを比較して大きい方を返す +K -= A - a #食べた分の枚数を、残りの食べる予定量から減らす +b = max(B - K, 0) #もし負になったら0を返す + +print(""{} {}"".format(a, b))" +p04011,s773778355,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) + +if k < n: + num = k*x + (n-k)*y +else: + num = n*x +print(num)" +p03109,s834445011,Accepted,"from datetime import datetime as dt +tstr = input() +tdatetime = dt.strptime(tstr, '%Y/%m/%d') +tstr = '2019/04/30' +heiseitime = dt.strptime(tstr, '%Y/%m/%d') +if heiseitime >= tdatetime: + print(""Heisei"") +else: + print(""TBD"")" +p02707,s927085355,Accepted,"N = int(input()) +A = list(map(int, input().split())) +l = [] +for i in range(N): + l.append(0) +for x in A: + l[x-1] += 1 +for s in l: + print(s) +" +p02811,s891314326,Accepted,"x, y = map(int, input().split()) + +print(""Yes"" if x*500 >= y else ""No"") +" +p02911,s684981291,Wrong Answer,"n, k, q = map(int, input().split()) +score_list = [k-q for _ in range(n)] +for i in range(q): + tmp = int(input()) + score_list[tmp - 1] = score_list[tmp - 1] + 1 + +print(score_list) +for j in score_list: + if j > 0: + print(""Yes"") + else: + print(""No"") +" +p04031,s708332156,Accepted,"from math import floor, ceil + + +n = int(input()) +A = list(map(int, input().split())) + +x = sum(A) / n +if abs(floor(x) - x) < abs(ceil(x) - x): + x = floor(x) +else: + x = ceil(x) + +answer = 0 +for a in A: + answer += (a - x)**2 + +print(answer) +" +p02994,s791255971,Accepted,"x,y = map(int,input().split()) +ans = 1000000000000000000000000000000 +apple = 0 +for i in range(1, x+1): + apple += i+y-1 + ans = min(ans, abs(i+y-1)) +#print(ans, apple) + +if abs(apple-ans) <= abs(apple+ans): + print(apple-ans) +else: + print(apple+ans)" +p02681,s155541145,Wrong Answer,"# A - Registration +def main(): + S, T = open(0).read().split() + print(""Yes"" if T[:-1] == S else ""No"") + print(T[:-1]) + + +if __name__ == ""__main__"": + main() +" +p02732,s761796540,Accepted,"# collections.counter 使い方 +import collections + +n=int(input()) +a= list(map(int, input().split())) +c = collections.Counter(a) +d = c.most_common() +ans=0 + +for i in range(len(d)): + ans+=(d[i][1]*(d[i][1]-1)//2) + + +for i in range(n): + if c[a[i]]>=2: + print(ans-c[a[i]]+1) + else: + print(ans)" +p02546,s448662144,Accepted,"def main(): + S=input() + if S[len(S)-1]==""s"": + print(S+""es"") + else: + print(S+""s"") + +if __name__==""__main__"": + main()" +p02771,s251080330,Accepted,"a = list(map(int, input().split())) +if len(set(a)) == 2: + print(""Yes"") +else: + print(""No"") +" +p03862,s176962042,Accepted,"N, X = map(int, input().split(' ')) +A = list(map(int, input().split(' '))) + +cost = 0 +diff = max(0, sum(A[0:2]) - X) +A[0] -= max(0, diff - A[1]) +A[1] -= min(A[1], diff) +cost += diff + +for i in range(2, N): + diff = max(0, A[i - 1] + A[i] - X) + A[i - 1] -= max(0, diff - A[i]) + A[i] -= min(A[i], diff) + cost += diff + +print(cost) +" +p02861,s642728303,Accepted,"#C +import math +n = int(input()) +coordinate = [] +for _ in range(n): + x,y = map(int,input().split()) + coordinate.append([x,y]) +dist = 0 +def culc_dist(x1,y1,x2,y2): + return (math.sqrt((x1-x2)**2 + (y1-y2)**2)) + +for i in range(n): + for j in range(n): + if i != j: + dist += culc_dist(coordinate[i][0],coordinate[i][1],coordinate[j][0],coordinate[j][1]) +dist /= n + +print(dist)" +p03331,s811930650,Wrong Answer,"# vim: fileencoding=utf-8 + + +def main(): + n = int(input()) + ans = float(""inf"") + for i in range(2, n // 2 + 1): + a = i + b = n - a + na = sum(map(int, list(str(a)))) + nb = sum(map(int, list(str(b)))) + if ans > na + nb: + ans = na + nb + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03339,s359164777,Wrong Answer,"N = int(input()) +S = input() +direction = [{""E"": 0, ""W"": 0} for _ in range(N + 1)] # direcion[i][""E""] ... i番目までにEを向いている人数 +ans = N +for i in range(N): + direction[i + 1][""E""] = direction[i][""E""] + (1 if S[i] == ""E"" else 0) + direction[i + 1][""W""] = direction[i][""W""] + (1 if S[i] == ""W"" else 0) +for i in range(N): + ans = min(ans, direction[i][""W""] + direction[N][""E""] - direction[i][""E""]) +print(ans) +" +p02639,s769110097,Accepted,"x1, x2, x3, x4, x5 = map(int, input().split()) + +if x1 == 0: + print(1) +elif x2 == 0: + print(2) +elif x3 == 0: + print(3) +elif x4 == 0: + print(4) +elif x5 == 0: + print(5)" +p03041,s449566260,Accepted,"n,k = map(int, input().split()) +s = input() + +print(s[:k-1]+s[k-1].lower()+s[k:])" +p02996,s083272704,Wrong Answer,"from collections import deque +import sys + +n = int(input()) + +ab = [] +for _ in range(n): + ab.append(list(map(int,input().split()))) + +ab = sorted(ab, key=lambda x:x[1], reverse=True) + +d = [] +d = deque(d) + +while len(ab) > 0: + d = deque([]) + d.append(ab.pop()) + while True: + if len(ab) == 0: + break + if ab[-1][1] == d[0][1]: + d.append(ab.pop()) + else: + break + num = 0 + for i in range(len(d)): + a,b = d.pop() + num += a + if num > b: + print('No') + sys.exit() + +print('Yes') +" +p02767,s048763211,Accepted,"N=int(input()) +X=list(map(int,input().split())) +p=round(sum(X)/len(X)) +ans=0 +for i in range(len(X)): + ans+=(X[i]-p)**2 +print(ans) +" +p02606,s017262075,Accepted,"l,r,d=map(int,input().split()) +print(r//d-(l-1)//d)" +p03211,s145411796,Accepted,"S=input() +c=[] +for i in range(len(S)-2): + r=abs(753-(100*int(S[i])+10*int(S[i+1])+int(S[i+2]))) + c.append(r) + +print(min(c)) + + +" +p02910,s413238774,Wrong Answer,"s=input() +ans=0 +for i in range(0,len(s),2): + if s[i]!='R' and s[i]!='U' and s[i]!='D': + ans=1 +for j in range(1,len(s),2): + if s[i]!='U' and s[i]!='L' and s[i]!='D': + ans=1 +if ans==0: + print('Yes') +else: + print('No')" +p02912,s080416321,Wrong Answer,"from heapq import heapify,heappush,heappop + +def main(): + N,M = map(int,input().split()) + A = [-x for x in map(int,input().split())] + heapify(A) + for i in range(M): + tmp = heappop(A) + tmp2 = tmp//2 + heappush(A,tmp2) + ans = 0 + for i in range(N): + ans += A[i] + + ans = abs(ans) + return ans + +print(main()) +" +p03592,s253309561,Accepted,"n, m, k = map(int, input().split()) +for nn in range(n+1): + for mm in range(m+1): + if nn*m+n*mm-2*nn*mm==k: + print('Yes') + break + else: + continue + break +else: + print('No')" +p03352,s780576539,Accepted,"x = int(input()) + +ans = 1 +for i in range(2, x): + if i * i > x: + break + + now = i + while now * i <= x: + now *= i + if now > ans: + ans = now + +print(ans)" +p03087,s807092865,Wrong Answer,"n,q = map(int, input().split()) +s = input() +a = [0]*n +for i in range(1,n): + a[i] = a[i-1] + if (s[i]==""C""): + if (s[i-1]==""A""): + a[i] += 1 +print(a) +for i in range(q): + l,r = map(int, input().split()) + print(a[r-1]-a[l-1]) + " +p02754,s288913186,Accepted,"n,a,b=map(int,input().split()) +m=n//(a+b) +c=n-m*(a+b) +if c<=a: + print(m*a+c) +else: + print(m*a+a) +" +p02795,s612218535,Accepted,"h = int(input()) +w = int(input()) +n = int(input()) + +print(n//max(h,w) if n%max(h,w)==0 else n//max(h,w)+1)" +p02708,s716115847,Accepted,"n, k = map(int, input().split()) +res = 0 +divnum = 10 ** 9 + 7 +for i in range(k, n + 2): + res += i * (n - i + 1) + 1 + res %= divnum +print(res)" +p03778,s158942898,Wrong Answer,"w,a,b = map(int, input().split()) + +if a+w < b: + print(b-(a+w)) +elif a<=b<=a+w: + print(0) + +if b+w < a: + print(a-(b+w)) +elif a<=b+w<=a+w: + print(0)" +p02801,s548238018,Wrong Answer,"# !/use/bin/python3 + +"""""" +https://atcoder.jp/contests/abc151/tasks/abc151_a +Next Alphabate +"""""" + +def solve(c): + print(c) + ans = ord(c) + return chr(ans+1) + +if __name__ == ""__main__"": + c = input() + print(solve(c)) +" +p03796,s749716935,Accepted,"MOD=10**9+7 +N=int(input()) + +answer=1 +for i in range(2,N+1): + answer*=i + answer%=MOD + +print(answer)" +p03449,s061229097,Accepted,"N = int(input()) +A = [list(map(int, input().split())) for _ in range(2)] + +print(max([sum(A[0][:j+1]) + sum(A[1][j:]) for j in range(N)])) +" +p03672,s024617829,Wrong Answer,"S = str(input()) +N = len(S) + +def f(): + for erase in range(2, N + 1): + new = S[0 : N - erase] + if len(new) % 2 == 1: continue + flg = 1 + for i in range((N - erase) // 2): + if new[i] != new[(N - erase) // 2 + i]: flg = 0 + break + if not flg: continue + return len(new) + +print(f())" +p04019,s644675890,Wrong Answer,"s = list(set(list(input()))) + +if len(s)%2 == 0: + if (""N"" in s and""S"" in s) or (""E"" in s and ""W"" in s): + print('Yes') +else: + print('No')" +p03146,s262065992,Accepted,"s = int(input()) +A = [] +A.append(s) + + +def has_duplicates(seq): + return len(seq) != len(set(seq)) +itr = 1 +while True: + #print(itr,A) + itr += 1 + if A[-1] % 2 == 0: + A.append(int(A[-1] / 2)) + else: + A.append(int(3*A[-1]+1)) + #print(A) + if has_duplicates(A): + print(itr) + break + " +p03150,s876871050,Accepted,"s = input() +for i in range(7): + if s[:i] + s[-7 + i:] == ""keyence"": + print(""YES"") + exit() +print(""NO"")" +p02684,s663070568,Wrong Answer,"N, K = map(int, input().split()) +A = list(map(int, input().split())) +temp = 1 +count = 0 +ans = 0 + +dict_num = {} +set_num = set() + +for _ in range(K): + count += 1 + temp = A[temp-1] + if temp in set_num: + dict_num[temp] += 1 + if dict_num[temp] == 3: + break + else: + dict_num[temp] = 1 + set_num.add(temp) + continue +else: + ans = temp + + +if count == K: + pass +else: + count = count - list(dict_num.values()).count(1) -1 + mod = K % count + for _ in range(mod + 1): + temp = A[temp-1] + else: + ans = temp + +print(ans)" +p02912,s871835069,Wrong Answer,"n, m = map(int, input().split()) +a = list(map(int, input().split())) + +a.sort(reverse = True) + +for i in range(m): + a[0] = a[0] // 2 + if sum(a) == 0: + break + for j in range(1, n): + if a[0] < a[j]: + a[0], a[j] = a[j], a[0] + break +print(sum(a))" +p04033,s813456369,Wrong Answer,"a, b = map(int, input().split()) +n = a * b +if n == 0: + print(0) +elif n > 0: + print('Positive') +else: + print('Negative')" +p03951,s932325908,Accepted,"n = int(input()) +s = list(input()) +t = list(input()) +count = 0 +for i in range(n, 0, -1): + if s[-i:] == t[:i]: + count = i + break +print(2 * n - count)" +p03693,s663062817,Wrong Answer,"r, g, b = map(int,input().split()) + +if (r * g * b) % 4 == 0: + print(""YES"") +else: + print(""NO"")" +p03011,s290868984,Wrong Answer,"p,q,r=map(int,input().split()) +if p+q<=q+r and p+q<=p+r: + print(p+q) +if p+r<=p+q and p+r<=q+r: + print(p+r) +if q+r<=p+r and q+r<=p+q: + print(q+r) +" +p03221,s846656906,Wrong Answer,"import sys +input = sys.stdin.readline + +N, M = map(int, input().split()) +PY = [tuple(map(int, input().split())) for _ in range(M)] + +city_count = [0]*(N+1) +for p, y in PY: + city_count[p] += 1 +for ken, count in enumerate(city_count): + [print(str(1*10**12+ken*10**6+i)[1:]) for i in range(1,count+1)] +" +p02792,s916564534,Accepted,"import math + +n = int(input()) +top_bottom_num = {str(i): {str(j): 0 for j in range(10)} for i in range(10)} +for i in range(1, n + 1): + str_num = str(i) + top_bottom_num[str_num[0]][str_num[-1]] += 1 +ans = 0 +for i in range(10): + for j in range(10): + i_j = top_bottom_num[str(i)][str(j)] + j_i = top_bottom_num[str(j)][str(i)] + ans += i_j * j_i +print(ans)" +p03803,s100064806,Accepted,"a,b=map(int,input().split()) +if a==1:a=14 +if b==1:b=14 +if a>b:print(""Alice"") +elif a s: + x = (time - s)/f + s += ceil(x)*f + time = s + c + print(time) +print(0) + + + + + + + + +" +p03910,s092100002,Accepted,"n = int(input()) + +cnt = 0 +for i in range(1, n + 1): + cnt += i + if cnt >= n: + ans, exc = i, cnt - n + break + +for j in range(1, ans + 1): + if exc != j: + print(j) +" +p03625,s537906403,Accepted,"from collections import Counter + +input() +d = Counter(map(int, input().split())) +d = dict(sorted(d.items(), reverse=True)) +ans = [] +for i, j in d.items(): + if j >= 4: + ans.append(i) + if j >= 2: + ans.append(i) + if len(ans) >= 2: + print(ans[0] * ans[1]) + break +else: + print(0)" +p02784,s773019833,Accepted,"h, n = map(int, input().split()) +if h <= sum(list(map(int, input().split()))): + print('Yes') +else: + print('No') + + " +p04043,s129428509,Accepted,"nums = list(input().split()) + +if nums.count('5') == 2 and nums.count('7') == 1: + print(""YES"") +else: + print(""NO"")" +p03556,s789331881,Wrong Answer,"c=0 +n=int(input()) +for i in range(n): + if i**2<=n:c=i**2 +print(c) +" +p03371,s757219422,Wrong Answer,"a,b,c,x,y=map(int,input().split()) + +if x>y: + print(min(2*x*c,2*y*c+(x-y)*a,a*x+b*y)) +else: + print(min(2*y*c,2*x*c+(y-x)*a,a*x+b*y))" +p03150,s816385611,Accepted,"s = input() + +k = 'keyence' + +for i in range(len(s)): + for j in range(i, len(s)): + t = s[:i] + s[j:] + if k == t: + print('YES') + exit() + +print('NO') + +" +p03042,s489861810,Accepted,"s = input() +mmyy = (1 <= int(s[:2]) <= 12) +yymm = (1 <= int(s[2:]) <= 12) +if mmyy: + if yymm: + print('AMBIGUOUS') + else: + print('MMYY') +else: + if yymm: + print('YYMM') + else: + print('NA')" +p03254,s437960284,Accepted,"N,x = map(int,input().split()) +a = map(int,input().split()) +ret = 0 +for i,n in enumerate(sorted(a)): + if i == N-1 and n == x: + x -= n + ret += 1 + elif i < N-1 and n <= x: + x -= n + ret += 1 + else: + break +print(ret)" +p03013,s948226110,Wrong Answer,"n,m = map(int,input().split()) +stair = [] +for i in range(m): + stair.append(int(input())) + +ans = [0]*(n+1) +ans[0] = 1 +ans[1] = 1 +for i in range(n+1): + if i==0: + continue + + elif i in stair: + ans[i] = 0 + else: + ans[i] = ans[i-2] + ans[i-1] +print(ans[n]%1000000007)" +p02630,s156185207,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +Q = int(input()) + +data = [0] * 100001 + +def my_sum(d): + retval = 0 + + for i in range(len(d)): + if d[i] == 0: + continue + retval += d[i] * i + return retval + +for i in A: + data[i] += 1 + +sum_val = my_sum(data) + +for i in range(Q): + B, C = map(int,input().split()) + + sum_val = sum_val - (data[B] * B) + ((data[C] + data[B]) * C) + + data[C] += data[B] + data[B] = 0 + + print(sum_val) +" +p02972,s289807886,Wrong Answer,"N = int(input()) +al = list(map(int, input().split())) + +print(-1) +exit() + +al = [0] + al # 1-index +multi_cnts = [0]*(N+1) +ans = [] +for n in range(N,0,-1): + if multi_cnts[n] != al[n]: + ans.append(n) + for i in range(2, int(-(-n**0.5//1))+1): + if n%i == 0: + multi_cnts[i]+=1 + multi_cnts[i]%=2 + + +print(len(ans)) +if ans: print(*ans)" +p03073,s157424672,Wrong Answer,"S = list(input()) + +cnt = 0 +a = S[0] + +for i in range(1,len(S)): + if S[i] != a: + cnt += 1 + if S[i] == ""1"": + a = ""0"" + else: + a = ""1"" + else: + a = S[i] + +print(int(cnt))" +p02922,s816893941,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + A, B = map(int, readline().split()) + print((B - 1 + A - 1 - 1) // (A - 1)) + + return + + +if __name__ == '__main__': + main() +" +p04020,s145502698,Accepted,"N = int(input()) +A = [int(input()) for _ in range(N)] +ans = 0 +if 0 not in A: + ans = sum(A)//2 +else: + now = 0 + for i in range(N): + if A[i] == 0 or i == N-1: + ans += sum(A[now:i+1])//2 + now = i+1 +print(ans)" +p03067,s404903927,Accepted,"import sys +input = sys.stdin.readline + +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) + +def main(): + mod=10**9+7 + L=LI() + if L[2]==(sum(L) - min(L) - max(L)): + print(""Yes"") + else: + print(""No"") + +main() +" +p02859,s651256499,Accepted,"r = int(input()) +print(r**2) +" +p02818,s844906253,Accepted,"x = input().split() + +a = int(x[0]) +b = int(x[1]) +k = int(x[2]) + +if(a-k > 0): + print(a-k,b) + exit() +elif(a-k == 0): + print(0,b) + exit() +elif(a-k < 0 and b-(k-a) > 0): + print(0,b-(k-a)) + exit() +elif(a-k < 0 and b-(k-a) == 0): + print(0,0) + exit() +elif(a-k < 0 and b-(k-a) < 0): + print(0,0) + exit()" +p03076,s119495702,Wrong Answer,"l = [int(input()) for _ in range(5)] + +ans = 0 +min_div = 10 +for i in l: + ans += 10 * (i + 10 - 1) //10 + if i % 10 != 0: + min_div = min(min_div, i % 10) +print(ans - (10 - min_div)) +" +p03219,s815140300,Wrong Answer,"X, Y = map(int, input().split()) +print((X+Y)/2)" +p03695,s560224240,Accepted,"N = int(input()) +a = list(map(int, input().split())) + +ans = [] +over = 0 +for i in range(N): + n = a[i] // 400 + if n < 8: + if n not in ans: + ans.append(n) + else: + over += 1 + +cnt = len(ans) + over +if len(ans) > 0: + print(len(ans), cnt) +else: + print(1, cnt)" +p03861,s550715662,Accepted,"import math +import sys +import os +from operator import mul + +sys.setrecursionlimit(10**7) + +def _S(): return sys.stdin.readline().rstrip() +def I(): return int(_S()) +def LS(): return list(_S().split()) +def LI(): return list(map(int,LS())) + +if os.getenv(""LOCAL""): + inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt' + sys.stdin = open(inputFile, ""r"") +INF = float(""inf"") + +a,b,x = LI() + +ans = 0 +if a > 0: + a -= 1 +else: + ans += 1 +ans += b//x - a//x + +print(ans)" +p03012,s333996969,Wrong Answer,"N = int(input()) +N_List = sorted(list(map(int,input().split())), reverse=True) +S_a = 0 +S_b = 0 +for i in range(N): + if S_a <= S_b: + S_a += N_List[i] + else: + S_b += N_List[i] +print(abs(S_a-S_b))" +p02639,s459935259,Accepted,"input = input() + +nums = input.split("" "") + +for index, num in enumerate(nums): + if int(num)==0: + print(index+1)" +p03448,s595737837,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +cnt = 0 +for i in range(a+1): + for j in range(b+1): + for k in range(c+1): + ans = i*500 + j*100 + k*50 + if ans == x: + cnt += 1 + +print(cnt)" +p02601,s573850731,Wrong Answer,"A,B,C = map(int, input().split()) +K = int(input()) + +for i in range(K): + if A > B: + B *= 2 + else: + C *= 2 + +if A < B and B < C: + print('Yes') +else: + print('No') +" +p03479,s755121119,Accepted,"x, y = map(int, input().split()) + +n = x +ans = 0 + +while n <= y: + n *= 2 + ans += 1 + +print(ans) +" +p03262,s065054614,Accepted,"import itertools +import math +import sys +from collections import Counter +from fractions import gcd +from functools import reduce + +n, start = map(int, input().split()) +x = list(map(int, input().split())) +x.append(start) +x.sort() +# print(x) +gaps = [] +for i in range(n): + gaps.append(x[i + 1] - x[i]) +# print(gaps) +if len(gaps) == 1: + print(gaps[0]) +else: + ans = reduce(gcd, gaps) + print(ans) +" +p02880,s409356840,Accepted,"import itertools +N = int(input()) + +if N > 81: + print('No') + exit() + +for i,j in itertools.product(range(1,10),range(1,10)): + if i*j == N: + print('Yes') + exit() + +print('No')" +p03071,s163357034,Accepted,"# python 3.4.3 +import sys +input = sys.stdin.readline +import numpy as np + +# ------------------------------------------------------------- +# function +# ------------------------------------------------------------- + + +# ------------------------------------------------------------- +# main +# ------------------------------------------------------------- +A,B = map(int,input().split()) + +print(max(A+max(A-1,B), B+max(A,B-1)))" +p03854,s158156324,Wrong Answer,"S = input() +results = True +while results: + for key_word in [""erase"", ""eraser"", ""dream"", ""dreamer""]: + if S.endswith(key_word): + S = S[:-len(S)] + continue + if S == '': + print(""YES"") + results = False + break + else: + print(""NO"") + results = False + break" +p03592,s417411900,Accepted,"N, M, K = map(int, input().split()) + +ans = 0 +for n in range(N + 1): + for m in range(M + 1): + black = n * (M - m) + m * (N - n) + if black == K: + print('Yes') + exit() +print('No') +" +p02862,s674520134,Wrong Answer,"mod = 10 ** 9 + 7 +x, y = map(int, input().split()) + +def nCm_mod(A, B, mod): + mul_one = 1 + mul_two = 1 + + for i in range(B): + mul_one *= A - i + mul_two *= i + 1 + mul_one %= mod + mul_two %= mod + + return (mul_one * pow(mul_two, mod-2, mod)) % mod + +if (x + y) % 3 != 0: + print(0) +else: + n = (2 * y - x) // 3 + m = (2 * x - y) // 3 + + comb_num = nCm_mod(n+m, min(n,m), mod) + print(comb_num) + " +p02677,s418315205,Wrong Answer,"import math + +A,B,H,M = map(int, input().split()) + +degH = H*360/12 + M*360/12/60 +degM = M*360/60 + +angle = abs(degH-degM) + +dist = 0 +if angle == 0: + dist = 0 +else: + dist = (A**2 + B**2 - 2*A*B * math.cos(math.radians(angle)))**(1/2) + +print(dist)" +p03250,s665139706,Wrong Answer,"A, B, C = map(int, input().split()) +result1 = A + B*10 + C +result2 = A*10 + B + C + +print(max(result1, result2))" +p02639,s126051546,Accepted,"import sys +nun_list = list(map(int, input().split())) +count=1 +for i in nun_list: + if i == 0: + print(count) + sys.exit() + count+=1" +p03264,s437516182,Wrong Answer,"K=int(input()) +print(((K/2)/2)*((K+1)/2))" +p03035,s800813676,Accepted,"a, b = map(int, input().split()) + +if 13 <= a: + print(b) +elif 6 <= a: + print(b // 2) +else: + print(0) +" +p03309,s346170466,Accepted,"n = int(input()) +a = list(map(int,input().split())) +for i in range(n): + a[i]-=(i+1) +# print(a) +a.sort() +# print(a) +s = 0 +for i in a: + s += abs(i) +if abs(a[(n-1)//2]) > abs(a[n//2]): + t = a[(n-1)//2] +else: + t = a[n//2] +ans = 0 +for i in a: + ans += abs(i-t) +# print(t) +print(ans)" +p02933,s353917288,Accepted,"a = int(input()) +s = input() +print(s if a>=3200 else 'red')" +p03723,s497578326,Accepted,"def main(): + A,B,C=map(int,input().split()) + ans=0 + tmp=set() + while A%2==0 and B%2==0 and C%2==0: + A,B,C=(B+C)//2,(C+A)//2,(A+B)//2 + if (A,B,C) in tmp: + print(-1) + exit() + else: + tmp.add((A,B,C)) + ans += 1 + print(ans) + +main()" +p02700,s101137610,Accepted,"import math +a,b,c,d= map(int,input().split()) +i = math.ceil(c/b) +j = math.ceil(a/d) +if i <= j: + print(""Yes"") +else: + print(""No"") +" +p02725,s546995181,Accepted,"k, n = map(int, input().split()) +a = list(map(int, input().split())) + +a += [a[0] + k] +maxPath = max(b - a for a,b in zip(a,a[1:])) +print(k - maxPath)" +p03699,s568459373,Accepted,"N = int(input()) +S = [] +for _ in range(N): + S.append(int(input())) +w = sum(S) + +if w % 10 != 0: + print(w) +else: + S.sort() + for i in range(N): + if S[i] % 10 != 0: + print(w - S[i]) + break + else: + print(0) +" +p03160,s805102982,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +dp=[float(""INF"")]*(N+1) +dp[0]=0 +for i in range(1,N): + dp[i]=min(dp[i],abs(A[i]-A[i-1])) +print(dp[N-1]) +" +p02713,s311708740,Accepted,"from math import gcd + +k=int(input()) + +ans=0 +for i in range(1,k+1): + for j in range(1,k+1): + for l in range(1, k+1): + ans+=gcd(gcd(i,j),l) + +print(ans)" +p03592,s414899291,Accepted,"n,m,k = map(int,input().split()) + +for i in range(n+1): + for j in range(m+1): + if i*m-2*i*j+j*n == k: + print(""Yes"") + exit() +print(""No"")" +p02640,s793137868,Accepted,"x, y = map(int, input().split()) + +for i in range(x + 1): + for j in range(x + 1): + if 2 * i + 4 * j == y and i + j == x: + print('Yes') + exit() + +print('No') +" +p02755,s309301528,Accepted,"A, B = map(int, input().split()) +flag = 0 +for i in range(1300): + if int(i*0.08) == A and int(i*0.1) == B: + print(i) + flag = 1 + break +if flag == 0: + print(-1) + " +p02860,s655910222,Wrong Answer,"r = int(input()) +print(r**2)" +p02602,s763005126,Wrong Answer,"import numpy as np + +n,k = list(map(int, input().split())) +a = list(map(int, input().split())) + +ans = [] +point_before = np.prod(a[:k]) + +for i in range(n-k): + point = np.prod(a[i+1:k+i+1]) + if point_before < point: + ans.append('Yes') + else: + ans.append('No') + point_before = point + # print(point_before) + +for a in ans: + print(a) +" +p03711,s698235706,Wrong Answer,"x, y = map(int,input().split()) +#print(x,y) + +a = [1,3,5,7,8,12] +#print(a) +b = [4,6,9,11] +c = [2] + +if (x in a) and (y in a): + print(""YES"") +elif (x in b) and (y in b): + print(""YES"") +elif (x in c) and (y in c): + print(""YES"") +else: + print(""NO"")" +p02618,s387588626,Accepted,"D=int(input()) +c = list(map(int,input().split())) +s=[[0 for e in range(26)] for f in range(D)] +for i in range(D): + s[i]=list(map(int,input().split())) +last=[0]*26 +ans=0 +point=[0]*D +for i in range(D): + saidai=-(10**10) + kouho=1 + for j in range(26): + if s[i][j]+c[j]*((i+1)-last[j])>=saidai: + kouho=j+1 + saidai=s[i][j]+c[j]*((i+1)-last[j]) + print(kouho)" +p02570,s248778268,Accepted,"if __name__ == ""__main__"": + d, t, s = (int(x) for x in input().split()) + if d <= t * s: + print('Yes') + else: + print('No') +" +p03037,s925627359,Accepted,"N,M=map(int,input().split()) +ans=0 +L,R=0,(10**5)+1 +for i in range(M): + l,r=map(int,input().split()) + L=max(L,l); R=min(R,r) + if r2019: + print(0) +else: + for i in range(l,r+1): + s.append(i%2019) + s.sort() + print(s[0]*s[1]) + +" +p03250,s943842680,Wrong Answer,"import os +l = list(map(int,input().split())) +l.sort() +a =l[2]*10+l[1]+l[2] +print(a) +" +p02690,s349213072,Wrong Answer,"def q4(): + X = int(input()) + for i in range(-65, 65): + for j in range(-65, 65): + if i**5 - j**5 == X: + print(i, j) + return + + +if __name__ == '__main__': + q4() +" +p02973,s430692360,Accepted,"from bisect import bisect_left +from collections import deque + +n = int(input()) +A = [int(input()) for _ in range(n)] + +D = deque([]) + +for a in A: + i = bisect_left(D, a) + if i == 0: + D.appendleft(a) + else: + D[i-1] = a + +print(len(D))" +p03061,s342803924,Wrong Answer,"import math +from itertools import accumulate + +n = int(input()) +a = list(map(int, input().split())) + +fromright = list(accumulate(a, math.gcd)) +a.reverse() +fromleft = list(accumulate(a, math.gcd)) +fromleft.reverse() + +gcd = [] + +gcd.append(fromleft[1]) + +for i in range(1, n-1): + gcd.append(math.gcd(fromright[i-1], fromleft[i+1])) + +gcd.append(fromright[1]) + +if n == 2: + print(math.gcd(a[1], a[0])) +else: + print(max(gcd))" +p02753,s781039250,Accepted,"S = input() + +if 'A' in S: + if 'B' in S: + print('Yes') + else: + print('No') +else: + print('No')" +p03479,s642878222,Accepted,"x , y = map(int, input().split()) +cnt = 0 +while x <= y: + x *=2 + cnt += 1 +print(cnt)" +p02778,s095825630,Accepted,"print(len(input())*""x"")" +p02612,s832001166,Accepted,"N=int(input()) + +if N%1000==0: + print(0) +else: + ans =1000-(N%1000) + print(int(ans))" +p03150,s399839849,Accepted,"s=input() +ans=False +for x in range(len(s)): + for y in range(x,len(s)): + if (s[:x]+s[y:])=='keyence': + ans=True +if ans: + print('YES') +else: + print('NO')" +p03137,s250074355,Accepted,"n,m = map(int,input().split()) + +t = list(map(int,input().split())) + +t.sort() +memo = [] +for i in range(m-1): + memo.append(t[i+1]-t[i]) +memo.sort() +#print(memo) +ans = 0 +for i in range(m-n): + #print(i) + ans += memo[i] +print(ans)" +p03437,s552169794,Accepted,"x,y=map(int,input().split()) +if(x%y==0): + print('-1') +else: + print(x)" +p02820,s272571180,Accepted,"N, K = map(int, input().split()) +A = tuple(map(int, input().split())) +T = input() + +bestmove = {'r':2, 's':0, 'p':1} + +ans = 0 +for k in range(K): + t = T[k::K] + prev = -1 + for opp in t: + me = bestmove[opp] + if prev != me: + prev = me + ans += A[me] + else: + prev = -1 + +print(ans) +" +p03860,s390488485,Wrong Answer,"x=""AtCoder""+input()+""Contest"" + +print(""A""+x[7]+""C"")" +p02879,s909113722,Wrong Answer,"A,B = map(int,input().split()) +if A<=9 and B<=9: + print()" +p02817,s072908889,Wrong Answer,"a = input().split() +print(a[0],a[1])" +p03042,s785071528,Accepted,"S = input() +S_front = S[:2] +S_back = S[2:] + +if 0 < int(S_front) < 13: + if 0 < int(S_back) < 13: + print(""AMBIGUOUS"") + else: + print(""MMYY"") +else: + if 0 < int(S_back) < 13: + print(""YYMM"") + else: + print(""NA"")" +p03095,s031532923,Accepted,"A=int(input()) +l=list(input()) +mod=10**9+7 +import collections +l=list(collections.Counter(l).values()) +l=[i+1 for i in l] +ans=1 +for i in l: + ans*=i + ans%=mod +print(ans-1)" +p03862,s222955742,Wrong Answer,"N,x = map(int,input().split()) +ls = list(map(int,input().split())) +ans = 0 +for i in range(N-1): + if ls[i]+ls[i+1] <= x: + continue + else: + eat = - x + ls[i] + ls[i+1] + ls[i+1] -= eat + ans += eat +print(ans)" +p03711,s689433924,Accepted,"x,y=map(int,input().split()) +grp1=[1,3,5,7,8,10,12] +grp2=[4,6,9,11] + +if x in grp1 and y in grp1: print(""Yes"") +elif x in grp2 and y in grp2: print(""Yes"") +else: print(""No"")" +p03062,s465013107,Wrong Answer,"n=int(input()) +a=[int(i) for i in input().split()] +x=0 +b=[] +for i in a: + if i<0: x=(x+1)%2 + b.append(abs(i)) +b.sort() +print(sum(b)-b[0] if x else sum(b))" +p03803,s439092174,Wrong Answer,"a,b=map(int,input().split()) + +if a==b: + print('Draw') + +elif a==1 or a>b: + print('Alice') + +elif b==1 or a len(s)-1: + cnt -= 1 + if i >= len(s): + break +print(cnt)" +p03000,s215347891,Wrong Answer,"n,x = map(int,input().split()) +l = list(map(int,input().split())) + +#print(l) + +a = [0] + +for i in range(n): + a.append(a[i] + l[i]) +# print(a) + + +for j in range(len(a)): + if a[j] <= x: + if j == len(a): + print(len(a)) + pass + else: + print(j) + break +" +p03705,s167115960,Accepted,"N, A, B = map(int, input().split()) +print(max(B*(N-2)-A*(N-2)+1, 0))" +p03211,s438689585,Accepted,"s = list(input()) +ans = float('inf') + +for i in range(len(s)-2): + num = int("""".join(s[i:i+3])) + if abs(ans) > abs(num-753): + ans = abs(num-753) +print(ans)" +p03659,s097756522,Accepted,"import numpy as np +n = int(input()) +a_ls = list(map(int, input().split())) + +sum_ls = list(np.cumsum(a_ls)) +sum_ls.insert(0,0) + +ans = float('inf') +for i in range(1,n): + su = sum_ls[i] + ara = sum_ls[-1] - sum_ls[i] + dif = abs(su-ara) + if dif < ans: + ans = dif + +print(ans) +" +p02995,s012569145,Wrong Answer,"def gcd(a,b):#最大公約数を返す。Euclid + if a= A + B: + print (A*x+B*y) + exit(0) + +if C * 2 <= A and C * 2 <= B: + print (max(x,y) * 2 * C) + exit(0) + +if x > y: + if A >= C * 2: + c = x * 2 + else: + c = y * 2 + a = (x-y) +else: + if B >= C * 2: + c = y * 2 + else: + c = x * 2 + b = (y-x) +print(A*a + B*b + C*c)" +p02947,s120753833,Accepted,"n = int(input()) +d = {} +ans = 0 +for _ in range(n): + s = list(input()) + s.sort() + s = """".join(s) + if s in d: + d[s] += 1 + ans += d[s] + else: + d.update({s : 0}) +print(ans)" +p02836,s444754456,Accepted,"S = input() + +count = 0 +for i in range(len(S)//2): + if S[i] != S[len(S)-1-i]: + count += 1 + +print(count) +" +p03038,s518582689,Wrong Answer,"import heapq + +N, M = map(int, input().split()) +A = list(map(int, input().split())) + +for _ in range(M): + B, C = map(int, input().split()) + A += B * [C] +" +p04020,s559574602,Wrong Answer,"N=int(input()) +sum=0 +A=int(input()) +sum+=A//2 +a=A%2 +for _ in range(N-1): + A=int(input()) + sum+=A//2 + b=A%2 + m=min(a,b) + if m>0: + sum+=m + b-=m + a=b +print(sum) + + + + +" +p02582,s266067077,Accepted,"s=input() +ans = 0 +if ""R"" in s: + ans = 1 +if s[0] == s[1] == ""R"": + ans += 1 +if s[1] == s[2] == ""R"": + ans += 1 +print(ans) +" +p02900,s931196857,Accepted,"def gcd(a,b): + if a%b == 0: + return b + else: + return gcd(b, a%b) +ans = 1 +def fact(n): + global ans + p = 2 + while p**2 <= n: + flag = False + while n%p == 0: + flag = True + n /= p + p += 1 + if flag: + ans += 1 + if n!= 1: + ans += 1 +a,b = map(int, input().split()) +g = gcd(a,b) +fact(g) +print(ans)" +p02547,s456296904,Wrong Answer,"N = int(input()) +count = 0 +for i in range(N): + a, b = map(int, input().split()) + if a == b: + count += 1 +if count >= 3: + print(""Yes"") +else: + print(""No"") +" +p02765,s837688041,Wrong Answer,"n,r=map(int,input().split()) +if n<10: + print(r-100*(10-n)) +else: + print(r) +" +p02796,s467465673,Accepted,"n = int(input()) +robots = [] +for _ in range(n): + x, l = map(int, input().split()) + robots.append([x-l, x+l]) + +robots = sorted(robots, key=lambda x: x[1]) + +cnt = 1 +current_end = robots[0][1] +for i in range(1, n): + if current_end <= robots[i][0]: + cnt += 1 + current_end = robots[i][1] + +print(cnt)" +p02726,s966120305,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N,X,Y = map(int,readline().split()) +ans = [0]*N +for i in range(1,N): + for j in range(i+1,N+1): + dist = min(j-i,abs(i-X)+1+abs(j-Y),abs(i-Y)+1+abs(j-X)) + ans[dist]+=1 +print('\n'.join(str(n) for n in ans[1:]))" +p03852,s038255469,Accepted,"c=input() +if c in ['a','e','i','o','u']: + print('vowel') +else: + print('consonant')" +p02731,s849858195,Accepted,"L = int(input()) +k = L/3 +print(k**3)" +p02583,s049454555,Wrong Answer,"N = int(input()) +L = list(map(int, input().split())) +R = list(set(L)) +L.sort() +R.sort() +M = len(R) +ans = 0 +if M <= 2: + print(ans) +else: + for i in range(N): + for j in range(N): + for k in range(N): + if L[i] + L[j] > L[k] and L[i] < L[j] and L[j] < L[k]: + ans += 1 +print(ans) +" +p02783,s605401732,Accepted,"n,k=map(int,input().split()) +print((n-1)//k+1)" +p03625,s307544146,Accepted,"from collections import Counter +n = int(input()) +a = Counter(list(map(int, input().split()))) +a = [list(x) for x in a.items() if x[1]>=2] +a.sort(reverse=True, key=lambda x: (x[0], x[1])) +count = 0 +base = 4 +for i in range(len(a)): + if count == 1: + print(l*a[i][0]) + exit() + else: + l = a[i][0] + count += 1 + + if a[i][1]>=4: + print(a[i][0]*a[i][0]) + exit() + +print(0)" +p03163,s538982482,Accepted,"N, W = map(int, input().split()) +wv = [list(map(int, input().split())) for _ in range(N)] + +dp = [[-1 for _ in range(W + 1)] for _ in range(N + 1)] +for i in dp: + i[0] = 0 +dp[0] = [0 for _ in range(W + 1)] + +for i in range(1, N + 1): + for l in range(1, W + 1): + if l - wv[i - 1][0] < 0: + dp[i][l] = dp[i - 1][l] + else: + dp[i][l] = max(dp[i - 1][l], dp[i - 1][l - wv[i - 1][0]] + wv[i - 1][1]) +print(dp[N][W]) +" +p03264,s055230487,Wrong Answer,"k = int(input()) +s = 0 +for x in range(1, k + 1): + for y in range(x, k + 1): + if y % 2 == 1 and x % 2 == 0: + s = s + 1 +print(s) +" +p03625,s041505013,Accepted,"n=int(input()) +l=list(map(int,input().split())) +d={} +for a in l: + if a in d: + d[a]+=1 + else: + d[a]=1 +ks=sorted(d,reverse=True) +f=0 +for i,k in enumerate(ks): + if d[k]>=4: + print(k*k) + exit() + if d[k]>=2: + f=k + break +s=0 +for k in ks[i+1:]: + if d[k]>=2: + s=k + break +print(f*s) +" +p03206,s302836006,Accepted,"d=int(input()) +ans=[""Christmas"",""Christmas Eve"",""Christmas Eve Eve"",""Christmas Eve Eve Eve""] +print(ans[25-d])" +p02833,s521934569,Accepted,"n = int(input()) +nbase = n+0 +if n % 2 == 1: + ans = 0 +else: + ns = 0 + while n != 0: + n = n//5 + ns += 1 + + nsa = ns - 1 + ans = 0 + for i in range(nsa,0,-1): + o = nbase//(5**i) + ans += o//2 + +print(ans)" +p03327,s530313890,Accepted,"n = int(input()) +if n > 999: + print('ABD') +else: + print('ABC')" +p03817,s344314152,Wrong Answer,"x = int(input()) +d, m = divmod(x, 11) +ans = d * 2 +if m > 5: + ans += 2 +elif m > 0: + ans += 1 +print(ans)" +p03556,s412254546,Wrong Answer,"n = int(input()) +for i in range(n): + if(i**2>n): + print((i-1)**2) + quit()" +p03721,s465318649,Wrong Answer,"#!/usr/bin/env python3 + +def main(): + n, k = map(int, input().split()) + arrdict = {} + for i in range(n): + a, b = map(int, input().split()) + if a in arrdict: + arrdict[a] = arrdict[a] + b + else: + arrdict[a] = b + + for key, v in arrdict.items(): + k -= v + if k <= 0: + ans = key + break + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02603,s439432852,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +start = [[0, 1000], [0, 1000]] +#0: all stack, 1: all money +max_index = A.index(max(A)) + +ans = 0 +for i in range(N): + if i == max_index: + ans = start[0][0] * A[i] + start[0][1] + else: + money = max([ + start[0][0] * A[i] + start[0][1], start[1][0] * A[i] + start[1][1] + ]) + start = [[money//A[i], money - (money//A[i])*A[i] ], [0, money]] +print(ans)" +p03730,s522813039,Accepted,"a, b, c = map(int, input().split()) + +ans = 'NO' +if a < b and c%a == 0: + ans = 'YES' +else: + for i in range(1, 1000): + if (b*i + c)%a == 0: + ans = 'YES' + break + +print(ans)" +p02995,s293373119,Accepted,"a,b,c,d = map(int,input().split()) + +def gcd(a,b): + while b: + a,b = b,a%b + return a + +def f(e): + return e - (e//c + e//d - e//(c*d//gcd(c,d))) + +print(f(b)-f(a-1)) +" +p02923,s743012344,Wrong Answer,"n = int(input()) +heights = list(map(int, input().split())) + +ans_list = [0]*n +for i in range(n): + if i == 0: + continue + else: + if heights[i] <= heights[i-1]: + ans_list[i] = ans_list[i-1] + else: + ans_list[i] = 0 + +ans_list.sort() +ans = ans_list[-1] +print(ans) + " +p02577,s661774252,Accepted,"total = 0 +N = input() +for c in N: + total += int(c) +if total % 9 == 0: + print(""Yes"") +else: + print(""No"")" +p02706,s772850971,Wrong Answer,"N, M = map(int, input().split()) +A = list(map(int, input().split())) + +ASOBU = sum(A) - N + +if ASOBU >= 0: + print(ASOBU) +else: + print('-1')" +p03719,s564798960,Accepted,"num_array = list(map(int, input().split())) +if num_array[0] <= num_array[2] and num_array[2] <= num_array[1]: + print(""Yes"") +else: + print(""No"")" +p03556,s004800503,Accepted,"n = int(input()) +res = 0 +for i in range(100000): + if i * i <= n: + res = i * i + else: + break + +print(res) +" +p02861,s140855129,Wrong Answer,"import math +n=int(input()) +l=[list(map(int,input().split())) for _ in range(n)] +sum_hen=0 +for i in range(n-1): + for j in range(i+1,n): + x_i,y_i=l[i][0],l[i][1] + x_j,y_j=l[j][0],l[j][1] + sum_hen+=((x_i-x_j)**2+(y_i-y_j)**2)**0.5 +print(sum_hen*2/(n*(n-1)))" +p03338,s428520297,Accepted,"import math +import string + + +def readints(): + return list(map(int, input().split())) + + +def nCr(n, r): + return math.factorial(n)//math.factorial(n-r)*math.factorial(r) + + +n = int(input()) +s = input() + +a = [] + +for i in range(n+1): + a.append(len(set(s[:i]) & set(s[i:]))) +print(max(a)) +" +p02694,s457087465,Wrong Answer,"import math +wanted = int(input()) +year = 0 +if wanted >= 101 and wanted <= 1000000000000000000: + year = math.log(wanted/100) / math.log(1.01) + print(year) +else: + print() + +" +p03407,s541675388,Accepted,"a, b, c = map(int, input().split()) +if a + b >= c: + print('Yes') +else: + print('No')" +p03592,s033007922,Accepted,"def resolve(): + n, m, k = map(int, input().split()) + for x in range(n + 1): + for y in range(m + 1): + met = y * (n - x) + x * (m - y) + if met == k: + print('Yes') + return + + print('No') +resolve()" +p02848,s954896204,Wrong Answer,"import sys +input=sys.stdin.readline +n=int(input()) +L=input() +F=[] +for i in range(len(L)): + A=ord(L[i])+n + if A>=91: + A=A-91+65 + F.append(chr(A)) +print("""".join(F)) + +" +p04045,s028788964,Accepted,"N ,K = map(int,input().split()) +D = [int(n) for n in input().split()] + +flag = False + +for i in range(N,100000): + N = i + while i > 0: + flag = True + if i%10 in D: + flag = False + break + else: + i //=10 + + if flag == True: + print(N) + break +" +p03386,s928508234,Accepted,"A, B, K = map(int, input().split()) +if A+K-1>=B-K+1: + print(*list(range(A,B+1)),sep=""\n"") +else: + print(*(list(range(A,A+K))+list(range(B-K+1,B+1))),sep=""\n"")" +p02791,s605541356,Wrong Answer,"N=int(input()) +data = list(map(int, input().split())) +ans=0 +min=data[0] +if N==1: + ans=1 +elif N>1: + for i in range(1,N): + minmin=data[0] + if data[i]<=minmin: + minmin=data[i] + if minmin<=data[i]: + ans+=1 + continue + if minmin<=data[i]: + ans+=1 + +print(ans)" +p03069,s860195403,Accepted,"n = int(input()) +s = input() +rw = s.count(""."") +lb = 0 +M = rw+lb +for i in range(n): + if s[i] ==""#"": + lb += 1 + else: + rw -= 1 + M = min(M,rw+lb) +print(M)" +p02970,s183632527,Accepted,"import sys +input = sys.stdin.readline +import math +import collections +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) + +n,d=MI() +ans=math.ceil(n/(2*d+1)) +print(ans)" +p03760,s188047741,Wrong Answer,"print(*[o + e for o, e in zip(input(), input())], sep='', end='')" +p02705,s510581013,Wrong Answer,"import math +a = int(input()) +print(math.pi * a *a) +" +p02922,s195358696,Wrong Answer,"A,B=map(int,input().split()) +count = 0 +tap = 1 +for i in range(30): + tap += A-1 + count += 1 + if tap >= B: + break +print(count)" +p02772,s605102968,Wrong Answer,"input() +A=list(map(int,input().split())) +print(""APPROVED"" if all(a%2==0 or a%3==0 or a%5==0 for a in A) else ""DENIED"")" +p02836,s202592356,Accepted,"s = input() +s_r = s[::-1] +count = 0 +for i in range(len(s)): + if s[i] != s_r[i]: + count += 1 +print(count//2)" +p03637,s116277058,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +four = 0 +two = 0 +other = 0 +for i in a: + if i % 4 == 0: + four += 1 + elif i % 2 == 0: + two += 1 + else: + other += 1 + +ans = 'No' +other += two % 2 +if four + 1 >= other: + ans = 'Yes' + +print(ans)" +p03986,s536050113,Accepted,"x = input() +ans = len(x) +cs = 0 +T = False + +for i in x: + if i == 'S': + if T: + T = False + cs += 1 + else: + if not T: + T = True + if cs > 0: + cs -= 1 + ans -= 2 +print(ans)" +p02947,s801472088,Accepted,"import collections + +ss = [] + + +N = int(input()) +for i in range(N): + s = str(sorted(input())) + ss.append(s) + +c = collections.Counter(ss) +ans = 0 + +for v in c.values(): + ans += v * (v - 1) // 2 +print(ans) +" +p03944,s287754008,Accepted,"w, h, n = map(int,input().split()) + +xl, xr = 0, w +yl, yu = 0, h +for i in range(n): + x, y, a = map(int,input().split()) + if a == 1: + xl = max(xl, x) + elif a == 2: + xr = min(xr, x) + elif a == 3: + yl = max(yl, y) + else: + yu = min(yu, y) + +print((xr-xl)*(yu-yl)) if xl < xr and yl < yu else print(0)" +p03385,s173797412,Wrong Answer,"s=input() +if sorted(s)==""abc"": + print(""Yes"") +else: + print(""No"")" +p03545,s591188491,Wrong Answer,"abcd=str(input()) +for i in range(2**4): + list=[int(abcd[0])] + symbol=[] + for j in range(1,4): + if (i>>j)&1==True: + list.append(int(abcd[j])) + symbol.append('+') + else: + list.append(int(abcd[j])*(-1)) + symbol.append('-') + if sum(list)==7: + print(abcd[0],symbol[0],abcd[1],symbol[1],abcd[2],symbol[2],abcd[3],""=7"") + break +" +p02786,s794999419,Accepted,"from functools import reduce +from fractions import gcd +import math +import bisect +import itertools +import sys +input = sys.stdin.readline +INF = float(""inf"") + + +# 処理内容 +def main(): + H = int(input()) + ans = 0 + i = 0 + while(H >= 1): + ans += 2**i + H /= 2 + i += 1 + + print(ans) + + +if __name__ == '__main__': + main()" +p02785,s928880219,Accepted,"n, k = map(int, input().split()) +h = list(map(int, input().split())) +h.sort() +print(sum(h[0:n-k]) if n > k else 0) +" +p03030,s155313647,Accepted,"n = int(input()) + +a =[] +for i in range(n): + s, p = input().split() + p = int(p) + a.append([s, -p, i + 1]) + +a.sort() +for s, p, i in a: + print(i)" +p03861,s026800207,Accepted,"a, b, x = map(int, input().split()) +print(b//x - (a-1)//x)" +p02918,s587558688,Accepted,"n, k = map(int, input().split()) +s = input() +sep = sum(a != b for a, b in zip(s, s[1:])) +print(n - max(0, sep - 2 * k) - 1)" +p03723,s352732045,Accepted,"A, B, C = map(int, input().split()) + + +def F(a, b, c): + if a % 2 == 1 or b % 2 == 1 or c % 2 == 1: + return 0 + if a == b == c: + return -1 + return F((a + b) // 2, (b + c) // 2, (c + a) // 2) + 1 + + +print(F(A, B, C)) + +" +p02556,s108644086,Accepted,"N=int(input()) + + +Sum=[] +Sub=[] +for _ in range(N): + x,y = map(int,input().split()) + Sum.append(x+y) + Sub.append(x-y) + +Sum = sorted(Sum) +Sub=sorted(Sub) +ans=max(abs(Sum[-1]-Sum[0]),abs(Sub[-1]-Sub[0])) +print(ans) +" +p03067,s352420869,Wrong Answer,"a,b,c = map(int,input().split()) +print (""Yes"") if a < c < b else print (""No"") +" +p02700,s218618607,Wrong Answer,"#スペース区切りの整数の入力 +tairyoku_A, kougeki_B,tairyoku_C,kougeki_D = map(int, input().split()) + +one = int(tairyoku_A /kougeki_D) +two = int(tairyoku_C /kougeki_B) + + +if(one>two): + print(""Yes"") +elif(one"": + ans[len(S)-i-1] = max(ans[len(S)-i-1], ans[len(S)-i]+1) + +print(sum(ans))" +p02836,s872359538,Accepted,"import math +import heapq +import sys +from collections import Counter +import datetime +from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN + +#N,K=map(int, input().split()) #複数数値入力 「A B」みたいなスペース空いた入力のとき +#x=list(map(int, input().split())) #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき +#s = [input() for i in range(3)] + +S=input() +cnt=0 +for i in range(len(S)//2): + if S[i]!=S[-1-i]: + cnt+=1 + +print(cnt)" +p03543,s094616983,Accepted,"N = str(input()) + +if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: + result = ""Yes"" +else: + result = ""No"" + +print(result) +" +p02972,s356577951,Wrong Answer,"n = int(input()) +b = list(map(int, input().split())) +a = [0] * (n + 1) +for i in range(1, n + 1): + a[i] = b[i - 1] + + +ball = [0] * (n + 1) +ans = [] + +for i in range(n, 0, -1): + s = 0 + j = i * 2 + while j < n: + s += ball[j] + j += i + + if s % 2 != a[i]: + ball[i] += 1 + ans.append(i) + +print(len(ans)) +for e in ans: + print(e) +" +p02717,s430614276,Wrong Answer,"d,e,f = map(int,input().split()) +print(f,e,d)" +p02657,s219828124,Wrong Answer,"a=4 +b=8 + +print(a*b) +" +p03494,s692385238,Accepted,"N=int(input()) +A=list(map(int,input().split())) +count=0 +while all( [a%2==0 for a in A]): + A=[a/2 for a in A] + count+=1 + +print(count)" +p03838,s207447465,Accepted,"x, y = list(map(int, input().split())) + +dif = abs(abs(x)-abs(y)) + +if (x >= 0 and y > 0) or (x < 0 and y <= 0): + if x < y: + print(dif) + else: + print(dif + 2) +else: + print(dif + 1)" +p02664,s636654467,Wrong Answer,"T=str(input()) +cnt=0 +count=len(T) +for i in T: + if i=='P': + cnt=1 + print('P',end='') + + elif i=='D': + cnt=0 + print('D', end='') + else: + if count == i: + print('D') + + elif cnt==1: + cnt=0 + print('D', end='') + else: + cnt=1 + print('P', end='') + +" +p02584,s999803454,Accepted,"x,k,d = map(int,input().split()) +c = abs(x)//d +if c < k: + if (k-c) % 2 == 0: + print(abs(x)%d) + else: + print(min(abs(abs(x)%d+d),abs(abs(x)%d-d))) +else: + print(abs(x)-d*k)" +p03659,s353105475,Wrong Answer,"import numpy as np +import itertools +n = int(input()) +a = list(map(int, input().split())) + +i = list(itertools.accumulate(a)) + +idx = np.abs(np.asarray(i) - sum(a) / 2).argmin() +if n == 2: + print(abs(a[0] - a[1])) + exit() +print(abs(i[idx] - (sum(a) - i[idx])))" +p02664,s307197756,Accepted,"#デフォルト +import itertools +from collections import defaultdict +import collections +import math +import sys +sys.setrecursionlimit(200000) +mod = 1000000007 + +t = list(input()) + +for i in range(len(t)): + if (t[i] == ""?""): + print(""D"",end="""") + else: + print(t[i],end="""")" +p04043,s559653475,Accepted,"a=list(map(int,input().split())) + +five=a.count(5) +seven=a.count(7) + +if five==2 and seven==1: + print('YES') +else: + print('NO') + +" +p02681,s315535390,Accepted,"s = input() +t = input() +print('Yes' if s == t[:-1] else 'No')" +p02843,s439937742,Accepted,"X = int(input()) + +q,mod = divmod(X,100) +if 5*q=30 else ""No"") +" +p03695,s301795016,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +flag = [0]*9 +t = 0 +x = 0 +y = 400 +while y <= 3200: + for i in a: + if x <= i < y: flag[t] = 1 + t += 1 + x += 400 + y += 400 +else: + for i in a: + if 3200 <= i: flag[8] += 1 + +if sum(flag[:8]) == 0: + print(1,flag[8]) + exit() + +total = sum(flag) +print(total - flag[8], total)" +p03407,s767169636,Accepted,"a,b,c=map(int,input().split()) +print(""Yes"" if (a+b>=c) else ""No"")" +p03565,s936072732,Accepted,"s=input() +T=input() +ans=[] +for i in range(len(s)-len(T)+1): + flag=True + S=s[:i]+T+s[i+len(T):] + for j in range(len(T)): + if(s[i+j]!=""?"" and s[i+j]!=T[j]): + flag=False + if(flag==True): + S.replace(""?"",""a"") + #print(S) + ans.append(S.replace(""?"",""a"")) + +if(ans): + ans.sort() + print(ans[0]) +else: + print(""UNRESTORABLE"")" +p02719,s648937447,Wrong Answer,"# -*- coding: utf-8 -*- +import math + +N,K = list(map(int,input().split())) + +#A = max(N,K) +#B = min(N,K) + +#sre = (1/(4*M))*sum(A) + +def hoge(K): + init_i = math.floor(N/K) + + p1 = abs(N - (init_i-1) * K) + p = abs(N - init_i * K) + m = abs((init_i+1) * K - N) + + return min(p1,p,m) + +ks = [] +tmp_K = K + +while(1): + tmp_K = hoge(tmp_K) + ks.append(tmp_K) + if tmp_K == 0 or tmp_K in ks: + break + +print(min(ks))" +p02607,s485459855,Accepted,"n=int(input()) +a=list(map(int,input().split())) +ans=0 +for i in range(0,n,2): + if a[i]%2==1: + ans+=1 +print(ans)" +p03067,s435259274,Wrong Answer,"A, B, C = map(int,input().split()) + +print('Yes' if A<=C<=B else 'No') +" +p03105,s404666613,Wrong Answer," +a,b,c = map(int,input().split()) + +if (b//a) <= c: + print(c) +else: + print(b//a) +" +p03285,s640683364,Wrong Answer,"n = int(input()) +ans = 0 +for i in range(30): + for j in range(20): + if 4*i + 7*j == n : + ans +=1 +print(ans)" +p02881,s537819197,Wrong Answer,"N = int(input()) +for i in range(1, int(N**0.5)+1, -1): + if N % i == 0: + print(i + (N // i) - 2) + break +" +p03000,s339381091,Accepted,"n, x = map(int, input().split()) +l = list(map(int, input().split())) +d = 0 +p = 1 +for i in range(n): + d += l[i] + if d <= x: + p += 1 +print(p)" +p02706,s905331901,Wrong Answer,"d, n = list(map(int, input().split())) +work = list(map(int, input().split())) +sumwork = sum(work) +ans = d - sumwork +print(ans)" +p02583,s600803425,Accepted,"N = int(input()) +L = list(map(int, input().split())) +ans = 0 +for i in range(N-2): + for j in range(i+1, N-1): + for k in range(j+1, N): + x, y, z = L[i], L[j], L[k] + if x != y and x != z and y != z: + if max(x, y, z) < x + y + z - max(x, y, z): + ans += 1 +print(ans)" +p03623,s200659472,Accepted,"x, a, b = map(int,input().split()) + +if abs(a-x) > abs(b-x): + print(""B"") +else: + print(""A"")" +p02823,s772469449,Accepted,"from sys import stdin +def main(): + #入力 + readline=stdin.readline + N,A,B=map(int,readline().split()) + if (B-A)%2==0: + print((B-A)//2) + else: + print(min(N-B,A-1)+1+(B-A-1)//2) + +if __name__==""__main__"": + main()" +p03779,s502957674,Accepted,"x=int(input()) +for i in range(1,x+1): + if x<=(i*(i+1))//2: + print(i) + break" +p03262,s198522121,Accepted,"N,X=map(int,input().split()) +x=input().split() +x_s=[int(a) for a in x] + +x_s.append(X) + +list_s=sorted(x_s) + +numbers=[] + +for n in range(1,N+1): + number=list_s[n]-list_s[n-1] + numbers.append(number) + +def gcd(a, b): + while b: + a, b = b, a % b + return a + +number=numbers[0] +for n in range(len(numbers)): + number=gcd(number,numbers[n]) + +print(number) +" +p03659,s891163832,Accepted,"n = int(input()) +a = list(map(int,input().split())) +s1 = sum(a) - a[0] +s2 = a[0] +m = abs(s1-s2) +for i in range(1,n-1): + s1 -= a[i] + s2 += a[i] + m = min(m,abs(s1-s2)) +print(m)" +p03073,s013633689,Wrong Answer,"S = input() +C = ['1', '0'] +c = S[0] +cnt = 0 +for i in range(1, len(S) - 1): + if c == S[i]: + c = C[ord(c) - ord('0')] + cnt += 1 + else: + c = S[i] +print(cnt) +" +p02729,s663220068,Accepted,"N,M = map(int,input().split()) + +answer1 = N * (N - 1) / 2 +answer2 = M * (M - 1) / 2 + +print(int(answer1 + answer2)) +" +p03759,s289523853,Accepted,"a,b,c = map(int, input().split()) +print('YES' if b-a==c-b else 'NO')" +p02879,s453408643,Accepted,"a,b=map(int,input().split()) +if max(a,b)<10:print(a*b) +else:print(-1)" +p02584,s437632780,Wrong Answer,"x, k, d = map(int, input().split()) +ans = pow(10, 16) +if x // d + 1> k: + ans = abs(x - k*d) +else: + ans = min(abs(x % d), d - abs(x % d)) + +print(ans)" +p02952,s073920837,Accepted,"import math +n = int(input()) +cnt = 0 +for i in range(1, n + 1): + if math.floor(math.log10(i) + 1) % 2: + cnt += 1 +print(cnt)" +p03131,s443396961,Accepted,"k, a, b = map(int, input().split()) +ans = 0 +if b - a <= 1: # 叩き続けたほうがいい + ans = k + 1 +else: + n = k - a + 1 #a個 + if n % 2 == 1: + ans = a + 1 + (b-a)*(n//2) #最後交換しない + else: + ans = a + (b-a)*(n//2) +print(ans)" +p02987,s119043478,Accepted,"s = sorted(input()) + +if len(set(s)) == 2 and s[0] == s[1] and s[2] == s[3]: + print('Yes') +else: + print('No')" +p02712,s017246162,Accepted,"N = int(input().strip()) +def hoge(N, r): # 1-Nのrの倍数の和 + R = N-(N%r) # N以下の一番大きいrの倍数を知りたい + n = R//r + return n*(n+1)//2*r + +ans = hoge(N,1) - hoge(N,3) - hoge(N,5) + hoge(N,15) +print(ans) +" +p02814,s037324618,Accepted,"import sys +from fractions import gcd +import math + +N,M = map(int, input().split()) +AA = list(map(int, input().split())) + +A = [] +for a in AA: + A.append(a//2) + +def f(x): + c = 0 + while x%2 == 0: + c += 1 + x //= 2 + return c + +a0 = f(A[0]) +for a in A: + if f(a) != a0: + print(0) + sys.exit() + +def lcm(x,y): + return x*y//gcd(x,y) + +l = A[0] +for a in A: + l = lcm(l,a) + +ans = M//l +print((ans+1)//2)" +p03796,s022053105,Accepted,"import math +n = int(input()) +print(math.factorial(n) % (10 ** 9 + 7))" +p03250,s157244354,Wrong Answer,"a,b,c = map(int, input().split()) +print(max(10*a+b+c, a+10*b+c))" +p03986,s805576937,Accepted,"X = input() +stack = [] +for e in X: + if e == 'S': + stack.append(e) + else: + if len(stack) == 0 or stack[-1] == 'T': + stack.append(e) + else: + stack.pop() +print(len(stack)) +" +p03475,s595965514,Accepted,"from math import ceil +n = int(input()) +lst = [list(map(int,input().split())) for _ in range(n-1)] +for i in range(n-1): + ans = lst[i][0]+lst[i][1] + for j in range(i+1, n-1): + k = max(0, ceil((ans-lst[j][1])/lst[j][2])) + ans = lst[j][1]+k*lst[j][2]+lst[j][0] + print(ans) +print(0)" +p02995,s737602654,Accepted,"import math +a,b,c,d=list(map(int,input().split())) +a-=1 +def calculation(x,c,d): + x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d))) + return x + +print(calculation(b,c,d)-calculation(a,c,d))" +p03377,s413172634,Accepted,"A,B,X=map(int,input().split()) + +if X>=A and X<=A+B: + print(""YES"") +else: + print(""NO"")" +p03220,s037510859,Wrong Answer,"n=int(input()) +t,a=map(int,input().split()) +h=list(map(int,input().split())) +ans=0 +dist=100 +for i in range(n): + d=abs(t-h[i]*0.006-a) + if d<=dist: + dist=d + ans=i+1 +print(ans)" +p03043,s806510736,Wrong Answer,"n,k=map(int,input().split()) +kakuritu=0 +for i in range(1,n+1): + if i>=k: + kakuritu+=1 + else: + kaisu=k//i + count=0 + while kaisu>1: + kaisu=kaisu/2 + count+=1 + kakuritu+=0.5**count +print(kakuritu/n) + +" +p02660,s872768877,Accepted,"from math import sqrt +n = int(input()) +ans = 0 +for i in range(2, 1 + int(sqrt(n))): + c = 0 + while n % i == 0: + n //= i + c += 1 + ans += int((-1 + sqrt(1 + 8 * c)) / 2) +if n != 1: + ans += 1 +print(ans) +" +p04019,s571442500,Wrong Answer,"l = list(input()) +n = l.count('N') +w = l.count('W') +s = l.count('S') +e = l.count('E') +if (n + s) % 2 == 0 and (w + e) % 2 == 0: + print('Yes') +else: + print('No')" +p02787,s976718013,Wrong Answer,"H, N = input().split() +H = int(H) +N = int(N) +a = [] +b = [] +con = 1 +while con <= N: + A, B = map(int, input().split()) + a.append(A) + b.append(B) + con += 1 +print(sum(b)) + +" +p03407,s316579466,Wrong Answer,"a, b, c = map(int, input().split()) +if a+b > c: + print('Yes') +else: + print('No')" +p02640,s814080021,Wrong Answer,"import sys +def main(): + x, y = map(int, input().split()) + + for i in range(0, 3): + for j in range(0, 3-i): + res = i * 2 + j * 4 + if y == res: + print('Yes') + sys.exit() + + print('No') + +if __name__ == '__main__': + main() + " +p03309,s229817277,Accepted,"import statistics +def resolve(): + n = int(input()) + a = list(map(int, input().split())) + seq = [] + for i in range(1, n+1): + seq.append(i-a[i-1]) + seq = sorted(seq) + m = int(statistics.median(seq)) + ans = 0 + for i in seq: + ans += abs(i-m) + print(ans) +resolve()" +p02916,s125737863,Accepted,"num = int(input()) +index = list(map(int, input().split())) +point = list(map(int, input().split())) +add = list(map(int, input().split())) + + +total = 0 +for i in range(num): + total += point[index[i]-1] + +for j in range(num-1): + if index[j+1] == index[j]+ 1: + total += add[index[j]-1] + +print(total)" +p02971,s256798153,Accepted,"N = int(input()) +A = [] + +for i in range(N): + A.append(int(input())) + +B = A +maxim = max(A) +max_i = A.index(maxim) +B.remove(maxim) +second = max(B) + +for i in range(N): + if (i == max_i): + print(second) + else: + print(maxim)" +p02783,s783949011,Accepted,"h, a = map(int, input().split()) +i = 0 +while h > 0: + h -= a + i += 1 + +print(i)" +p03469,s225123077,Wrong Answer,"s = input() +s.replace(""2017"",""2018"") +print(s)" +p02729,s246034102,Accepted,"n,m = map(int,input().split()) + +from operator import mul +from functools import reduce + +def bb(n,r): + r = min(n-r,r) + if r == 0: return 1 + over = reduce(mul, range(n, n - r, -1)) + under = reduce(mul, range(1,r + 1)) + return over // under +if m==1 and n==1: + print(0) + exit() + +if m>1 and n>1: + print(bb(n,2)+bb(m,2)) +elif m>1: + print(bb(m,2)) +else: + print(bb(n,2)) + +" +p03035,s324214116,Wrong Answer,"A,B=map(int,input().split()) +if (A>=13): + print(B) +elif(12>=A>=6): + print(B/2) +else: + print(0)" +p02766,s137777592,Accepted,"n,k=map(int,input().split()) + +def Base_10_to_n(X, n): + if (int(X/n)): + return Base_10_to_n(int(X/n), n)+str(X%n) + return str(X%n) + +x10=n +x2=Base_10_to_n(x10, k) +print(len(x2))" +p03838,s301328848,Accepted,"def resolve(): + ''' + code here + ''' + x, y = [int(item) for item in input().split()] + res = 0 + + if x < 0 and abs(y) - abs(x) >= 0: + res += 1 + elif x > 0 and abs(y) - abs(x) <= 0: + res += 1 + + res += abs(abs(x) - abs(y)) + + + if y > 0 and abs(y) - abs(x) < 0: + res += 1 + elif y < 0 and abs(y) - abs(x) > 0: + res += 1 + + print(res) + +if __name__ == ""__main__"": + resolve() +" +p03250,s952755649,Accepted,"a,b,c = map(int,(input().split())) +num = [] +num.append(a) +num.append(b) +num.append(c) +num.sort(reverse=True) +print(num[0]*10+num[1]+num[2])" +p02660,s049461451,Accepted,"N = int(input()) +primetable = [] + +i = 2 +while i* i <= N: + if(N % i == 0): + j = 0 + while N % i == 0: + N/= i + j+= 1 + primetable.append((i, j)) + i+= 1 +if(N != 1): + primetable.append((int(N), 1)) + +Ans = 0 +for i in primetable: + ans = 0 + n = 1 + while 1/ 2* n* (n+ 1)<= i[1]: + ans = n + n+= 1 + Ans+= ans + +print(Ans)" +p03860,s199295652,Wrong Answer,"def hi(name): + print(""Hello,"", name) + +def f(x): + return x * x + +hi(""Alice"") +hi(""Bob"") + +print( f(2) ) +print( f(8) )" +p03745,s266774223,Accepted,"def solve(): + ans = 1 + N = int(input()) + A = list(map(int, input().split())) + ud = 0 + for i in range(N-1): + a = A[i+1]-A[i] + if a*ud<0: + ans += 1 + ud = 0 + elif ud==0: + ud = a + return ans +print(solve())" +p02742,s263868541,Wrong Answer,"H, W = map(int, input().split()) +if H % 2 == 0 or W % 2 == 0: + print(W * H // 2) +else: + total = H * (W//2) + H//2 + 1 + print(total)" +p02723,s030522044,Accepted,"S = input() +ret = 'No' +if S[2] == S[3]: + if S[4] == S[5]: + ret = 'Yes' +print(ret)" +p04029,s509980712,Accepted,"import sys +import itertools +readline = sys.stdin.buffer.readline + +n = int(readline()) +ans = 0 +for i in range(1,n+1): + ans += i +print(ans)" +p02843,s848906009,Accepted,"n = int(input()) +if n <= 99: + print(0) + exit() +if 100 <= n <= 105: + print(1) + exit() +dp = [True] + [False] * n +for i in range(100, n + 1): + if dp[i - 100] or dp[i - 101] or dp[i - 102] or dp[i - 103] or dp[i - 104] or dp[i - 105]: + dp[i] = True +print([0, 1][dp[n]])" +p03835,s395940333,Accepted,"k, s = map(int,input().split(' ')) +count = 0 +for x in range(k+1): + for y in range(k+1): + z = s - (x+y) + if 0 <= z and z <= k: + count += 1 + +print(count)" +p02792,s832701660,Wrong Answer,"n=int(input()) +count=[[0]*9 for _ in range(9)] +for i in range(1,n+1): + if i%10>0: + i=str(i) + if int(i[::-1])<=n: + x,y=int(i[0])-1,int(i[-1])-1 + count[x][y]+=1 +ans=0 +for i in count: + for j in i: + ans+=j**2 +print(ans)" +p02747,s496435688,Wrong Answer,"import re + +try: + s = input() +except: + print(""No"") + +s = s.replace('hii', '') +print(s) +if ""hii"" in s: + print(""No"") +else: + if ""hi"" in s: + print(""Yes"") + else: print(""No"")" +p02778,s640041659,Accepted,"print(len(input()) * ""x"")" +p02793,s563334070,Wrong Answer,"import fractions + +def lcm(x, y): + return (x * y) // fractions.gcd(x, y) + +n = int(input()) +A = list(map(int, input().split(' '))) +lcm_A = 1 +for a in A: + lcm_A = lcm(lcm_A, a) + +B_sum = 0 +for a in A: + B_sum += lcm_A // a + B_sum %= 100000000 + 7 + +print(B_sum)" +p02775,s547060195,Accepted,"N = list('0'+input()) +l = len(N) +ans = 0 +i = l-1 +while i > 0: + if int(N[i])>=6 or (int(N[i]) == 5 and int(N[i-1])>=5): + ans+=10-int(N[i]) + i-=1 + while N[i] == '9': + i-=1 + N[i] = str(int(N[i])+1) + else: + ans+=int(N[i]) + i-=1 +ans+=int(N[0]) +print(ans) + " +p02663,s819168855,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) +print(h2*60+m2-h1*60-m1-k)" +p03059,s265792290,Wrong Answer,"A, B, T = map(int, input().split()) + +print( (T+1//A) * B) +" +p03785,s964579917,Accepted,"def main(): + n, c, k, *t = map(int, open(0).read().split()) + t.sort() + u = tuple(t) + + cnt = 1 + p, l = 0, u[0] + k + for v in t: + if v <= l and p < c: + p += 1 + else: + cnt += 1 + p = 1 + l = v + k + print(cnt) + + +if __name__ == '__main__': + main() +" +p03385,s302331169,Wrong Answer,"s=input() +s=sorted(s) +l=['a','b','c'] +if s==l: + print('YES') +else: + print('NO')" +p03633,s217117971,Wrong Answer,"from fractions import gcd + + +def lcm(a, b): + g = gcd(a, b) + return a / g * b + + +n = int(input()) +t = [int(input()) for _ in range(n)] +ans = t[0] +for i in range(1, n): + ans = lcm(ans, t[i]) +print(int(ans)) +" +p02778,s556615256,Wrong Answer,"a = input() +num = len(a) +print('*'*num)" +p02646,s760138737,Accepted," +a, v = map(int, input().split()) +b, w = map(int, input().split()) +t = int(input()) + +if a == b: + print('YES') + exit() +if b - a > 0: + if (v - w) * t >= b - a: + print('YES') + exit() + else: + print('NO') + exit() +else: + if (v - w) * t >= a - b: + print('YES') + exit() + else: + print('NO') + exit() + +print('NO')" +p03131,s445591653,Wrong Answer,"K,A,B = map(int,input().split()) +if B-A-2 <= 0: + print(K+1) + exit() + +if K-1 <= A: + print(K+1) + exit() + +K -= (A-1) +num = K//2 +nokori = K%2 +#print(K,num,nokori) +ans = A+num*(B-A)+nokori +print(ans)" +p02622,s954782001,Wrong Answer,"def MinorChange(): + + str1 = str(input()) + str2 = str(input()) + + data = [] + + for num in range(len(str1)): + if str1[num] != str2[num]: + data.append(str1[num]) + + print(list(set(data))) + +if __name__ == '__main__': + MinorChange()" +p02601,s295133483,Accepted,"a,b,c=map(int,input().split()) +K=int(input()) + +# B > A +# C > B +import sys +for i in range(K+1): + A=a + B=b*(2**i) + C=c*(2**(K-i)) + #print(i,K-i,A,B,C) + if B>A and C>B: + print('Yes') + sys.exit() +else: + print('No')" +p02843,s450136978,Accepted,"N = int(input()) +x = N // 100 +y = N % 100 +if y <= 5 * x: + print(1) +else: + print(0)" +p02681,s833083687,Accepted,"s = input() +t = input() +print(""Yes"" if s == t[:-1] else ""No"")" +p02918,s397809481,Accepted,"# https://atcoder.jp/contests/abc140/tasks/abc140_d +n, k = map(int, input().split()) + +s = input() +block = 0 +start = 0 +seg = [] +block = 0 +for i in range(n - 1): + if s[i] == s[i + 1]: + block += 1 + +ans = min(n - 1, block + k * 2) +print(ans) +" +p03645,s061495724,Accepted,"import sys +input = sys.stdin.readline + +n, m = map(int, input().split()) +ships = [[] for _ in range(n)] +for i in range(m): + a, b = map(int, input().split()) + ships[a-1].append(b-1) + ships[b-1].append(a-1) + +if set(ships[0]) & set(ships[-1]) == set(): + print('IMPOSSIBLE') +else: + print('POSSIBLE') +" +p02814,s269084064,Accepted,"from fractions import gcd +n,m=map(int,input().split()) +a=list(map(int,input().split())) +wa=[] +for i in range(n): + p=a[i] + f=0 + while p%2==0: + p=p//2 + f+=1 + wa.append(f) +if max(wa)!=min(wa): + print(0) + exit() +ans = a[0] +for i in range(1, n): + ans = ans * a[i] // gcd(ans, a[i]) +g=ans//2 +kai=m//g +kai=-(-kai//2) +print(kai) +" +p02691,s152400472,Wrong Answer,"n = int(input()) +H = list(map(int, input().split())) +H = [0] + H +count = 0 + +for a in range(1, n+1): + for b in range(1, n+1): + if a >= b : + continue + if abs(a - b) == H[a] + H[b]: + print(a, b, a-b) + count+=1 +print(count)" +p03220,s386716946,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def main(): + N = int(input()) + T, A = map(int, input().split()) + H = list(map(int, input().split())) + result = [abs((T - h * 0.006) - A) for h in H] + print(result.index(min(result)) + 1) + + +if __name__ == ""__main__"": + main() +" +p02712,s192126198,Accepted,"N = int(input()) +A = [] +for i in range(N+1): + if i % 3 != 0 and i % 5 != 0: + A.append(i) +print(sum(A)) +" +p03617,s059762979,Wrong Answer,"l=list(map(int,input().split())) +NN=int(input()) +ans=10**30 +size=[0.25,0.5,1,2] +for i in range(2**4): + tmp=[] + for j in range(4): + if (i>>j)&1: + tmp.append(j) + ans2=0 + N=NN + while N!=0 and len(tmp)!=0: + v=tmp.pop(-1) + S=size[v] + M=l[v] + v2=N//S + N-=v2*S + ans2+=v2*M + if N==0: + ans=min(ans,ans2) +print(int(ans))" +p02683,s865230022,Wrong Answer,"n, m, x = map(int, input().split()) +ce = list(list(map(int, input().split())) for _ in range(n)) +cst = [] +for i in range(2**n): + kn = [0 for _ in range(m)] + for j in range(n): + if i >> j & 1: + kn = [kn[k] + ce[j][k] for k in range(m)] + if all(kn[i] >= x for i in range(1, m)): + cst.append(kn[0]) +print(-1 if cst == [] else min(cst))" +p02775,s902076835,Accepted,"N=""0""+input() +N=N[::-1] +DP=[[0,0]for i in range(len(N))] + +DP[0][0]=int(N[0]) +DP[0][1]=10-int(N[0]) + +#print(DP) +#print(N) +for i in range(1,len(N)): + DP[i][0]=min(DP[i-1][0]+int(N[i]),DP[i-1][1]+int(N[i])+1) + DP[i][1]=min(DP[i-1][0]+10-int(N[i]),DP[i-1][1]+10-(int(N[i])+1)) +#print(DP) +print(min(DP[-1]))" +p02730,s243500996,Accepted,"def isPalindrome(st): + for i in range(0, int(len(st)/2)): + if st[i] != st[len(st)-i-1]: + return False + return True +st = input() +if isPalindrome(st): + n1 = int((len(st) - 1)/2) + n2 = int((len(st) + 3)/2) - 1 + if isPalindrome(st[0:n1]): + if isPalindrome(st[n2:]): + print(""Yes"") + else: + print(""No"") + else: + print(""No"") +else: + print(""No"")" +p02783,s345925503,Accepted,"h,a=map(int,input().split()) + +print(-(-h//a))" +p03795,s539464952,Accepted,"N = int(input()) +x = 800 * N +y = 200 * (N//15) +print(x - y)" +p03160,s406261865,Accepted,"N = int(input()) +h = list(map(int, input().split())) + +dp_table = [float(""inf"")]*N # 0~N-1まで +dp_table[0] = 0 + +for i in range(N-1): # 0~N-1までだが+1して扱う(1~N) + dp_table[i+1] = min(dp_table[i]+abs(h[i]-h[i+1]), dp_table[i+1]) + if i-1>=0: + dp_table[i+1] = min(dp_table[i-1]+abs(h[i-1]-h[i+1]), dp_table[i+1]) + +print(dp_table[N-1])" +p02780,s023963535,Wrong Answer,"N = list(map(int,input().split())) +n = N[0] +k = N[1] + +X = list(map(int,input().split())) + +#---- +#max_val = 0 +#max_st = 0 +#for i in range(0,n-k): +# tmp_val = X[i] + X[i+1] + X[i+2] +# if tmp_val >= max_val : +# max_st = i +# max_val = tmp_val + +#max_p = (1+X[i])/2 + (1+X[i+1])/2 + (1+X[i+2])/2 +#print(max_p) +#--- + +X.sort() +max_p = 0 +for i in range(1,k+1): + max_p += (1+X[n-i])/2 + +print(max_p)" +p02789,s930897852,Accepted,"n, m = map(int, input().split()) +if n == m: + print(""Yes"") +else: + print(""No"") +" +p03284,s993024806,Accepted,"N, K = map(int,input().split()) +P = N % K +if P != 0: + print(1) +else: + print(0)" +p02832,s353230564,Accepted,"N = int(input()) +lsa = list(map(int,input().split())) +a = 1 +for i in range(N): + if lsa[i] == a: + a += 1 +if a == 1: + ans = -1 +else: + ans = N-(a-1) +print(ans)" +p02645,s210787811,Accepted,"s = input() +print(s[:3])" +p02766,s619800816,Wrong Answer,"n,k=map(int,input().split()) +ans=0 +for i in range(n): + if n>=1: + n=n/k + ans+=1 + else: + print(ans) + break" +p02624,s774983863,Accepted,"n = int(input()) +ans = 0 +for j in range(1, n + 1): + y = n // j + ans += y * (y + 1) * j // 2 +print(ans)" +p02918,s804179442,Wrong Answer,"import sys +input=sys.stdin.readline + +N,K=(int(x) for x in input().rstrip('\n').split()) +L = list(input()) +now = L[0] +change = 0 +for x in L: + if x != now: + change += 1 + now = x +ok = 0 +for i in range(K): + if change == 0: + ok += 1 + print(N-1) + break + elif change==1: + change -= 1 + else: + change -= 2 +if ok == 0: + print(N-1-change)" +p02917,s107735348,Wrong Answer,"N = int(input()) +B = list(map(int,input().split())) + +A = [B[i] for i in range(N-1)] +A = [B[0]] + A + +for i in range(2,N-1): + if max(A[i],A[i+1]) > B[i]: + A[i] = B[i] + +print(sum(A)) +" +p03998,s966514140,Accepted,"n='a' +d={'a':input(),'b':input(),'c':input()} +while True: + t=d[n] + if len(t) ==0: + print(n.upper()) + break + d[n]=d[n][1:] + n=t[0] +" +p02688,s958412963,Accepted,"n, k=map(int,input().split()) + +c=[0]*n + +for i in range(k): + d = int(input()) + a=list(map(int,input().split())) + for i in range(len(a)): + c[a[i]-1]+=1 + +print(c.count(0)) +" +p02596,s106604218,Accepted,"import sys + +k = int(input()) + +ans = [0]*(k+1) +ans[0] = 7 % k + +if ans[0] == 0: + print(1) + +else: + for i in range(k): + ans[i+1] = (ans[i]*10 + 7) % k + + if ans[i+1] == 0: + print(i+2) + sys.exit() + + print(-1)" +p02658,s910754289,Wrong Answer,"from sys import stdin +def I(): return int(stdin.readline().rstrip()) +def LI(): return list(map(int,stdin.readline().rstrip().split())) + +n = I() +a = LI() + +tmp = 1 +for i in range(n): + if pow(10,18)n: + break + if n%i==0: + m=i + l=n//i + + print(m-1+l-1) + +if __name__==""__main__"": + main()" +p03730,s369725550,Wrong Answer," +a, b, c = map(int, input().strip().split()) +a_temp = a + +for i in range(b): + if a_temp % b == c: + print('Yes') + break + a_temp += a +else: + print('No') +" +p04045,s736328705,Accepted,"def is_bad_nums(j: int, d: []) -> bool: + while j: + if j % 10 in d: + return True + j //= 10 + return False + + +def answer(n: int, k: int, d: []) -> int: + for i in range(n, 100000): + if is_bad_nums(i, d): + continue + return i + + +def main(): + n, k = map(int, input().split()) + d = list(map(int, input().split())) + print(answer(n, k, d)) + + +if __name__ == '__main__': + main()" +p02717,s318425205,Accepted,"a = input() +numbers = a.split() +print(""{} {} {}"".format(numbers[2], numbers[0], numbers[1]))" +p03836,s486170051,Accepted,"import sys +# sys.setrecursionlimit(100000) + + +def input(): + return sys.stdin.readline().strip() + + +def input_int(): + return int(input()) + + +def input_int_list(): + return [int(i) for i in input().split()] + + +def main(): + sx, sy, tx, ty = input_int_list() + dx, dy = tx - sx, ty - sy + ans = ""R"" * dx + ""U"" * dy + ""L"" * dx + ""D"" * dy + ""L"" + ""U"" * (dy + 1) + ""R"" * (dx + 1) + ""DR"" + ""D"" * (dy + 1) + ""L"" * (dx + 1) + ""U"" + print(ans) + return + + +if __name__ == ""__main__"": + main() +" +p02818,s716452937,Wrong Answer,"from collections import deque + +A, B, T = map(int,input().split()) + +t = A - T +if t >= 0: + print(t, B) +else: + print(0, B+t)" +p03407,s358620955,Accepted,"a,b,c=map(int,input().split()) +if a+b>=c:print(""Yes"") +else:print(""No"")" +p02987,s521862359,Wrong Answer,"s = str(input()) + +print('Yes') if (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2]) else print('No')" +p03745,s861690748,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +count = 1 +is_up = False +is_down = False +for i in range(1, n): + if a[i] < a[i-1] and is_up: + count += 1 + is_up = False + elif a[i] > a[i-1] and is_down: + count += 1 + is_down = False + elif a[i] < a[i-1]: + is_down = True + elif a[i] > a[i-1]: + is_up = True +print(count) +" +p03448,s553183847,Wrong Answer,"A=int(input()) +B=int(input()) +C=int(input()) +X=int(input()) + +count = 0 +for a in range(min([A,X//500+1])): + for b in range(min([B,(X-500*a)//100+1])): +# print(a*500,b*100) + if (X-500*a-100*b) % 50 == 0 and (X-500*a-100*b) / 50 <= C: + count = count + 1 + +print(count)" +p02594,s188414291,Accepted,"x = int(input()) +if x >= 30: + print(""Yes"") +else: + print(""No"")" +p03555,s786586809,Wrong Answer,"print('Yes' if input() == input()[::-1] else 'No') +" +p02571,s526762475,Wrong Answer,"import re +result_list = [] +S = input() +T = list(input()) +result = 0 +for i in range(len(T)+1): + for j in range(len(T)): + if i+j<=len(T): + temp_word = ''.join(T[j:j+i]) + if temp_word in S: + result = len(T) - len(temp_word) +print(result)" +p02725,s990678420,Accepted,"K, N = map(int, input().split()) +A = [int(x) for x in input().split()] +B = [A[i] - A[i-1] for i in range(1, N)] +B.append(K - A[-1] + A[0]) +ans = sum(B) - max(B) +print(ans)" +p03264,s728245756,Accepted,"K = int(input()) +res = 0 +for i in range(1,K+1): + if i % 2 == 0: + for j in range(i+1,K+1): + if j%2 !=0: + res+=1 + else: + for j in range(i+1,K+1): + if j%2 ==0: + res+=1 + +print(res)" +p03555,s930273851,Accepted,"C = [input() for i in range(2)] + +if C[0][0] == C[1][2] and C[0][1] == C[1][1] and C[0][2] == C[1][0] and C[1][0] == C[0][2] and C[1][1] == C[0][1] and C[1][2] == C[0][0]: + print(""YES"") +else: + print(""NO"")" +p03495,s645690897,Accepted,"from collections import defaultdict + +def main(): + N, K = map(int, input().split()) + A = [a for a in input().split()] + L = defaultdict(int) + + for i in range(N): + L[A[i]] += 1 + + L = sorted(list(L.items()), key= lambda x : x[1], reverse = True) + + cnt = 0 + typ = 0 + + for i in range(len(L)): + typ += 1 + if typ > K: + pair = L[i] + cnt += pair[1] + + print(cnt) +if __name__ == ""__main__"": + main()" +p02726,s506610241,Accepted,"from itertools import combinations +n,x,y = map(int,input().split()) +cnt = [0]*n +for i,j in combinations(range(1,n+1),r=2): + k = min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)) + cnt[k]+=1 +for i in range(1,n): + print(cnt[i]) " +p02947,s473790970,Wrong Answer,"N = int(input()) +sd = {} +cnt = 0 +for i in range(N): + str = ','.join(sorted(input())) + if str in sd: + sd[str] += sd[str] + else: + sd[str] = 1 + +print(sum(sd.values())-len(sd))" +p03241,s393275764,Accepted,"n, m = map(int, input().split()) +div = m//n +INF = 10**18 +ans = -INF +for i in reversed(range(1, div+1)): + if m % i != 0: + continue + if ans < i: + ans = i + break +print(ans) +" +p03061,s263400015,Accepted,"import numpy as np +def gcd(a, b): + if a < b: + a, b = b, a + if b == 0: + return a + else: + return gcd(b, a % b) +n = int(input()) +a = np.array([int(x) for x in input().split()]) +np.sort(a) +l = np.zeros(n + 1) +r = np.zeros(n + 1) +m = np.zeros(n) +for i in range(n): + l[i + 1] = gcd(l[i], a[i]) +for i in reversed(range(n)): + r[i] = gcd(r[i + 1], a[i]) +for i in range(n): + m[i] = gcd(l[i], r[i + 1]) +print(int(np.max(m))) +" +p03720,s575440276,Wrong Answer,"from collections import defaultdict +n, m = map(int, input().split()) +ans = defaultdict(int) +for q in range(m): + ab = list(map(int, input().split())) + if ab[0] != ab[1]: + ans[ab[0]] += 1 + ans[ab[1]] += 1 +for _, v in sorted(ans.items()): + print(v)" +p03815,s073142749,Accepted,"x=int(input()) +a=x//11*2 +b=x%11 +print(a if b==0 else a+1 if b<7 else a+2) +" +p03435,s637584474,Wrong Answer,"if __name__ == ""__main__"": + c1 = list(map(int, input().split())) + c2 = list(map(int, input().split())) + c3 = list(map(int, input().split())) + + if (sum(c1)+sum(c2)+sum(c3))%3 == 0: + print('Yes') + else: + print('No')" +p03000,s717761310,Accepted,"n, x = map(int, input().split()) +L = list(map(int, input().split())) +val = 0 +count = 1 + +for l in L: + val += l + if val <= x: + count += 1 +print(count)" +p02970,s786710715,Accepted,"import math +N,D = map(int, input().split()) +p = 2*D+1 +print(math.ceil(N/p))" +p02639,s605406712,Wrong Answer,"def main(): + input_number = list(map(int, input().split())) + for i in input_number: + if i==0: + print(i) + break + +if __name__=='__main__': + main() +" +p02720,s679618715,Wrong Answer,"from itertools import takewhile + +k = int(input()) + +def is_lunlun(i): + l = [int(x) for x in list(str(i))] + a = [abs(l[j] - l[j+1]) <= 1 for j in range(len(l)-1)] + + return all(a) + +def lunlun(): + j = 1 + while True: + if is_lunlun(j): + yield j + j += 1 + +print(k) +for i,e in enumerate(lunlun()): + if i == k: + print(e) + break" +p02847,s989831277,Accepted,"s=str(input()) +temp=[""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] +for i in range(0,7): + if temp[i]==s: + print(7-i) + break" +p03644,s717030636,Accepted,"n = int(input()) +for i in range(7): + if 2 ** i <= n: + ans = 2 ** i + else: + break +print(ans)" +p03437,s246291578,Accepted,"import sys +def input(): return sys.stdin.readline().rstrip() +def main(): + x,y=map(int,input().split()) + if x==y or x%y==0: + print(-1) + sys.exit() + else: + for i in range(2,10*6): + if x*i % y!=0: + print(x*i) + sys.exit() + +if __name__=='__main__': + main()" +p03639,s644586756,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +cnt1=0 +cnt2=0 +cnt4=0 +for i in range(n): + if a[i]%2==1: + cnt1+=1 + elif format(a[i], 'b')[::-1].find('1')==1: + cnt2+=1 + else: + cnt4+=1 + +if cnt2>=2: + if cnt4>=(n-cnt2)//2: + print('Yes') + else: + print('No') +else: + if cnt4>=n//2: + print('Yes') + else: + print('No') + " +p02946,s460643639,Accepted,"k,x = map(int, input().split()) + +a = max(-1000000,x - (k-1)) +b = min(1000000,x+(k-1)) + +L = [str(i) for i in range(a,b+1)] +print("" "".join(L)) +" +p03161,s127610427,Accepted,"n,k=map(int, input().split()) +h=list(map(int,input().split())) +dp=[0]*(n) +if k+1<=n: + max=k+1 +else: + max=n + +for i in range(1,max): + dp[i]=abs(h[0]-h[i]) + +for i in range(k,n): + li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ] + dp[i]=min(li) + +print(dp[-1])" +p02948,s011757538,Wrong Answer,"N,M = map(int,input().split()) +AB = [list(map(int,input().split())) for _ in range(N)] +AB = sorted(AB, reverse = True) + +ans = 0 +day = M + +for i in range(N): + if AB[i][0] <= day: + ans += AB[i][1] + day -= 1 + else: + continue + if day == 0: + break +print(ans)" +p03137,s942526566,Wrong Answer,"N,M = map(int,input().split()) +X = list(map(int,input().split())) + +ans = 0 + +if N >= M: + pass +else: + X.sort() + dist = [] + + for i in range(1,M): + dist.append(abs(X[i]-X[i-1])) + dist.sort() + ans = sum(dist[:-N+1]) + +print(ans)" +p02994,s009424833,Accepted,"n,l=map(int,input().split()) +a=[l+i-1 for i in range(1,n+1)] +pura=sorted([i for i in a if i>=0]) +mai=sorted([i for i in a if i<0])[::-1] +if pura==[]: + print(sum(mai[1:])) +elif mai==[]: + print(sum(pura[1:])) +elif abs(pura[0])>=abs(mai[0]): + print(sum(pura)+sum(mai[1:])) +else: + print(sum(pura[1:])+sum(mai))" +p03803,s757042424,Accepted,"A,B = map(int,input().split()) +if A == 1: + A += 13 +if B == 1: + B += 13 +if A > B: + print(""Alice"") +elif B > A: + print(""Bob"") +else: + print(""Draw"")" +p02711,s057369918,Wrong Answer,"n=int(input()) +a=n//100 +b=n-a*100 +c=n%10 +if a==7 or b==7 or c==7: + print(""Yes"") +else: + print(""No"")" +p02696,s388303374,Wrong Answer,"a,b,n = map(int, input().split()) +res = 0 +for i in range(1,min(n+1,pow(10,7))): + res = max(res,(a*i)//b - a*(i//b)) +print(res)" +p02987,s821592246,Accepted,"#import math +#import bisect +#import numpy as np +#import itertools +#import copy +#import collections +import sys + +ipti = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + +def main(): + s = input() + ss = list(set(s)) + flag = False + + if len(ss) == 2: + a = s.count(ss[0]) + b = s.count(ss[1]) + if a == b == 2: + flag = True + + if flag: + print('Yes') + else: + print('No') + +if __name__ == '__main__': + main()" +p03206,s938257663,Wrong Answer,"# a, b = map(int, input().split()) +print('Christmas' + ' Eve'*(int(input())-25))" +p03994,s192046580,Accepted,"S = input() +K = int(input()) + +ans = '' +for s in S: + to_a_cost = (26 - (ord(s) - 97)) % 26 + if to_a_cost <= K: + ans += 'a' + K -= to_a_cost + else: + ans += s + + +if K: + K %= 26 + ans = ans[:-1] + chr(97 + (((ord(ans[-1]) - 97) + K) % 26)) + +print(ans) +" +p03013,s099796952,Wrong Answer,"N,M = map(int,input().split()) +a = [1]*(N+1) +Answer = [] +for i in range(M): + a[int(input())-1] = 0 +Answer.append(1*a[0]) +Answer.append(1*a[1]+1*a[0]) +for j in range(2,N): + A = ((Answer[j-1]%(10**9+7)) + (Answer[j-2]%(10**9+7)))*a[j] + Answer.append(A%(10**9+7)) +print(Answer[-1])" +p02756,s761079458,Accepted,"from collections import deque +from sys import stdin +input = stdin.readline + + +def main(): + S = input()[:-1] + Q = int(input()) + + q = deque([S]) + reverse = False + for i in range(Q): + line = input().split() + if line[0] == '1': + reverse = not(reverse) + else: + if reverse ^ (int(line[1])-1): + # S = S + line[2] + q.append(line[2]) + else: + # S = line[2] + S + q.appendleft(line[2]) + + print(''.join(list(reversed(''.join(q)))) if reverse else ''.join(q)) + + +if(__name__ == '__main__'): + main() +" +p03243,s351467665,Accepted,"contests = [i for i in range(100,1000) if i % 111 == 0] +N = int(input()) +for contest in contests: + if contest >= N: + print(contest) + break + else: + continue +" +p02833,s681099673,Accepted," +N = int(input()) + +ans = 0 +count = 1 + +if int(N) % 2 == 1: + print(ans) +else: + while (2* (5 ** count)) <= N: + ans += N // (2* (5 ** count)) + count += 1 + print(ans) +" +p02819,s760066361,Wrong Answer,"X=int(input()) +import sys +for i in range(X,10**5+1): + T=True + for j in range(2,i): + if i%j==0: + T=False + if T==True: + print(i) + break + else: + continue" +p02951,s600292745,Wrong Answer,"a, b, c = map(int, input().split()) +d = a-b +print(c-d)" +p02780,s416518589,Wrong Answer,"nk = list(map(int, input().split())) +p = list(map(int, input().split())) +n = nk[0] +k = nk[1] +maxnum = 0 +for i in range(n-k): + if p[i+k] >= p[i]: + maxnum = i+k + +ans = (sum(p[maxnum-k+1:maxnum+1])+k)/2 +print(ans)" +p02576,s830848382,Wrong Answer,"N, X, T = map(int, input().split()) + +ans = N // X +if N % X != 0: + ans += 1 + +print(ans) +" +p04043,s950618980,Accepted,"a=list(map(int,input().split())) +a.sort() +if a[0]==5 and a[1]==5 and a[2]==7:print(""YES"") +else:print(""NO"")" +p03472,s368923381,Accepted,"from operator import itemgetter + +n, h = map(int, input().split()) +ab = sorted([list(map(int, input().split())) for i in range(n)], key=itemgetter(0), reverse=True) + +max_a = ab[0][0] +ab_s2 = sorted(ab, key=itemgetter(1), reverse=True) +ans = 0 +for a, b in ab_s2: + if b > max_a: + h -= b + ans += 1 + if h <= 0: + break + +if h > 0: + ans += -(-h // max_a) + +print(ans)" +p03699,s977104175,Wrong Answer,"n = int(input()) +s = [int(input()) for _ in range(n)] +s.sort() +ans = sum(s) +i = 0 +while(ans %10 == 0 and i < n): + ans -= s[i] + i+=1 +print(ans) +" +p02817,s987545941,Accepted,"s,t = input().split() +print(t+s)" +p03657,s392289078,Accepted,"import sys +import itertools +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +import math +import collections + + +a,b = map(int,input().split()) +if (a+b)%3 == 0: + print(""Possible"") +elif a%3 == 0: + print(""Possible"") +elif b%3 == 0: + print(""Possible"") +else: + print(""Impossible"")" +p03721,s747388147,Wrong Answer,"N, K = map(int, input().split()) +l = [] +for i in range(N): + a, b = map(int, input().split()) + l.append([a, b]) +c = 0 +ans = 0 +for r in l: + c += r[1] + if c >= K: + ans = r[0] + break +print(ans)" +p02607,s080637448,Accepted,"N = int(input()) +A = list(map(int,input().split())) +ans = 0 +for i in range(0,N,2): + if A[i]%2==1: + ans+=1 + +print(ans) +" +p03623,s391083383,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + x, a, b = map(int, input().split()) + + if abs(x - a) < abs(x - b): + ans = ""A"" + else: + ans = ""B"" + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02570,s956890408,Wrong Answer,"D,T,S = map(int,input().split()) +if D/S <=T : + print(""YES"") +else : + print(""NO"") " +p03494,s428505776,Accepted,"N = int(input()) + +nums = list(map(int,input().split(' '))) + +count = 0 +existOdd = True +while existOdd: + for i in nums: + if i%2!=0: + existOdd = False + break + + if existOdd: + for i in range(N): + nums[i] /= 2 + + count+=1 + +print(count) +" +p03286,s349955157,Accepted,"N = int(input()) + +ans = """" + +if N == 0: + print(0) + exit() + +while N != 0: + a, b = divmod(N, 2) + ans = str(b) + ans + N = -a + +print(ans)" +p02687,s741207752,Wrong Answer,"S = ""ABC"" + +if S == ""ABC"": + print(""ARC"") +else: + print(""ABC"") +" +p02829,s467868350,Wrong Answer,"A = int(input()) +B = int(input()) +for i in range(1,3): + if i != A and i != B: + print(i)" +p03127,s562094227,Accepted,"from functools import reduce +from fractions import gcd +N = int(input()) +A = list(map(int, input().split())) + +print(reduce(gcd, A))" +p03437,s004684989,Wrong Answer,"x,y = map(int,input().split()) +if x!=y: + print(x) +else: + print(-1) +" +p02701,s782592601,Wrong Answer,"N = int(input()) +s = input().split() +print(""\n"") +print(len(set(s)))" +p03251,s420795930,Accepted,"N, M, X, Y = map(int,input().split()) +x = list( map(int,input().split())) +y = list( map(int,input().split())) +if ((XX: + break + #print(i,j,(X-S)/50) + if (X-S)%50==0 and (X-S)/50<=C: + cnt +=1 +print(cnt)" +p02918,s723317147,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 7) + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +# WA + +N, K = map(int, input().split()) +S = list(input()) + +START = S[0] +prev = S[0] +ans = 0 +for i in range(1, N): + s = S[i] + + if prev == s: + ans += 1 + else: + if s == START and K > 0: + ans += 2 if i < N-1 else 1 + K -= 1 + + prev = s + +print(ans) +" +p02607,s182641550,Accepted,"n=int(input()) +a_list = list(map(int,input().split())) + +count = 0 +for i in range(1, n+1): + if i % 2 == 1 and a_list[i-1] % 2 == 1: + count += 1 +print(count)" +p03309,s823307396,Wrong Answer," + +def solve(): + N = int(input()) + As = list(map(int, input().split())) + + Bs = [] + + for i in range(N): + Bs.append(As[i]-i-1) + + Bs.sort() + b = Bs[N//2] + + ans = 0 + + for i in range(N): + ans += Bs[i]-b + + print(ans) + + +# Solve +if __name__ == ""__main__"": + solve() +" +p02843,s157174163,Wrong Answer,"n = int(input()) + +for i in range(1000): + if 100*i<=n and 105*i<=n: + print(""1"") + exit() +print(""0"")" +p02988,s385272112,Accepted,"n = int(input()) +p = list(map(int,input().split())) +count = 0 +for i in range(n-2): + if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]: + count += 1 +print(count)" +p02646,s350539418,Wrong Answer,"a,v = input().split() +b,w = input().split() +t = input() + +a_kyori = int(t) * int(v) + int(a) +b_kyori = int(t) * int(w) + int(b) + +if a_kyori >= b_kyori: + print(""Yes"") +else: + print(""No"")" +p03206,s615713302,Wrong Answer,"D = int(input()) +n = D-25 +eve = "" Eve"" +print(""Christmas""+eve*n)" +p03720,s387618466,Accepted,"n, m = map(int, input().split()) + +ab =[[] for _ in range(n)] + +for _ in range(m): + a, b = map(int, input().split()) + ab[a-1].append(b-1) + ab[b-1].append(a-1) + +for i in ab: + print(len(i))" +p02720,s155222823,Wrong Answer,"K = int(input()) + +t = -1 +for i in range(1,10**6): + for j in range(len(str(i)) - 1): + if abs(int(str(i)[j]) - int(str(i)[j+1])) > 1: + break + else: + t += 1 + #print(i,t) + if t+1 == K: + break +print(i)" +p03221,s346084329,Wrong Answer,"n , m = map(int, input().split()) + +lis = [] +for _ in range(m): + lis.append(list(map(int, input().split()))) + +t = 1 +tmp = sorted(lis)[0][0] + +for i in sorted(lis): + if tmp == i[0]: + a = str(i[0]) + left = a.zfill(6) + right = str(t).zfill(6) + t += 1 + else: + t = 1 + tmp = i[0] + left = str(i[0]).zfill(6) + right = str(t).zfill(6) + + print(left+right)" +p03774,s093887136,Accepted,"n,m = map(int,input().split()) +s = [] +for i in range(n): + s.append(tuple(map(int,input().split()))) +p = [] +for i in range(m): + p.append(tuple(map(int,input().split()))) + +for a,b in s: + mnl = float('inf') + for i in range(m): + c,d = p[i] + l = abs(a-c)+abs(b-d) + if l < mnl: + mnp = i+1 + mnl = l + print(mnp) +" +p02743,s423566712,Wrong Answer,"from math import sqrt as r +a, b, c = map(int, input().split()) + +if (a + b + 2 * r(a * b)) < c: + print(""Yes"") +else: + print(""No"")" +p03073,s775081067,Wrong Answer,"S=list(input()) +cnt=0 +tmp=S[0] +for i in range(len(S)): + if i == 0:continue + if S[i] == tmp: + cnt += 1 + tmp = S[i] +print(cnt)" +p03417,s021126379,Accepted,"# coding: utf-8 +N, M = map(int, input().split()) +print(abs(N * M - (N+M)*2 + 4))" +p03665,s756399996,Wrong Answer,"n,p=map(int,input().split()) +a=[i%2 for i in list(map(int,input().split()))] +e=a.count(0) +o=a.count(1) +if n==1 and sum(a)%2!=p: + print(0) +else: + print((2**e)*(2**o)//2)" +p02684,s299752176,Accepted,"n, k = map(int, input().split()) +A = [0] + list(map(int, input().split())) + +here = 1 +log = [1] +loop = [] +num_log = [0] * (n + 1) +num_log[1] = 1 +for i in range(k): + here = A[here] + if num_log[here] == 1: + pre_loop = log.index(here) + k = k - pre_loop + loop = log[pre_loop:] + here = loop[k % len(loop)] + break + else: + num_log[here] = 1 + log += [here] +print(here) +" +p02747,s172443639,Accepted,"S=input() + +if S==""hi"" or S==""hihi"" or S==""hihihi"" or S==""hihihihi"" or S==""hihihihihi"": + print(""Yes"") +else: + print(""No"")" +p02818,s765975610,Accepted,"A,B,K = list(map(int,input().split())) +if K <= A: + print(A-K,"" "",B) +else: + print(0,"" "",max(A+B-K,0))" +p02831,s956799937,Accepted,"import math +A, B = map(int,input().split()) +print(A * B // math.gcd(A, B))" +p02627,s783884177,Accepted,"n=input() + +if n.isupper(): + print(""A"") +else: + print(""a"")" +p03161,s993758652,Accepted,"n, k = map(int, input().split()) +h = [int(i) for i in input().split()] + +def chmin(a, b): + if a > b: + return b + else: + return a +f_inf = pow(10,9)+99 + +dp = [f_inf] * (n+1) +dp[0] = 0 +for i in range(1, n): + for j in range(1, k+1): + if i - j >= 0: + dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j])) +print(dp[n-1]) +" +p03556,s457825629,Accepted,"n = int(input()) +i = 0 +while i**2 <= n: + result = i**2 + i += 1 +print(result)" +p03456,s965023569,Accepted,"#!/usr/bin/env python3 +import math +a, b = input().split() +c = int(a + b) + +if math.sqrt(c).is_integer(): + print(""Yes"") +else: + print(""No"") +" +p02842,s366954069,Wrong Answer,"# sumitb2019_b_bacha.py +N = int(input()) +for i in range(N): + if int(i*1.08) == N: + print(i) + exit() +print("":("") + + +" +p03264,s272229878,Accepted,"import sys + +def main(): + K = int(input()) + + odd = K // 2 + even = K - odd + + print(odd * even) + +main()" +p03379,s588416749,Wrong Answer,"import copy +N = int(input()) +X = list(map(int,input().split())) +length = len(X) +sortx = sorted(X) +bef = sortx[N//2-1] +aft = sortx[N//2] +for i in range(N): + print(aft if i <= bef else bef) + " +p02658,s579772258,Accepted,"n = int(input()) +al = list(map(int, input().split())) + +res = 1 +from collections import Counter +count = Counter(al) +cc = count[0] + +if cc >=1: + print(0) + exit() + +for i in range(n): + res *= al[i] + if res > 10**18: + print(-1) + exit() + +else: + print(res)" +p02755,s103595996,Accepted,"A,B = list(map(int, input().split())) +flag = 0 + +for j in range(1250): + if int(j*0.08) == A and int(j*0.10) == B: + print(j) + flag = 1 + break + +if flag == 0: + print(-1) + + +" +p03524,s796596703,Accepted,"S = input() +from collections import Counter +ctr = Counter(S) + +mx = max(ctr.values()) +mn = min(ctr.values()) +if len(ctr) < 3: mn = 0 +if abs(mx-mn) < 2: + print('YES') +else: + print('NO')" +p03478,s142939476,Wrong Answer,"n, a, b = list(map(int, input().split())) + +#print(n) +#print(a) +#print(b) + +t = 0 +ans = 0 + +for ii in range(n) : + i = ii+1 + t100 = i // 100 + t10 = (i%100) // 10 + t1 = i%10 + sum = t100 + t10 + t1 + + #print(""i : "" + str(i)) + #print(""t100 : "" + str(t100)) + #print(""t10 : "" + str(t10)) + #print(""t1 : "" + str(t1)) + #print(""sum : "" + str(sum)) + + if a <= sum and sum <= b : + ans = ans + i + #print(""ans : "" + str(ans)) + +print(ans)" +p02697,s896286062,Wrong Answer,"n,m= map(int, input().split()) +ans=[] +if n%2==1: + for i in range(m): + ans.append(i+1) + ans.append(n-1-i) + +else: + for i in range(m): + ans.append(i+2) + ans.append(n-i-1) + +print(*ans)" +p03611,s904410071,Accepted,"import collections +N = int(input()) +A = list(map(int, input().split())) +num = [] +for i in range(N): + num.append(A[i]) + num.append(A[i] + 1) + num.append(A[i] - 1) +#print(num) +num_count = collections.Counter(num) +#print(num_count.values()) +print(max(num_count.values()))" +p02899,s795880353,Accepted,"N = int(input()) +A = list(map(int, input().split())) +ans = {a:i for i,a in enumerate(A,1)} + +for i in range(N): + print(ans[i+1])" +p02953,s302051764,Wrong Answer,"def main(): + N = int(input()) + H = list(map(int, input().split("" ""))) + flag = True + for i in range(N - 1): + if H[i] - H[i + 1] <= 0: + H[i + 1] -= 1 + for j in range(N - 1): + if H[j + 1] - H[j] < 0: + flag = False + break + if flag: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + main()" +p02553,s993368353,Accepted,"a, b, c, d = map(int, input().split()) +print(max(a * c, a * d, b * c, b * d)) +" +p03607,s131962230,Accepted,"N = int(input()) +A = [int(input()) for i in range(N)] + +from collections import Counter +c = Counter(A) +keys, values = zip(*c.most_common()) + +n = len(values) +ans = 0 + +for i in range(n): + if values[i]%2 == 1: + ans += 1 + +print(ans)" +p03545,s017492515,Accepted,"k=input() +a=int(k[0]) +b=int(k[1]) +c=int(k[2]) +d=int(k[3]) +op1=[""+"",""-""] +op2=[""+"",""-""] +op3=[""+"",""-""] +flag=0 +for i in range(2): + for j in range(2): + for l in range(2): + siki=k[0]+op1[i]+k[1]+op2[j]+k[2]+op3[l]+k[3] + if (eval(siki)==7): + print(siki+""=7"") + flag=1 + if (flag==1): + break + if (flag==1): + break + if (flag==1): + break" +p02597,s880185115,Accepted,"n = int(input()) +c = input() + +r_cnt = 0 +for i in range(n): + if c[i] == 'R': + r_cnt += 1 + + +r_cnt_2 = 0 +for i in range(r_cnt): + if c[i] == 'R': + r_cnt_2 += 1 + +if r_cnt == n: + print(0) +else: + print(r_cnt - r_cnt_2) +" +p04029,s086522292,Accepted,"n=int(input()) +ans=n*(n+1)//2 +print(ans)" +p03456,s020701635,Accepted,"# -*- coding: utf-8 -*- + +import math +import itertools +import sys +import copy + +# 入力 +#A, B, C, D = map(int, input().split()) +#L = list(map(int, input().split())) +#N = int(input()) +a, b = map(str, input().split()) + +d = int(a+b) + +if d == (math.floor(d**0.5) ** 2) : + print (""Yes"") +else : + print (""No"") +" +p02578,s196756721,Accepted,"n = int(input()) +a = list(map(int,input().split())) +x = 0 +total = 0 + + +for i in range(n-1): + if a[i] >= a[i+1]: + x = a[i] - a[i+1] + total += x + a[i+1] = a[i] + i = i+1 + else: + total += 0 + +print(total)" +p03804,s028205170,Accepted,"N, M = map(int, input().split()) +A = [input() for _ in range(N)] +B = [input() for _ in range(M)] + +diff = N - M +for i in range(diff+1): + for j in range(diff+1): + flag = True + for k in range(M): + if not (B[k] in A[j+k][i:i+M]): + flag = False + if flag: + print('Yes') + exit(0) + +print('No') +" +p03657,s641196713,Accepted,"a,b=map(int,input().split()) +if a%3==0 or b%3==0 or (a+b)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p03103,s766348656,Wrong Answer,"N, M = list(map(int,input().split())) +L = [] +for i in range(N): + L.append(list(map(int,input().split()))) +L = sorted(L) +a = 0 +c = 0 +for i in range(N): + a = a + L[i][1] + if a > M: + c = i + break +p = 0 +for j in range(c): + p += L[j][0]*L[j][1] + +p += L[c][0]*(M - a + L[c][1]) + +print(p)" +p02789,s810563556,Wrong Answer,"N,M = map(int,input().split()) + +if (N==M): + print(""Yes"") +elif(N!=M): + print(""NO"") + +" +p03000,s164435097,Accepted,"def resolve(): + n,x=map(int, input().split()) + l=list(map(int, input().split())) + num=1 + zahyou=0 + for i in range(n): + zahyou+=l[i] + if zahyou<=x: + num+=1 + print(num) +resolve()" +p02818,s319970398,Accepted,"a,b,k = map(int,input().split()) + +if a-k>0: + a -= k + print(a,b) + exit() +else: + k -= a + a = 0 +if b-k>0: + b -=k + print(a,b) + exit() +else: + print(a,0)" +p03711,s167880081,Accepted,"x, y = map(int, input().split()) +a=[1, 3, 5, 7, 8, 10, 12] +b=[4, 6, 9, 12] +c=[2] +if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): + print(""Yes"") +else: + print(""No"")" +p03478,s792810612,Accepted,"N, A, B = map(int,input().split()) + +count = 0 + +for i in range(1, N + 1): + dict_sum = sum(map(int, str(i))) + if A <= dict_sum <= B: + count = count + i + +print(count)" +p02697,s493066007,Accepted,"n,m=list(map(int,input().split())) +mm=int((m+1)/2+0.01) +for i in range(mm): + print(1+i,2*mm-i) +for i in range(m-mm): + print(2*mm+i+1,2*m-i+1)" +p02847,s659377427,Wrong Answer,"S = input('曜日を入力してね! ') + +if S == 'SUN': + print('7') + +if S == 'MON': + print('6') + +if S == 'TUE': + print('5') + +if S == 'WED': + print('4') + +if S == 'THU': + print('3') + +if S == 'FRI': + print('2') + +if S == 'SAT': + print('1')" +p02754,s718433212,Accepted,"N, A, B = list(map(int, input().split())) + +SUM=0 +a = N % (A + B) +if a > A: + SUM = A +else: + SUM = a + +SUM = SUM + (N // (A + B)) * A + +print(SUM)" +p03161,s045191567,Accepted,"import sys + + +def input(): + return sys.stdin.readline().strip() + + +n, k = map(int, input().split()) +H = list(map(int, input().split())) + +INF = 10 ** 9 +dp = [INF] * n +dp[0] = 0 +for i in range(n - 1): + for j in range(1, k + 1): + if j >= n - i: + break + dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i])) +print(dp[-1]) +" +p02817,s438928239,Accepted,"s,t = input().split() +print(t+s)" +p03416,s634270333,Wrong Answer,"def Is_cyc(x): + s = str(x) + for i in range(len(s)): + if s[i] != s[-i-1]: + return False + return True + +def main(): + a,b = map(int,input().split()) + ans = 0 + for i in range(a,b+1): + if Is_cyc(i): + ans += 1 + print(ans)" +p02820,s663779550,Accepted,"n,k = map(int,input().split()) +r,s,p = map(int,input().split()) +t = list(input()) + +win = {""r"":""p"",""s"":""r"",""p"":""s""} +point = {""r"":r,""s"":s,""p"":p} + +ans = [] +sum = 0 + +for i in range(k): + ans.append(win[t[i]]) + sum+=point[win[t[i]]] + +for i in range(k,n): + if win[t[i]] == ans[i - k]: + ans.append(-1) + else: + ans.append(win[t[i]]) + sum+=point[win[t[i]]] +print(sum)" +p02578,s622028652,Accepted,"def solve(n, arr): + ans_arr = [0] + for i in range(0, n-1): + if arr[i] > arr[i + 1]: + diff = arr[i] - arr[i + 1] + ans_arr.append(diff) + arr[i + 1] += diff + else: + ans_arr.append(0) + return sum(ans_arr) + +if __name__ == ""__main__"": + n = int(input()) + arr = list(map(int, input().split(' '))) + print(solve(n, arr))" +p03994,s925390393,Wrong Answer,"alf = {c:i for i,c in enumerate('abcdefghijklmnopqrstuvwxyz')} +a = 'abcdefghijklmnopqrstuvwxyz' +s = input() +k = int(input()) +diff = [26-alf[c] for c in s] +diff[0] = 0 +ans = [] +for i in range(len(s)): + if k >= diff[i]: + ans.append('a') + k -= diff[i] + else: + ans.append(s[i]) + # print(ans,k) +if k > 0: + ans[-1] = a[(alf[ans[-1]] + k % 26)] +print(''.join(ans)) +" +p03795,s811025024,Accepted,"from sys import stdin, stdout + + +def main() -> None: + line = int(stdin.readline()) + x = line * 800 + tmp = line / 15 + y = int(tmp) * 200 + rta = x - y + print(rta) + + +main()" +p03544,s799122366,Wrong Answer,"n = int(input()) + +l0 = 2 +l1 = 1 +ans = 0 +for i in range(n - 1): + ans = l0 + l1 + l0 = l1 + l1 = ans + +print(ans) +" +p03493,s767341557,Wrong Answer,"s = ""101"" +s = list(map(int, (s[0] + s[2]))) +print(sum(s))" +p02765,s354421962,Accepted,"import sys +sys.setrecursionlimit(10**9) +INF=10**18 +MOD=10**9+7 +def input(): return sys.stdin.readline().rstrip() + +def main(): + N,R=map(int,input().split()) + print(R+100*max(0,(10-N))) + +if __name__ == '__main__': + main() +" +p03632,s184655661,Accepted,"A,B,C,D=map(int, input().split()) +if A>= 1 +#print(result%mod) + +N = int(input()) +A = np.fromstring(input(),dtype = np.int64, sep = ' ') +Large = 10**9 + 7 +ans = 0 +for i in range(60): + sum1 = np.sum(A&1) + ans += sum1*(N-sum1) * pow(2,i,Large) + ans %= Large + A>>=1 # A = A>>1とする +print(ans) + + + + + + +" +p04034,s286097832,Accepted,"#!/usr/bin/env python3 +import sys + + +def main(): + N, M = map(int, input().split()) + red = [0] * N + red[0] = 1 + num = [1] * N + + for i in range(M): + x, y = map(int, input().split()) + x -= 1 + y -= 1 + if red[x]: + red[y] = 1 + + num[x] -= 1 + num[y] += 1 + if num[x] == 0: + red[x] = 0 + print(sum(red)) + +if __name__ == '__main__': + main() +" +p04019,s947504258,Accepted,"s = set(list(input())) +if any(s==set(list(cand)) for cand in ['NS','EW','NEWS']): + print('Yes') +else: + print('No') +" +p03274,s100952907,Wrong Answer,"import sys +N , K = map(int,input().split()) +x = list(map(int,input().split())) +m = 2* 10**8 +for i in range(N - K + 1): + r = N - i - 1 + l = N - i - K + s1 = abs(x[r]) + abs(x[r] - x[l]) + s2 = abs(x[l]) + abs(x[r] - x[l]) + s = min([s1,s2]) + if s abs(H[i][0]-A): + print(H[i][1]+1) +else: + print(H[i-1][1]+1)" +p02705,s280466303,Accepted,"import math +r = int(input()) +p = math.pi +a = p * (r * 2) +print(a)" +p03071,s713501972,Wrong Answer,"a, b = map(int, input().split()) + +if abs(a - b) <= 1: + print(max(a,b)*2-1) +elif a - b == 0: + print(a*2) +else: + print(a*2-1)" +p02888,s030209405,Accepted,"N = int(input()) +L = list(map(int, input().split())) +L.sort() +result = 0 +for x in range(N): + z = x + 2 + for y in range(x+1, N): + while z < N and L[x] + L[y] > L[z]: + z += 1 + result += z - y - 1 +print(result)" +p02993,s935488837,Accepted,"s=input() + +if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]: + print(""Bad"") +else: + print(""Good"")" +p02951,s623822588,Wrong Answer,"A,B,C =map(int,input().split()) +print(C-A+B)" +p02993,s076886482,Wrong Answer,"s = input() + +ans = 'Nad' +for i in range(len(s)-1): + if s[i] == s[i+1]: + ans = 'Good' + break +print(ans) +" +p03486,s444844190,Wrong Answer,"# import numpy as np +import sys, math +from itertools import permutations, combinations +from collections import defaultdict, Counter, deque +from math import factorial, gcd +from bisect import bisect_left, bisect_right + +sys.setrecursionlimit(10 ** 7) +enu = enumerate +MOD = 10 ** 9 + 7 +input = lambda: sys.stdin.readline()[:-1] +pl = lambda x: print(*x, sep=""\n"") + +S = list(input()) +T = list(input()) + +S.sort() +T.sort(reverse=True) +for s, t in zip(S, T): + if ord(s) < ord(t): + print(""Yes"") + exit() +else: + print(""No"") +" +p02888,s551744231,Accepted,"from bisect import bisect_left +N = int(input()) +L = list(map(int, input().split())) +L.sort() +ans = 0 +for i in range(N): + for j in range(i+1, N): + A = L[i] + L[j] + highbound = bisect_left(L, A) + ans += highbound - j - 1 +print(ans)" +p03705,s100928715,Wrong Answer,"N,A,B=map(int, input().split()) +#最小がA 最大がB その区間でN個 +if A>B: + print(0) + exit() +elif N==1 and A!=B: + print(0) + exit() +MAX=A+B*(N-1) +MIN=B+A*(N-1) +print(MAX, MIN) +print(MAX-MIN+1)" +p03633,s866285256,Wrong Answer,"import math +def gcd(a, b): + while b: + a, b = b, a % b + return a +def lcm(x, y): + return (x * y) // gcd(x, y) + +N = int(input()) +T = [int(input()) for _ in range(N)] +if N == 1: + print(T[0]) + exit() + +ans = lcm(T[0] , T[1])" +p02606,s036104133,Wrong Answer,"a = list(map(int, input().split())) +count = 0 + +if (a[1] - a[0]) % a[2] != 0: + count = 0 +elif (a[1] - a[0]) != 0 & a[2] == 1: + count = a[1] +else: + for i in range(a[1] + 1): + if i % a[2] == 0: + count += 1 + + for j in range(a[0] + 1): + if j % a[2] == 0: + count -= 1 + +print(count)" +p03455,s795306977,Accepted,"# -*- coding: utf-8 -*- +import sys +sys.setrecursionlimit(10**9) +INF=10**18 +MOD=10**9+7 +input=lambda: sys.stdin.readline().rstrip() +YesNo=lambda b: bool([print('Yes')] if b else print('No')) +YESNO=lambda b: bool([print('YES')] if b else print('NO')) +int1=lambda x:int(x)-1 + +def main(): + a,b=map(int,input().split()) + if a*b%2: + print('Odd') + else: + print('Even') + +if __name__ == '__main__': + main() +" +p02717,s710125961,Accepted,"n=input() + +abc = n.split("" "") + +a=abc[0] +b=abc[1] +c=abc[2] + +print(c + "" "" + a + "" "" + b)" +p03705,s716771907,Accepted,"import sys +stdin = sys.stdin +mod = 10**9 + 7 + +def ns(): return stdin.readline().rstrip() +def ni(): return int(ns()) +def na(): return list(map(int, stdin.readline().split())) + + +n, a, b = na() +sum_min = a * (n-1) + b +sum_max = a + (n-1) * b + +if n == 0 and a != b: + print(0) +else: + print(max(0, sum_max - sum_min + 1))" +p04033,s662854332,Accepted,"a,b =map(int,input().split()) +cnt =b-a+1 + +if a <0 and b>0 or a==0 or b==0: + ans = ""Zero"" +elif (a>0 and b>0) or(a<0 and b<0 and cnt%2==0) : + ans=""Positive"" + +elif(a<0 and b<0 and cnt%2!=0): + ans=""Negative"" + +print(ans)" +p03544,s856738391,Accepted,"n = int(input()) + +lst = [2, 1] +for i in range(100): + lst.append(lst[-1]+lst[-2]) +print(lst[n])" +p03971,s570277817,Accepted,"S=lambda:input() +I=lambda:int(input()) +L=lambda:list(map(int,input().split())) +LS=lambda:list(map(str,input().split())) + +n,a,b=L() +s=S() +passed=0 +rankbyb=0 +for i in range(n): + if s[i]=='b': + rankbyb+=1 + + if s[i]=='a' and passed diff: + ans = diff +print(ans) +" +p03471,s171282998,Accepted,"n, y = map(int,input().split()) + +for i in range(0,n+1): + for j in range(0, n-i+1): + if y == 10000*i + 5000*j + 1000*(n-i-j): + print(""{0} {1} {2}"".format(i, j, n-i-j)) + exit() +print(""-1 -1 -1"") +" +p02988,s454367847,Accepted,"def actual(n, P): + count = 0 + + for i in range(1, n - 1): + a, b, c = P[i - 1], P[i], P[i + 1] + + if (a < b < c) or (a > b > c): + count += 1 + + return count + +n = int(input()) +P = list(map(int, input().split())) + +print(actual(n, P))" +p02970,s250052767,Accepted,"import math +n,d=map(int,input().split()) +print(math.ceil(n/(2*d+1))) +" +p03548,s623176875,Accepted,"x,y,z = map(int, input().split()) + +n = 1 +while x >= (n+1)*z + n*y: + n += 1 +print(n-1)" +p02873,s354595544,Wrong Answer,"S = list(input()) +before = 0 +last_upper = 0 +count = 0 +answer = 0 +for i, s in enumerate(S): + # print(answer, i, before, last_upper) + if s == '<': + if before < 0 and last_upper < i-1: + answer += abs(before)*(i-last_upper) + before = 0 + elif before > 0 and last_upper < i-1: + answer -= before*(i-last_upper-1) + before = 0 + before += 1 + answer += before + last_upper = i + else: + before -= 1 + answer += before +# print(answer, last_upper) +if before < 0: + answer += abs(before)*(len(S)-last_upper) +elif before > 0: + answer -= before*(len(S)-last_upper-1) +print(answer) +" +p02600,s949652226,Wrong Answer,"def resolve(): + x = int(input()) + ans = 8 + low = 400 + for s in range(401, 2000): + if s == low+200: + low = s + ans -= 1 + if x == s: + break + print(ans) +resolve()" +p03377,s270403550,Accepted,"A,B,X = map(int,input().split()) +cat = X-A +if cat >= 0 and cat <= B : + print('YES') +else: + print('NO')" +p03107,s976925509,Accepted,"s = list(input()) +a = s.count('0') +b = s.count('1') +print(2*min(a,b))" +p03481,s976374286,Accepted,"x,y = map(int,input().split()) +cnt = 0 +cur = x +while(cur<=y): + cur = cur *2 + cnt += 1 +print(cnt)" +p02760,s764341777,Accepted,"a = [list(map(int,input().split())) for i in range(3)] +n = int(input()) +b = [int(input()) for j in range (n)] +ans = ""No"" +for k in range (n): + for l in range(3): + for m in range(3): + if a[l][m] == b[k]: + a[l][m] = 0 +for o in range(3): + if a[o][0] == a[o][1] == a[o][2] or a[0][o] == a[1][o] == a[2][o]: + ans = ""Yes"" +if a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]: + ans = ""Yes"" +print(ans)" +p02659,s957136940,Wrong Answer,"a,b=map(float, input().split()) +ans=(a*b)//1 +print(int(ans))" +p02583,s234331061,Accepted,"n = int(input()) +l = list(map(int, input().split())) + +ans = 0 + +for i in range(n): + for j in range(i+1,n): + for k in range(j+1,n): + if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]: + ans+=0 + elif abs(l[i]-l[j]) 0 or (neg % 2) == 0: + ans = sum(abs(A)) +else: + ans = sum(abs(A)) - min(abs(A)) + # print(S, idx, A[idx], res) + +print(ans) + +" +p02597,s383565339,Accepted,"N = int(input()) +C = list(input()) +l = 0 +r = N-1 +ans = 0 +while (r-l) > 0: + if C[l] == ""W"" and C[r] == ""R"": + C[l], C[r] = C[r], C[l] + l += 1 + r -= 1 + ans += 1 + continue + if C[l] == ""R"": + l += 1 + if C[r] == ""W"": + r -= 1 +print(ans)" +p03721,s023369013,Accepted,"from heapq import heappop, heappush +N, K = map(int, input().split()) +AB = [] + +cnt = 0 +for i in range(N): + a, b = map(int, input().split()) + heappush(AB, (a, b)) + + +while AB: + a, b = heappop(AB) + cnt += b + + if K <= cnt: + print(a) + exit()" +p03150,s395359847,Accepted,"import sys +input = sys.stdin.readline +S = list(input())[: -1] +for l in range(len(S)): + for r in range(l, len(S)): + t = S[: l] + S[r: ] + if """".join(t) == ""keyence"": + print(""YES"") + exit(0) +print(""NO"")" +p03607,s880761618,Wrong Answer,"a=int(input()) +b=[input() for i in range(a)] +print((len(b)-(len(b)-len(set(b)))*2))" +p03041,s462831554,Accepted,"N,K=map(int,input().split()) +S=input() +newS = S[:K-1]+S[K-1].lower()+S[K:] +print(newS)" +p03262,s392216981,Wrong Answer,"N,X = map(int,input().split()) +x = list(map(int,input().split())) +x.append(X) +x.sort() +d = float(""inf"") +for i in range(N): + d = min(d,abs(x[i]-x[i+1])) +print(d)" +p03146,s138306689,Accepted,"a = int(input()) +als = [0]*(100000) +for i in range(0,10**6+2): + als[a] = 1 + if a%2 == 0: + a = a//2 + else: + a = 3*a+1 + if als[a] == 1: + print(i+2) + exit()" +p02583,s753420354,Accepted,"#!/usr/bin/env python3 +import itertools +n = int(input()) +l = list(map(int, input().split())) + +ans = 0 +for i in itertools.combinations(l, 3): + i = sorted(list(i)) + # print(i) + if i[0] == i[1] or i[1] == i[2]: + continue + if i[0]+i[1] > i[2]: + # print(i) + ans += 1 + +print(ans) +" +p03719,s305514614,Wrong Answer,"a,b,c = map(int,input().split()) +print(""YES"" if a>=c and a<=b else ""NO"")" +p03162,s406841140,Wrong Answer,"N = int(input()) +ABC = [] +for _ in range(N): + ABC.append(list(map(int, input().split()))) + +table = [[0]*3 for i in range(N)] + + +for i in range(0, N):# i日目 + if i == 0: + table[i] = ABC[i] + else: + for j in range(3): #a,b,c + table[i][j] = max( + [table[i-1][j1] + ABC[i][j1] for j1 in range(3) if j1 != j] + ) + # print(table) + +print(max(table[-1]))" +p02714,s409294834,Accepted,"n = int(input()) +s = input() + +ans = s.count(""R"") * s.count(""G"") * s.count(""B"") + +for i in range(n-2): + si = s[i] + for j in range(i+1, i+(n-i-1)//2+1): + sj = s[j] + k = 2*j-i + if k < n and s[k] != si and s[k] != sj and si != sj: + ans -= 1 + +print(ans)" +p03693,s540697117,Accepted,"li = list(map(int,input().split())) +total = 100*li[0] + 10*li[1]+li[2] +print(""YES"" if total % 4 == 0 else ""NO"")" +p03030,s212359913,Wrong Answer,"def main(): + n = int(input()) + if n == 1: + print(1) + return + a = [list(input().split()) for i in range(n)] + s = sorted(a, key=lambda x:(x[0],-int(x[1]))) + for i in a: + print(s.index(i)+1) + +if __name__ == '__main__': + main() +" +p03252,s531741779,Accepted,"S = input() +T = input() + +if len(set(S)) != len(set(T)): + print(""No"") + exit() +else: + for i in range(len(S)): + if S.index(S[i]) != T.index(T[i]): + print(""No"") + #print(S.index(S[i]), T.index(T[i])) + exit() +print(""Yes"") +" +p03351,s138313580,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + a, b, c, d = map(int, input().split()) + + ab = abs(a - b) <= d + bc = abs(b - c) <= d + ca = abs(c - a) <= d + if ca or (ab and bc): + ans = ""Yes"" + else: + ans = ""No"" + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02675,s292095302,Accepted,"n = int(input()) +a = n%10 + +if a == 3: + print('bon') +elif str(a) in '0168': + print('pon') +else: + print('hon') +" +p02608,s904684898,Accepted,"from math import sqrt +n = int(input()) +sqn_int = int(sqrt(n)) +a = [0] * n +for x in range(1, 1 + sqn_int): + for y in range(1, 1 + sqn_int): + for z in range(1, 1 + sqn_int): + left = x**2 + y**2 + z**2 + x*y + y*z + z*x + if left <= n: + a[left - 1] += 1 +for i in a[:n]: + print(i) +" +p03730,s548715973,Accepted,"A, B, C = map(int, input().split()) +for i in range(A, B * A + 1, A) : + if i % B == C : + print(""YES"") + exit() + if i == B * A : + print(""NO"") +" +p03681,s981329830,Accepted,"import math +n, m = map(int, input().split()) + +if abs(n-m)>1: + print(0) +elif n-m==1: + print(int((math.factorial(n)*math.factorial(m))%(10**9+7))) +elif m-n==1: + print(int((math.factorial(m)*math.factorial(n))%(10**9+7))) +elif n==m: + print(int((math.factorial(n)*math.factorial(m)*2)%(10**9+7)))" +p02854,s720824741,Accepted,"import sys +from itertools import accumulate + +input = sys.stdin.readline + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + + cumsum_A = list(accumulate(A)) + sum_A = sum(A) + + ans = float(""inf"") + for i in range(N - 1): + cost = abs((sum_A - cumsum_A[i]) - cumsum_A[i]) + if cost < ans: + ans = cost + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02727,s607245872,Wrong Answer,"X, Y, A, B, C = [int(i) for i in input().split()] +P = [int(i) for i in input().split()] +Q = [int(i) for i in input().split()] +R = [int(i) for i in input().split()] + +P = sorted(P) +Q = sorted(Q) +R = sorted(R) + + +A= P[:X] + Q[:Y] + R +A = sorted(A) +print(sum(A[:X+Y])) +" +p03627,s686803743,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +a.sort() + +tmp_val = 0 +pair_val = 0 +for i in range(n-1, -1, -1): + if tmp_val == a[i]: + if pair_val != 0: + print(pair_val * a[i]) + exit() + else: + pair_val = a[i] + tmp_val = 0 + else: + tmp_val = a[i] + +print(0)" +p02820,s419308394,Accepted,"import sys,math,collections,itertools +input = sys.stdin.readline + +N,K=list(map(int,input().split())) +R,S,P=list(map(int,input().split())) +T = input().rstrip() +s =T.replace('r','P') #P +ss=s.replace('s','R') #R +sss=ss.replace('p','S') #S +sl = list(sss) + +for i in range(K,N): + if sl[i]==sl[i-K]: + sl[i] = '0' + +sc = collections.Counter(sl) + +print(sc['R']*R + sc['P']*P + sc['S']*S) +" +p02923,s614136683,Accepted,"n = int(input()) +h = [int(x) for x in input().split()] +ans = 0 +count = 0 +for i in range(n-1): + if h[i]>=h[i+1]: + count += 1 + else: + ans = max(ans,count) + count = 0 +else: + ans = max(ans,count) +print(ans)" +p02833,s982385728,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +p = int(readline()) +if p % 2 == 1: + print(0) +else: + p //= 2 + ans = 0 + while p: + p //= 5 + ans += p + print(ans)" +p02918,s980283671,Wrong Answer,"N,K=map(int,input().split()) +S=input() +e=(S[0]=='L')+(S[-1]=='R') +i=S.count(""RL"") +c=max(i-K,0)*2+max(e-max(K-i,0),0) + +print(N-c)" +p02879,s929866184,Accepted,"a, b = map(int, input().split()) +if a in range(1, 10) and b in range(1, 10): + print(a * b) +else: + print(-1) +" +p03105,s258374498,Wrong Answer,"A, B, C = map(int, input().split()) + +if B > A * C: + print(C) +elif A * C > B and B > A: + print(A) +else: + print(0)" +p03448,s456682278,Accepted,"A=int(input()) +B=int(input()) +C=int(input()) +X=int(input()) +s=0 +for i in range(A+1): + x=X-500*i + if x<0: break + for t in range(B+1): + if x<0: break + elif 50*C>=x: + s+=1 + x-=100 + else: x-=100 +print(s) " +p02766,s349938969,Accepted,"import math +def findNumberOfDigits(n, b): + dig = (math.floor(math.log(n) /math.log(b)) + 1) + return dig +n, k = map(int, input().strip().split()) +print(findNumberOfDigits(n, k))" +p03861,s997302245,Wrong Answer,"a, b, x = map(int, input().split()) + +if (b-a+1) % x == 0: + ans = (b-a+1) // x +elif a % x == 0 or b % x == 0: + ans = (b-a+1) // x + 1 +else: + ans = (b-a+1) // x + +print(ans)" +p03127,s600050810,Wrong Answer,"import sys +n=int(input()) +a=list(map(int,input().split())) +g=0 +k=0 +i=set(a) +if len(i)==1: + print(a[0]) + sys.exit() +j=0 +while g*k==0 and j0: + r=n%10 + s=s+r + n=n//10 + if s%9==0: + continue + else: + c=1 + print('No') + break +if not c: + print('Yes') +" +p03665,s796895910,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +n, p = map(int, readline().split()) +a = list(map(int, readline().split())) +cnt_1 = 0 +cnt_2 = 0 +for i in a: + if i % 2 == 1: + cnt_1 += 1 + else: + cnt_2 += 1 +ans = 2 ** max(0, cnt_1 - 1) * 2 ** cnt_2 +if p == 1 and cnt_1 == 0: + ans = 0 +print(ans) +" +p02773,s638878284,Accepted," +from collections import Counter + +n = int(input()) +s = [input() for i in range(n)] +c = Counter(s) +C = c.most_common() +a = C[0][1] +ans = [] +for i in range(len(c)): + if C[i][1] == a: + ans.append(C[i][0]) + +ans.sort() +print(*ans,sep=""\n"")" +p02645,s044300458,Accepted,"S=input() +print(S[:3])" +p02970,s377799032,Wrong Answer,"n,d = map(int,input().split()) +a = 0 +ans = 0 +while a < n: + a += 2*d + ans += 1 +print(ans)" +p04034,s142051385,Wrong Answer,"N, M = map(int, input().split()) +P = [0] * N +C = [1] * N +P[0] = 1 +for _ in range(M): + x, y = map(int, input().split()) + x -= 1 + y -= 1 + P[y] += P[x] / C[x] + P[x] -= P[x] / C[x] + C[x] -= 1 + C[y] += 1 +print(sum([1 if p else 0 for p in P]))" +p02971,s143516079,Accepted,"n = int(input()) +h = [] + +for i in range(n): + h.append(int(input())) + +left = [0] * n +left[0] = h[0] +for i in range(1, n): + left[i] = max(left[i - 1], h[i]) + +right = [0] * n +right[-1] = h[-1] +for i in reversed(range(n - 1)): + right[i] = max(right[i + 1], h[i]) + +print(right[1]) +for i in range(1, n - 1): + print(max(left[i - 1], right[i + 1])) +print(left[n - 2])" +p02953,s936262391,Wrong Answer,"from functools import reduce +n = int(input()) +H = list(map(int, input().split())) + +H[0] -= 1 +for i in range(1, n): + if H[i] < H[i-1]: + H[i] -= 1 +print('Yes' if reduce(lambda x, y: x <= y, H) else 'No')" +p03274,s703230039,Wrong Answer,"N,K=map(int,input().split()) +x=list(map(int,input().split())) + +ans=max(x)-min(x) + +for i in range(N-K+1): + ans=min(ans,x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1]))) +print(ans)" +p04012,s395308505,Accepted,"w = input() +flag = True +wlist = ""a b c d e f g h i j k l m n o p q r s t u v w x y z"".split() +for i in range(26) : + if w.count(wlist[i]) % 2 == 1 : + print(""No"") + flag = False + break +if flag : + print(""Yes"")" +p02665,s174042288,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=[0]*(N+1) +B[N]=A[N] +for i in range(N-1,-1,-1): + B[i]=B[i+1]+A[i] + +C=[0]*(N+1) +C[0]=1 +for i in range(1,N+1): + C[i]=2*(C[i-1]-A[i-1]) + +check=[min(B[i],C[i]) for i in range(N+1)] +for i in range(N+1): + if check[i]= cnt: + K -= cnt + ans.append('a') + else: + ans.append(c) +K %= 26 +if 122 < ord(ans[-1]) + K: + ans[-1] = chr(ord(ans[-1]) + K - 26) +else: + ans[-1] = chr(ord(ans[-1]) + K) +print(*ans,sep='') +" +p02677,s301863851,Accepted,"import math + +a, b, h, m = list(map(int, input().split())) +deg_a = (60 * h + m) * (360 / (60 * 12)) +deg_b = m * (360 / 60) +deg = abs(deg_a - deg_b) +rad = math.radians(deg) + +c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad) +print(c2 ** 0.5)" +p04044,s725130815,Accepted,"n, l = map(int, input().split()) +s = [input() for _ in range(n)] +s.sort() +print(''.join(s))" +p02923,s737438516,Wrong Answer,"N = int(input()) +H = list(map(int,input().split())) + +count = [0] + +for i in range(1,N): + if H[i-1] > H [i]: + count.append(count[-1] + 1) + else: + count.append(0) + +print(max(count))" +p03612,s811763505,Wrong Answer,"N=int(input()) +p=list(map(int,input().split())) + +count=0 +for i in range(N-1): + if p[i] == i+1: + p[i],p[i+1]=p[i+1],p[i] + count += 1 +print(count)" +p03243,s155875429,Wrong Answer,"N = int(input()) + +res = 0 +for i in range(9): + tmp = i * 111 + if tmp >= N: + res = tmp + break +print(res)" +p02754,s276484571,Wrong Answer,"N, A, B = map(int, input().split()) +num = A * N // (A + B) +if N % (A + B) > A: + print(num + A) +else: + print(num + (N % (A + B)))" +p02682,s228298153,Wrong Answer,"a,b,c,k = list(map(int, input().split())) +if a + b >= k: + print(a) +else: + print(2 * a + b - k) +" +p02854,s964083432,Wrong Answer,"import sys +input = sys.stdin.readline + +def main(): + n = int(input()) + + stick = list(map(int, input().split())) + + total = sum(stick) + mid = total // 2 + + cum = 0 + midi = 0 + for i, block in enumerate(stick): + cum += block + if cum >= mid: + midi = i + break + + l1 = cum + r1 = total - l1 + diff1 = abs(l1 - r1) + + l2 = l1 + stick[midi] + r2 = r1 - stick[midi] + diff2 = abs(l2 - r2) + + print(min(diff1, diff2)) + +main()" +p02659,s942935651,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Sun May 31 21:07:49 2020 + +@author: NEC-PCuser +"""""" + +A, B = map(str, input().split()) +A = int(A) +B = float(B) * 1000 // 1 + +C = A * int(B) // 1000 +print(C)" +p03035,s391676383,Wrong Answer,"A,B = map(int,input().split()) +if A <= 5: + print(0) +elif A <= 12: + print(B/2) +else: + print(B)" +p02576,s523348346,Accepted,"n, x, t = map(int, input().split()) +print(t * ((n + x - 1) // x)) +" +p02631,s140874543,Accepted,"def main(): + n = int(input()) + a = [int(v) for v in input().split()] + x = 0 + for i in range(n): + x ^= a[i] + for i in range(n): + print(x ^ a[i]) + +main()" +p03681,s790907573,Accepted,"x,y=map(int,input().split()) +import math +xx=math.factorial(x) +yy=math.factorial(y) +if x==y: + print(xx*yy*2%((10**9)+7)) +elif abs(x-y)==1: + print(xx*yy%((10**9)+7)) +else: + print(0)" +p03479,s369019675,Wrong Answer,"import math + +a,b = map(int, input().split()) +print(b/a) +n= math.floor(math.log2(b/a)) +print(n+1)" +p02838,s458848601,Accepted,"import numpy as np +MOD = 10 ** 9 + 7 +N = int(input()) +A = np.array(list(map(int, input().split()))) +ans = 0 +for n in range(60): # または、range(60)またはrange(len(bin(max(A)))) + cnt_1 = np.count_nonzero((A>>n)&1) + cnt_0 = N - cnt_1 + ans += (cnt_1 * cnt_0 * (2 ** n)) % MOD +ans %= MOD +print(ans)" +p02817,s383223345,Accepted,"S, T = input().split() + +print(T+S)" +p02860,s347948320,Accepted,"N = int(input()) +S = input() + +if N%2 == 1: + print(""No"") +else: + count = 0 + for i in range(N//2): + if S[i] == S[i+N//2]: + count+=1 + if count == N//2: + print(""Yes"") + else: + print(""No"")" +p04029,s835332993,Accepted,"N = int(input()) + +S = N*(N+1)//2 + +print(S) +" +p03146,s051272245,Wrong Answer,"s = int(input()) + +def f(n): + if n % 2 == 0: + return n//2 + else: + return 3*n+1 + +cnt = 1 +k = s +while(True): + k = f(k) + cnt += 1 + if k == 4: + ans = cnt+3 + break + +print(ans)" +p03211,s334558370,Wrong Answer,"S=list(input()) +X=753 +ans=0 +for i in range(len(S)-2) : + for j in range(0,8,1) : + if int(S[i]) == j : + demo = int(S[i]+S[i+1]+S[i+2]) + if demo >= ans : + ans = demo +print(abs(X-ans)) + + " +p02897,s081851929,Accepted,"n=int(input()) +if n%2==0: + print(""0.5"") +if n%2==1: + print((int(n/2)+1)/n)" +p03252,s520964636,Accepted,"from collections import Counter as Ct +print('Yes' if sorted(Ct(input()).values()) == sorted(Ct(input()).values()) else 'No')" +p02911,s055736125,Wrong Answer,"n,k,q =map(int,input().split()) +ans=[0]*n +for i in range(q): + a=int(input()) + ans[a-1]+=1 +for i in range(n): + if 0 <=ans[i]<=q-k and q-k>0: + print(""No"") + else: + print(""Yes"") +" +p03723,s085795097,Accepted,"A, B, C = map(int, input().split()) +ans = 0 +while True: + # print(A, B, C) + if A % 2 == 0 and B % 2 == 0 and C % 2 == 0: + if A == B == C: + print(-1) + exit() + ans += 1 + tA = A + tB = B + tC = C + A = tB//2 + tC//2 + B = tA//2 + tC//2 + C = tB//2 + tA//2 + else: + print(ans) + exit() + +" +p03095,s826573740,Accepted,"#AGC031 A Colorful Subsequence +# Answer +N = int(input()) +S = input() +alpha = [0]*26 +mod = 10**9+7 + +for n in S: + num = ord(n)-97 + alpha[num] += 1 + +ans = 1 +for i in range(26): + ans *= (alpha[i]+1) + +# ans %= mod +print(ans%mod-1)" +p03767,s268195583,Accepted,"n = int(input()) +A = list(map(int, input().split())) +A.sort() +A.reverse() +ans = 0 +for i in range(n): + ans += A[1 + 2*i] +print(ans)" +p03835,s815749629,Accepted,"##import sys +#import numpy as np +import math +#from fractions import Fraction +import itertools +from collections import deque +from collections import Counter +import heapq +from fractions import gcd +#input=sys.stdin.readline +#import bisect +k,s=map(int,input().split()) +ans=0 +for i in range(k+1): + if s-i>2*k: + continue + else: + for j in range(k+1): + if s-i-j>k or s-i-j<0: + continue + else: + ans+=1 +print(ans)" +p03416,s208938627,Accepted,"a = list(map(int, input().split())) +ans = 0 +for i in range(a[0], a[1]+1): + t = str(i) + flag = True + for j in range(len(t)//2): + if t[j]!=t[len(t)-1-j]: + flag = False + ans += 1 if flag else 0 +print(ans) +" +p02630,s522761755,Wrong Answer,"from collections import Counter +n=int(input()) +a=list(map(int,input().split())) +d=dict(Counter(a)) +ans=sum(a) +q=int(input()) +for _ in range(q): + b,c=map(int,input().split()) + if b not in d.keys(): continue + ans+=(c*d[b]-b*d[b]) + print(ans) + if c in d.keys(): d[c]+=d[b] + else: d[c]=d[b] + d[b]=0" +p02848,s152386700,Accepted,"import sys + +def main(): + input = sys.stdin.readline + n = int(input()) + s = input().rstrip() + first = ord(""A"") - 1 + last = ord(""Z"") + increment = lambda x: chr(ord(x)+n) if ord(x)+n <= last else chr(first + (ord(x)+n - last)) + new_s = """".join(map(increment, s)) + print(new_s, end="""") + + + +if __name__ == '__main__': + main() +" +p02693,s139046051,Wrong Answer,"k = int(input()) +a,b = map(int,input().split()) + +wk = (b//k) +if wk*k >=a: + print('Ok') +else: + print('NG')" +p03456,s742945126,Accepted,"n = int(input().replace("" "", """")) +for i in range(1, 320): + if i**2 == n: + print(""Yes"") + break +else: + print(""No"")" +p03327,s515926705,Accepted,"n=int(input()) +print('ABC'if n<=999 else 'ABD' )" +p03544,s662489356,Accepted,"n = int(input()) +l1 = 2 +l2 = 1 +l = 1 +for i in range(n-1): + l = l1+l2 + l1, l2 = l2, l +print(l)" +p02584,s065686858,Wrong Answer,"x,k,d = [int(i) for i in input().split()] +ans = x%d + +if x > d and k <= x//d: + ans = x - k*d +else: + k = k-x//d + if k%2 == 0: + ans = x % d + elif k%2 == 1: + ans = d - x%d +print(ans)" +p03385,s969231368,Wrong Answer,"s = input() + +if s == ""abc"" or s == ""bac"" or s == ""cba"" or s == ""acb"": + print(""Yes"") +else: + print(""No"")" +p03773,s070525115,Accepted,"a,b = map(int,input().split()) +print((a+b)%24) +" +p02602,s310105784,Wrong Answer,"n,k=map(int, input().split()) +a=list(map(int, input().split())) + +sei=[0]*(n-k+1) +for i in range(n-k+1): + for j in range(i,i+k): + sei[i]+=a[j] + +for i in range(n-k): + if sei[i] int: + sum_ = 0 + for a in A: + sum_ ^= a + return sum_ + + +def main(N: int, A: List[int]): + sum_ = sum_xor(A) + for a in A: + print(a ^ sum_, end="""") + print() + + +if __name__ == ""__main__"": + N = int(input()) + A = list(map(int, input().split())) + main(N, A) +" +p02681,s808307972,Wrong Answer,"S = input(""Enter words: "") +T = input(""Enter another words: "") + +if S in T: + print(""Yes"") +else: + print(""No"") + " +p02601,s836797946,Accepted,"import itertools +x=list(map(int,input().split())) +k=int(input()) +L=list(itertools.combinations_with_replacement([0,1,2],k)) +for l in L: + X=x.copy() + for i in l: + X[i] = X[i]*2 + if X[0] b: + ans = 0 + else: + ans = b - (a+w) +elif a == b: + ans = 0 + +else: + if b+w > a: + ans = 0 + else: + ans = a - (b+w) + +print(ans)" +p03803,s538641386,Accepted," +def resolve(): + A, B = list(map(int, input().split())) + if A == B: + print(""Draw"") + return + if A == 1: + A = 14 + if B == 1: + B = 14 + + if A > B: + print(""Alice"") + else: + print(""Bob"") + + +if '__main__' == __name__: + resolve()" +p03435,s741551558,Accepted,"c = [list(map(int,input().split())) for _ in range(3)] + +e = c[0][1] - c[0][0] +f = c[0][2] - c[0][1] + +if any(e != c[x][1]-c[x][0] for x in [1,2]) or any(f != c[x][2]-c[x][1] for x in [1,2]) : + print('No') +else: + print('Yes')" +p03944,s766340564,Wrong Answer,"W, H, n = map(int, input().split()) + +one = 0 +two = W +three = 0 +four = H +for i in range(n): + x, y, a = map(int, input().split()) + if a == 1: + one = max(one, x) + elif a == 2: + two = min(two, x) + elif a == 3: + three = max(three, y) + elif a == 4: + four = min(four, y) + +w = W - (one + (W - two)) +h = H - (three + (H - four)) +print(max(0, w*h)) +" +p03761,s819235477,Accepted," +from sys import stdin + +n = int(stdin.readline().rstrip()) +s = [stdin.readline().rstrip() for i in range(n)] +d = {} +dl = [] +for i in range(26): + d.update({chr(i + 97): 0}) +for i in range(n): + dl.append(d.copy()) +for i in range(n): + for si in s[i]: + dl[i][si] += 1 +ans = '' +for al in range(26): + tmp = 10**9+7 + for i in range(n): + if tmp > dl[i][chr(al + 97)]: + tmp = dl[i][chr(al + 97)] + ans += (tmp * chr(al + 97)) + +print(ans)" +p02759,s067438641,Wrong Answer,"A = int(input()) +if A%2==1: + A = (A/2)+0.5 +else: + A =A/2 +print(A)" +p02756,s109965964,Accepted,"s=input() +n=len(""s"") +q=int(input()) +l=[] +start="""" +end="""" +m=0 +for i in range(q): + l.append(input()) + if l[i]==""1"": + m += 1 + + else: + due,f,c=l[i].split() + if (f==""1"" and m % 2==0) or (f !=""1"" and m % 2==1) : + start += c + else: + end += c +if m % 2 ==0: + + start=start[::-1] + s = start + s + end + +else: + s = s + end + s = s[::-1] + s = s + start + +print(s)" +p03038,s245515333,Wrong Answer,"n, m=map(int, input().split()) +a=list(map(int, input().split())) +change=[] + +for i in range(m): + b, c=map(int, input().split()) + change.append((c, b)) + +change=sorted(change, reverse=True) +elem=0 + +for c, b in change: + while elem0: + if a[elem] 1: + print(""NO"") + exit() +print(""YES"")" +p03433,s159818513,Wrong Answer,"N=int(input()) +A=int(input()) +ans=N%500 +if ans-A<=0: + print('YES') +else: + print('NO') +" +p02663,s996904059,Wrong Answer,"h1,m1,h2,m2,k=map(int,input().split()) +h3=h2-h1 +h3=h3*60+m1+m2 + +print(h3-k)" +p02556,s820363724,Accepted,"N = int(input()) +L = [tuple(map(int, input().split())) for _ in range(N)] +L.sort(key=lambda x: x[0]+x[1]) +a = abs(L[0][0]-L[-1][0])+abs(L[0][1]-L[-1][1]) +L.sort(key=lambda x: x[0]-x[1]) +b = abs(L[0][0]-L[-1][0])+abs(L[0][1]-L[-1][1]) +print(max(a, b)) +" +p02983,s465982588,Accepted,"L, R = map(int, input().split()) + +if R-L >= 2019: + print(0) + exit() + +for i in range(L,R+1,1): + if i%2019 == 0: + print(0) + exit() + +ans = 2018 +for i in range(L,R+1,1): + for j in range(i+1,R+1,1): + x = (i*j)%2019 + if x C[key]: + ans += C[key] + elif key < C[key]: + ans += C[key]-key +print(ans)" +p03407,s816820256,Accepted,"a,b,c = map(int, raw_input().split()) +print 'Yes' if a + b >= c else 'No'" +p03109,s521828017,Accepted,"S = input() + +if int(S[0:4]) < 2019 : + print(""Heisei"") +elif int(S[0:4]) == 2019 and int(S[5:7]) <= 4: + print(""Heisei"") +else: + print(""TBD"")" +p03281,s058895252,Accepted,"c = 0 +for i in range(1, int(input())+1): + if not i%2: + continue + if sum(not(i%j) for j in range(1, i+1))==8: + c += 1 +print(c)" +p02705,s893211078,Accepted,"r = int(input()) +print(2*r*3.14)" +p03012,s620817732,Accepted,"N=int(input()) +S=list(map(int,input().split())) + + +T=sum(S) +L=sum(S) +M=0 +U=[] +Q=T/2 +for i in range(len(S)): + M=M+S[i] + T=T-S[i] + L=min(L,abs(M-T)) +print(L)" +p02935,s013545444,Accepted,"N = int(input()) +A = list(map(int,input().split())) +A = sorted(A) +ans = A[0] + +for i in range(1,N): + ans = (ans + A[i])/2 + +print(ans)" +p03495,s024472787,Accepted,"n,k=map(int,input().split()) +a=list(map(int,input().split())) +from collections import Counter +cc=Counter(a) +l=[] +for i in cc: + l.append([cc[i],i]) +l.sort(key=lambda x: -x[0] ) +#print(l) +su=0 +for i in range(min(k,len(l))): + su+=l[i][0] +print(n-su) +" +p03557,s743662924,Wrong Answer,"import bisect + +n=int(input()) + +list_A=sorted(list(input().split(' '))) +list_B=sorted(list(input().split(' '))) +list_C=sorted(list(input().split(' '))) +ans=0 +for i in list_B: + a=bisect.bisect_left(list_A, i) + b=bisect.bisect_right(list_C, i) + ans += a*(n-b) +print(ans)" +p02612,s791265615,Wrong Answer,"n = int(input()) +x = 0 +for i in range(10) : + if 1000*i>n and x == 0: + x = i + +print(1000*x-n)" +p02633,s808967805,Accepted,"X=int(input()) +i=1 + +while True: + if X*i%360==0: + print(i) + break + i+=1" +p02660,s535421482,Wrong Answer,"n=int(input()) +start=n +ans=0 +for i in range(2,int((n+1)**0.5)): + if(n%i==0): + for j in range(1,100): + if(n%(i**j)==0): + ans+=1 + n/=i**j + else: + break + if(n==1): + break +if(n==start and start!=1): + ans+=1 +print(ans)" +p02818,s180361783,Accepted,"a,b,k=map(int,input().split()) +if k<=a:print(a-k,b) +elif k<=a+b:print(0,b-k+a) +else:print(0,0)" +p02705,s466851187,Accepted,"r = int(input()) + +import math + +print(math.pi*2*r)" +p04030,s044579268,Accepted,"s=input() +l=len(s) +a=[] +for i in range(l): + n=len(a) + if s[i]=='0': + a.append(0) + elif s[i]=='1': + a.append(1) + elif s[i]=='B': + if a!=[]: + del a[n-1] + +for i in range(len(a)): + print(a[i],end="""")" +p02630,s462279858,Accepted,"from collections import Counter +N=int(input()) +A=list(map(int,input().split())) +s=sum(A) +Q=int(input()) +cnt=Counter(A) +for _ in range(Q): + b,c=map(int,input().split()) + if b in cnt: + s-=cnt[b]*b + s+=cnt[b]*c + print(s) + if c in cnt: + cnt[c]+=cnt[b] + cnt[b]=0 + else: + cnt[c]=cnt[b] + cnt[b]=0 + else: + print(s)" +p02675,s601986806,Accepted,"N = int(input()) +L = [ + [2,4,5,7,9], + [0,1,6,8], + [3] +] +h = ['hon', 'pon', 'bon'] +for ll in range(len(L)): + if N % 10 in L[ll]: + print(h[ll]) + break" +p02957,s162651200,Accepted,"a,b=map(int,input().split()) + +if a>b and (a-b)%2==0: + print (int(b + (a-b)/2 )) +elif b>a and (b-a)%2==0: + print (int(a+(b-a)/2 )) +else: + print(""IMPOSSIBLE"") " +p03013,s365570510,Wrong Answer,"CONST = 10**9 + 7 +n,m = map(int,input().split()) + +dp = [-1 for _ in range(n+1)] +dp[0] = 1 +dp[1] = 2 +for _ in range(m): + a = int(input()) + dp[a] = 0 + if a == 0 and dp[1] ==2: + dp[1] = 1 + +for i in range(2,n): + if dp[i] == 0: + continue + dp[i] = (dp[i-1] + dp[i-2]) % CONST +print(dp[n])" +p03767,s579604120,Accepted,"n=int(input()) +a=list(map(int,input().split())) +a.sort() +print(sum(a[n:len(a):2]))" +p02687,s922302049,Accepted,"def main(): + s = input() + print(list(set([""ABC"", ""ARC""])-set([s]))[0]) + +if __name__ == ""__main__"": + main()" +p03705,s594666132,Accepted,"N,A,B = map(int, input().split()) + +"""""" +MIN: (N - 1) * A + B +MAX: A + (N - 1) * B + +MAX - MIN + 1 += (N - 1) * (B - A) - (B - A) + 1 += (N - 2) * (B - A) + 1 +"""""" + +if N == 1 and A != B: + print(0) +elif A > B: + print(0) +else: + print((B - A) * (N - 2) + 1)" +p02958,s329229235,Accepted,"n = int(input()) +P = list(map(int,input().split())) +cnt = 0 +for i in range(n): + if i+1!=P[i]: + cnt += 1 +print('YES' if cnt ==2 or cnt ==0 else 'NO')" +p03239,s721763101,Accepted,"N, T = map(int, input().split()) +c = [0] * N +t = [0] * N +for i in range(N): + c[i], t[i] = map(int, input().split()) + +z = zip(c, t) +z = sorted(z) +c, t = zip(*z) + +for i in range(N): + if t[i] <= T: + print(c[i]) + exit() +print('TLE') +" +p02773,s825952933,Accepted,"# coding: utf-8 + +def main(): + n = int(input()) + lines = [] + for i in range(0, n): + lines.append(input()) + + dct = {} + for l in lines: + if l in dct: + dct[l] += 1; + else: + dct[l] = 1; + + cmax = max(dct.values()) + + print('\n'.join(sorted([k for k,v in dct.items() if v == cmax]))) + +if __name__ == '__main__': + main() +" +p02711,s319274620,Accepted,"if input().count('7'): + print(""Yes"") + +else: + print(""No"") + +" +p03730,s121131458,Wrong Answer,"# -*- coding: utf-8 -*- +"""""" +Created on Tue Jun 2 21:44:35 2020 + +@author: naoki +"""""" +import fractions + +A, B, C = map(int,input().split()) # A,B,Cを入力 + +#不定方程式を解ければよい ax-by=c +#そのためにユークリッドの互除法を用いる +#gcd(a,b) = gcd(b,c) ならば不定方程式が成立する。そうでないならば成立しない。 +if fractions.gcd(A,B) == fractions.gcd(B,C): + print(""YES"") +else: + print(""NO"")" +p02842,s911064338,Accepted,"N = int(input()) +for i in range(1,50001): + tmp = int(i * 1.08) + if(tmp == N): + print(str(i)) + exit() +print("":("")" +p02743,s663456000,Wrong Answer,"from math import sqrt +A, B, C = map(int,input().split()) +if pow(A,0.5) + pow(B,0.5) < pow(C,0.5): + print(""Yes"") +else: + print(""No"")" +p03261,s166422358,Accepted,"n=int(input()) +a=[] +for i in range(n): + a.append(input()) +if len(a)!=len(set(a)): + print('No') + exit() +for i in range(n-1): + if a[i][-1]!=a[i+1][0]: + print('No') + exit() +print('Yes')" +p03416,s057435450,Accepted,"A,B = map(int,input().split()) +c = 0 +for i in range(A,B+1): + s = str(i) + k = True + for j in range(len(s)//2): + if s[j] != s[(j+1)*-1]: + k = False + break + if k: + c+=1 +print(c)" +p03486,s749705704,Wrong Answer,"print('yes' if sorted(input()) < sorted(input(), reverse=True) else 'No') +" +p04033,s980416499,Accepted,"a, b = [int(w) for w in input().split()] + +if a * b <= 0: + print(""Zero"") +elif a > 0: + print(""Positive"") +else: + if (a - b) % 2 == 0: + print(""Negative"") + else: + print(""Positive"") +" +p03251,s535149674,Accepted,"n,m,x,y = map(int, input().split()) +X = list(map(int, input().split())) +Y = list(map(int, input().split())) + +lower = max(X) +upper = min(Y) +ans ='War' + +for z_i in range(x+1,y+1): + if lower < z_i <= upper: + ans ='No War' + +print(ans)" +p02694,s516601008,Accepted,"import math + +x = int(input()) +k = 0 +p = 100 + +while p < x: + p = p + int(p/100) + k = k + 1 + +print(k) +" +p02597,s971476576,Accepted,"N = int(input()) +C = list(input()) +RtoW = sum(map(lambda x: x==""R"",C)) +WtoR = 0 +ans = RtoW +for i in range(N): + if C[i] == ""R"": + RtoW -= 1 + else: + WtoR += 1 + ans = min(ans,max(RtoW,WtoR)) + +print(ans)" +p04005,s713854184,Wrong Answer,"A, B, C = map(int, input().split()) + +if A*B*C%2==0: + print(0) +else: + big = max([A, B, C]) + print(round(A*B*C/big))" +p02916,s502529599,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +c=list(map(int,input().split())) + +bef=a[0]-1 +man=b[bef] + +for i in a[1:]: + ind=i-1 + if ind==bef+1: + man+=c[bef] + man+=b[ind] + bef=ind +print(man) +" +p03221,s787716770,Accepted,"n, m = map(int, input().split()) +Pre = [list(map(int, list(input().split()))) for i in range(m)] + +for i in range(1, m + 1): + Pre[i - 1].append(i) + +Pre.sort() + +cnt = 1 +Pre[0][1] = cnt +for i in range(1,m): + if Pre[i - 1][0] != Pre[i][0]: + cnt = 1 + Pre[i][1] = cnt + else: + cnt += 1 + Pre[i][1] = cnt + +Pre.sort(key=lambda x: x[2]) + +for i in range(m): + print(""{0:06d}{1:06d}"".format(Pre[i][0],Pre[i][1]))" +p03017,s255046880,Wrong Answer,"n,a,b,c,d = map(int, input().split()) +s = input() + +if '##' in s: + print('No') + exit() +else: + if c= a else a-1)" +p03145,s483191605,Wrong Answer,"a, b, c = map(int, input().split()) +print(a*b*0.5)" +p03103,s384499611,Wrong Answer,"import numpy as np + +N, M = map(int, input().split()) +a = [input().split() for i in range(N)] +a = [[int(i[0]), int(i[1])] for i in a] +a = np.array(a,dtype= 'int64') +a = a[a[:, 0].argsort(), :] + +sum = 0 +coin = 0 +for item in a: + if item[1] + sum < M: + sum += item[1] + coin += item[0] * item[1] + else: + for i in range(1, item[1] + 1): + if sum + i == M: + print(coin + item[0] * i) + break + + +" +p04020,s483372396,Accepted,"N = int(input()) +A = [int(input()) for i in range(N)] + +ans = 0 +t = 0 +for i in range(N): + if A[i] == 0: + ans += t // 2 + t = 0 + else: + t += A[i] +ans += t // 2 +print(ans) +" +p02687,s276876901,Accepted,"print('ABC' if input() == 'ARC' else 'ARC') +" +p03962,s623458939,Accepted,"print(len(set(list(map(int,input().split()))))) +" +p02742,s735243331,Accepted,"def resolve(): + H, W = [int(i) for i in input().split()] + if min(H, W) == 1: + print(1) + elif (H * W) % 2 == 0: + print(format(H * W // 2, ""d"")) + else: + print(format((H * W // 2) + 1, ""d"")) + + +resolve() +" +p03760,s680354188,Accepted,"o = list(input()) +e = list(input())+[""""] +#print(o,e) +for x,y in zip(o,e): + print(x+y,end="""") + + +" +p03282,s377360762,Accepted,"s=input() +k=int(input()) +for i in range(len(s)): + if s[i]==""1"": + k-=1 + else: + k-=int(s[i])*(5*10**18) + if k<=0: + print(s[i]) + exit()" +p03548,s891251726,Accepted,"X, Y, Z = map(int, input().split()) + +print((X - Z) // (Y + Z)) + +" +p03146,s428184129,Wrong Answer,"s=int(input()) +a=s +if s in [4,2,1]: + ans=3 +else: + ans=2 + for i in range(10**6): + if a==1: + break + if a%2==0: + a=a//2 + else: + a=3*a+1 + ans+=1 +print(ans)" +p02744,s974560293,Accepted,"N = int(input()) +alp = lambda c: chr(c+96) +def num(L,key): + if len(L) == N: + ans = [alp(a) for a in L] + print(''.join(ans)) + else: + for k in range(1,key+1): + l = L + [k] + num(l,key) + l = L + [key+1] + num(l, key+1) + +init =[1] +num(init,1)" +p03438,s939716078,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) +cp = 0 +cm = 0 +for i in range(N): + if A[i]>B[i]: + cm += A[i]-B[i] + elif B[i]>A[i]: + cp += (B[i]-A[i])//2 +if cp>=cm: + print(""Yes"") +else: + print(""No"")" +p02756,s649663263,Accepted,"S=input() +Q=int(input()) +c=0 +left="""" +right="""" +for i in range(Q): + T=list(map(str,input().split())) + if len(T)==1: + c+=1 + else: + if (T[1]==""1"" and c%2==0) or (T[1]==""2"" and c%2==1): + left+=T[2] + else: + right+=T[2] + +if c%2==0: + ans=left[::-1]+S+right +else: + ans=right[::-1]+S[::-1]+left +print(ans)" +p03221,s289848720,Accepted,"if __name__ == '__main__': + N, M = map(int, input().split()) + PY = [] + for i in range(1, M+1): + p, y = map(int, input().split()) + PY.append((y, p, i)) + PY.sort() + ANS = [""""]*(M+1) + P = [0]*(N+1) + for y, p, i in PY: + P[p] += 1 + ANS[i] = ""{0:06d}"".format(p) + ""{0:06d}"".format(P[p]) + + for ans in ANS: + if ans=="""": continue + print(ans)" +p03252,s235761942,Wrong Answer,"import collections + +S=input() +T=input() + +S_list=collections.Counter(S) +S_list1=list(S_list.values()) +S_list1=set(S_list1) + +T_list=collections.Counter(T) +T_list1=list(T_list.values()) +T_list1=set(T_list1) + +if S_list1==T_list1: + print('Yes') +else: + print('No')" +p02917,s105997148,Accepted,"n = int(input()) +b = list(map(int,input().split())) +ans = sum([min(b[i],b[i+1]) for i in range(n-2)]) +ans += b[0] + b[n-2] +print(ans)" +p02639,s277890726,Accepted,"x = list(map(int, input().split())) +print((x.index(0))+1)" +p02897,s131169309,Accepted,"import math + +n = int(input()) + +answer = (n - math.floor(n / 2)) / n + +print(answer) + +# nums = list(range(1, n + 1)) +# +# odds = [x for x in nums if x % 2 == 1] +# +# if len(nums) % 2 == 0: +# print(0.5) +# else: +# print(len(odds) / len(nums)) +" +p04034,s503213059,Accepted,"n,m = map(int, input().split()) +xy = [list(map(int, input().split())) for _ in range(m)] + +box = [1]*(n+1) +red = [0]*(n+1) +red[1] = 1 +for x,y in xy: + box[x] -= 1 + box[y] += 1 + if red[x]==1: red[y] = 1 + if box[x]==0: red[x] = 0 +print(sum(red))" +p02996,s657813612,Accepted,"N = int(input()) +lis = [] +for i in range(N): + lis.append(list(map(int,input().split()))) +lis = sorted(lis, key = lambda x:x[1]) +a = 0 +for j in range(N): + a += lis[j][0] + if a > lis[j][1]: + print('No') + exit() +print('Yes') +" +p02727,s381753101,Accepted,"x,y,a,b,c=map(int,input().split()) +l_r=sorted(map(int,input().split()),reverse=True)[:x] +l_b=sorted(map(int,input().split()),reverse=True)[:y] +l_w=sorted(map(int,input().split()),reverse=True) + +ans=[] +ans+=l_r +ans+=l_b +ans+=l_w + +print(sum(sorted(ans,reverse=True)[:x+y]))" +p02963,s305639314,Wrong Answer,"N = int(input()) + +if N <= 10**9: + List = [0,0,0,1,N,0] +else: + a = -(-N//(10**9)) + b = a*10**9-N + List = [0,0,10**9,b,a,1] + +print(*List)" +p02760,s542865062,Accepted,"a = [] +for i in range(3): + a += map(int, input().split()) + +n = int(input()) + +for i in range(n): + b = int(input()) + for j in range(9): + if b == a[j]: + a[j] = 'o' + +isBingo = False +bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6]] +for elem in bingo: + if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o': + isBingo = True + break + +print('Yes') if isBingo else print('No') +" +p02742,s696925722,Accepted,"h,w=(int(i) for i in input().split()) +if(h==1): + print(1) +elif(w==1): + print(1) +else: + if(h%2==0): + print((h//2)*w) + else: + print( (((h//2)+1)*w)-(w//2))" +p03555,s349699493,Wrong Answer,"C = str(input()) + +if C[0] == C[1]: + print('Yes') +else: + print('No')" +p03059,s192166369,Accepted,"A, B, T = map(int, input().split()) +print(B*(T//A)) +" +p02697,s155504865,Accepted,"import sys +input = lambda: sys.stdin.readline().rstrip(""\r\n"") + +n, m = map(int, input().split()) +if n % 2 == 0: + n -= 1 +ans = [] +left_range = n//2 +right_range = n//2 - 1 +left1 = 1 +right1 = 1 + left_range +left2 = right1 + 1 +right2 = left2 + right_range + +while True: + if left1 >= right1: + break + ans.append([left1, right1]) + left1 += 1 + right1 -= 1 + +while True: + if left2 >= right2: + break + ans.append([left2, right2]) + left2 += 1 + right2 -= 1 + +for i in range(m): + print(*ans[i]) + + +" +p02963,s643373112,Wrong Answer,"s=int(input()) +ans1=s//10**9+1 +ans2=10**9-s%10**9 +print(0,0,10**9,ans1,ans2,1)" +p03479,s984548876,Accepted,"x, y = map(int, input().split()) +num = 0 +while x <= y: + x *= 2 + num += 1 +print(num)" +p03328,s499182219,Accepted,"a, b = map(int, input().split()) + +c = b-a +res = sum(i for i in range(c)) +print(res-a)" +p03241,s294492700,Wrong Answer,"n, m = map(int, input().split()) +for i in range(m//n, 0, -1): + rem = m-m//n*n + if rem%i==0: + print(i) + break" +p03387,s718550874,Accepted,"a = list(map(int, input().split())) +a.sort(reverse = True) +if (a[1]+a[2])%2 ==1: + print(int(2 + a[0]-(a[1]+a[2]+1)/2)) +else: + print(int(a[0]-(a[1]+a[2])/2))" +p02843,s726888875,Wrong Answer,"X=int(input()) +N=X%100 +if N//5+1<=X//100: + print('1') +else: + print('0')" +p03317,s403245117,Accepted,"n,k = map(int,input().split()) +a = list(map(int,input().split())) +s = k +i = 1 +while n > s: + s += (k-1) + i += 1 + +print(i)" +p03109,s312467694,Accepted,"print('Heisei'if input()[5:]<'04/31'else'TBD') +" +p02691,s658159735,Accepted,"N = int(input()) + +A = list(map(int, input().split())) + +L = [] +R = [] + +for i in range(N): + L.append(i+1 + A[i]) + R.append(i+1 - A[i]) + +L.sort() +R.sort() + +#print(L) +#print(R) + +temp = 0 +ans = 0 +j = 0 +for i in range(N): + if i >= 1 and L[i] == L[i-1]: + ans += temp + continue + temp = 0 + while j < N and L[i] >= R[j]: + if L[i] == R[j]: + temp += 1 + j += 1 + ans += temp + +print(ans)" +p03699,s552082050,Wrong Answer,"n = int(input()) + +a = [] +b = [] +for i in range(n): + s = int(input()) + if s%10 == 0: + a.append(s) + else: + b.append(s) + +b = sorted(b,reverse = True) +if len(b) == 0: + print(0) +elif len(b)%2 == 0: + print(sum(a)+sum(b[:len(b)-1])) +else: + print(sum(a)+sum(b))" +p03161,s644608910,Accepted,"N,K = map(int,input().split()) +h = list(map(int,input().split())) +dp = [10**15+1 for i in range(N)] +dp[0] = 0 +for i in range(N): + for j in range(1,K+1): + if i+j> i) & 1 + count0 = np.count_nonzero(a) + count1 = N - count0 + tmp = 2**i + n = count0 * count1 + tmp = tmp * n + ans += tmp + ans = ans % MOD +print(ans)" +p02594,s735596961,Accepted,"X = int(input()) +if X >= 30: + print('Yes') +else: + print('No') " +p03386,s763883692,Wrong Answer,"def myAnswer(A:int,B:int,K:int) -> int: + if(B >= K): + ans = [i for i in range(A,A+K)] + for i in range(B,B-K,-1): + ans.append(i) + else: + ans = [i for i in range(A,B+1)] + ans = list(set(ans)) + ans.sort() + for a in ans: + print(a) + + + +def modelAnswer(): + tmp=1 +def main(): + A,B,K = map(int,input().split()) + myAnswer(A,B,K) + +if __name__ == '__main__': + main()" +p02910,s020600145,Accepted,"s = input() +ans = 0 +for i in range(len(s)): + if i % 2 ==0 : + if s[i] == ""L"": + ans += 1 + else: + if s[i] == ""R"": + ans += 1 +if ans == 0: + print('Yes') +else: + print('No') +" +p03251,s282576795,Wrong Answer,"n,m,X,Y=map(int,input().split()) +x=list(map(int,input().split())) +y=list(map(int,input().split())) +x.append(X) +y.append(Y) +if max(x)<=min(y): + print(""No War"") +else: + print(""War"")" +p04031,s885702660,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) +sa = min(A) +ba = max(A) +ma1 = (ba + sa-1) // 2 +ma2 = (ba + sa) // 2 +ma3 = (ba + sa+1) // 2 +ans1 = 0 +ans2 = 0 +ans3 = 0 +for i in A: + ans1 += (i-ma1)**2 + ans2 += (i-ma2)**2 + ans3 += (i-ma3)**2 +print(min(ans1, ans2, ans3))" +p02624,s169214117,Accepted,"N = int(input()) +ans = N * (N + 1) // 2 +ans = 2 * ans - 1 +if N == 1: + print(ans) + exit() +for i in range(2, N // 2 + 1): + M = N - (N % i) + ans += (i + M) * (M // i) // 2 + ans -= i +print(ans)" +p03545,s014958683,Accepted,"from itertools import product + +A, B, C, D = map(int, input()) + +for operators in product(('+', '-'), repeat=3): + a = A + b = B + c = C + d = D + if operators[0] == '-': + b *= -1 + if operators[1] == '-': + c *= -1 + if operators[2] == '-': + d *= -1 + + if a + b + c + d == 7: + print('{}{}{}{}{}{}{}=7'.format(A, operators[0], B, operators[1], C, operators[2], D)) + break +" +p03077,s110234427,Accepted,"n = int(input()) +time = [int(input()) for _ in range(5)] +count = 0 +if all([i >= n for i in time]): + print(5) +else: + smallest = min(time) + smallest_index = time.index(smallest) + count += n // smallest + if n % smallest != 0: + count += 1 + print(count + 4) +" +p03012,s277367202,Wrong Answer,"n = int(input()) +ws = list(map(int, input().split())) + +full = sum(ws) +half = full / 2 +total = 0 + +for i in range(n): + total += ws[i] + if total >= half: + total_plus = total + ws[i + 1] + dif = abs(total - (full - total)) + dif_plus = abs(total_plus - (full - total_plus)) + print(min(dif, dif_plus)) + exit()" +p02783,s707869022,Accepted,"a,b=(int(x) for x in input().split()) +sum=0 +while a>0: + a-=b + sum+=1 +print(sum)" +p02624,s852614609,Wrong Answer,"n = int(input()) +board = [1] * (n+1) + +def divisor_num(n, board): + for i in range(2, n+1): + j = 1 + while i*j <= n: + board[i*j] += 1 + j += 1 + +divisor_num(n, board) +res = sum([i * board[i] for i in range(1, n+1)]) +print(board) +" +p02622,s007693721,Wrong Answer,"s=input() +t = input() +count = 0 +for i in range(len(s)): + if s[i]!=t[i]: + count += 1" +p02946,s649429986,Wrong Answer,"n,k=map(int,input().split()) +s1=set() +s2=set() +for i in range(n): + s1.add(k-i) +for j in range(n): + s2.add(k+j) +print("" "".join(map(str,s1|s2)))" +p02546,s814241366,Accepted,"s = input() + +if s[-1] == 's': + s= s + 'es' +else: + s= s + 's' + +print(s)" +p02996,s341861273,Wrong Answer,"n = int(input()) +Jobs = [] +for i in range(n): + Jobs.append(list(map(int, input().split()))) + +Jobs.sort(key=lambda x: x[1], reverse=True) +#print(Jobs) +now = Jobs[0][1] +for time, deadline in Jobs: + if now < deadline: + now -= time + else: + now = deadline + now -= time + #print(now) +if now < 0: + print(""NO"") +else: + print(""YES"")" +p03644,s347884456,Wrong Answer,"num = int(input()) + +count_max = 0 +for i in range(num): + tmp = i + 1 + count = 0 + while tmp % 2 == 0: + tmp = tmp / 2 + count += 1 + if count > count_max: + count_max = count + +print(count_max)" +p02615,s977669478,Wrong Answer,"n = int(input()) +lst = [int(i) for i in input().split()] + +list.sort(lst) +lst2 = [] +total = 0 +for i in range(n): + num = lst[i] + if not lst2: + lst2.append(num) + if len(lst2) == 1: + total += lst2[0] + lst2.append(num) + if len(lst2) == 2: + total += lst2[1] + lst2.pop(1) + lst2.append(num) +print(total)" +p02859,s913214529,Accepted,"def main(): + r = int(input()) + print(r ** 2) + + +if __name__ == ""__main__"": + main() +" +p03795,s742212435,Accepted,"n = int(input()) +x = 800 * n +y = 200 * (n // 15) +print(x - y)" +p03861,s483821783,Wrong Answer,"a, b, x = map(int, input().split()) + +# a = p * x + r, b = q * x + s と剰余を使って表す +p = a // x +q = b // x + +res = p - q +print(res) +" +p02665,s401557754,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a_min = [0] * (n + 1) +a_min[n] = a[n] +for i in range(n - 1, -1, -1): + a_min[i] = a[i] + a_min[i + 1] + +b = [1] +for i in range(n): + tmp = b[i] - a[i] + b.append(min(tmp * 2, a_min[i + 1])) + if tmp < 1 or tmp * 2 < a[i + 1]: + print(-1) + break +else: + if n == 0: + ans = 1 if a[0] == 1 else -1 + print(ans) + else: + print(sum(b)) +" +p03360,s950205950,Accepted,"#!/usr/bin/env python3 + +n_list = list(map(int, input().split())) +K = int(input().split()[0]) + +n_list = list(sorted(n_list, reverse=True)) +n = n_list[0] +for _ in range(K): + n = n * 2 +ans = n + n_list[1] + n_list[2] +print(ans) +" +p03986,s474097980,Wrong Answer,"from collections import Counter +import sys +x = input() +n = len(x) +a = [] + +for i in range(n-1): + if x[i] == ""T"" and x[i+1] == ""S"": + a.append(i+1) + +a = [0] + a + [n] + +ans = 0 +for i in range(len(a)-1): + q = a[i+1]-a[i] + b = Counter(x[:q]) + ans += abs(b[""S""] - b[""T""]) + x = x[q:] + +print(ans)" +p02665,s292192962,Accepted,"from itertools import accumulate + +n = int(input()) +a = list(map(int, input().split())) + +if n == 0: + print(1 if a[0] == 1 else - 1) + exit() + +if a[0] != 0: + print(-1) + exit() + +b = list(accumulate(a)) +v = 1 +cnt = 1 +for i in range(n): + if (v - a[i]) * 2 - a[i + 1] < 0: + print(-1) + exit() + v = min((v - a[i]) * 2, b[-1] - b[i]) + cnt += v +print(cnt)" +p03339,s677971652,Accepted,"n=int(input()) +s=input() +cnt=s[1:].count('E') +ans=cnt +for i in range(1,n): + if s[i] == 'E': + cnt-=1 + if s[i-1] == 'W': + cnt += 1 + ans = min(ans,cnt) +print(ans) +" +p02595,s670571655,Accepted,"N,D=map(int,input().split()) + +ans=0 +for i in range(N): + a,b=map(int,input().split()) + temp=a**2+b**2 + if temp**0.5<=D: + ans+=1 +print(ans) + +" +p03644,s927750165,Accepted,"N = int(input()) + +b = 0 + +while True: + if N >= 2: + N /= 2 + b += 1 + if N < 2: + break + +print(2 ** b) +" +p04033,s533432468,Accepted,"# -*- coding: utf-8 -*- + +a, b = map(int, input().split()) + +if 0 < a <= b: + ans = 'Positive' +elif a <= b < 0: + if (b - a + 1) % 2 == 0: + ans = 'Positive' + else: + ans = 'Negative' +else: + ans = 'Zero' + +print(ans) +" +p03565,s300320633,Accepted,"import sys + + +Sp = [c for c in input()] +T = [c for c in input()] + +sn = len(Sp) +tn = len(T) + +match_i = 51 +for i in range(sn - tn + 1): + partial = Sp[i:i+tn] + for j in range(len(partial)): + if partial[j] == '?': + partial[j] = T[j] + if partial == T: + match_i = i + +if match_i > 50: + print('UNRESTORABLE') + sys.exit() + +Sp[match_i:match_i+tn] = T +for i in range(sn): + if Sp[i] == '?': + Sp[i] = 'a' +S = ''.join(Sp) + +print(S)" +p02628,s850550355,Wrong Answer,"N,K=map(int,input().split()) +ans=0 +p=list(map(int,input().split())) + +p.sort() + +for i in range(K): + ans+=p[i] + + print(ans) +" +p03086,s683701465,Accepted,"S = input() +def check(S): #1 moji + if S in ""ATGC"": + return True + else: + return False + +ans =0 +for i in range(len(S)): + temp = 0 + while i 0: + r = x % 10 + x = x // 10 + if r in d: + ans += 1 + flag = 0 + break + if flag == 1: + break +print(ans) +" +p02882,s623266337,Wrong Answer,"from math import atan +from math import degrees + +a, b, x = [int(x) for x in input().split()] + +volume = a * a * b +volume_per = x / volume + +print(volume_per) + +if volume_per >= 0.5: + up = b * (1 - volume_per) + down = a / 2 +else: + up = b + down = 2 * a * volume_per + +print(degrees(atan(up/down))) +" +p02657,s641261561,Accepted,"a, b = map(int, input().split(' ')) +print(a*b)" +p02948,s888023262,Accepted,"n, m = map(int, input().split()) +ab = [[] for _ in range(m+1)] +for i in range(n): + t = [int(inp) for inp in input().split()] + if t[0] <= m: + ab[t[0]].append(-t[1]) +ans = 0 +import heapq +h = ab[1] +heapq.heapify(h) +for i in range(1, m+1): + if len(h) > 0: + ans += heapq.heappop(h) + if i != m: + for t in ab[i+1]: + heapq.heappush(h, t) +print(-ans)" +p02729,s004800544,Accepted,"#!/usr/bin/env python3 +m, n = map(int, input().split()) +print((m * (m-1) + n * (n - 1)) // 2)" +p02547,s465260008,Wrong Answer,"n=int(input()) +cnt=0 +ans=0 +for i in range(n): + d,e=map(int,input().split()) + if d!=e: + if cnt==3: + ans=0 + break + cnt=1 + else: + cnt+=1 + if cnt==3: + ans=1 + break +if cnt>=3: + ans=1 +if ans==1: + print(""Yes"") +else: + print(""No"") +" +p03107,s606740283,Accepted," +S = input() + +dic = [0,0] + +for i in S: + + dic[int(i)] += 1 + +print (min(dic)*2) +" +p02983,s587267891,Wrong Answer,"l,r = map(int,input().split()) +x = l%2019 +y = min(r,l+2018)%2019 +if x=0: + lmap[s[i]]-=1 + rmap.add(s[i]) + if lmap[s[i]]==0: + del lmap[s[i]] + x = len(lmap) + if x==len(rmap): + #print(i,end=',') + lmax = max(lmax,x) + i-=1 +print(lmax)" +p03698,s885074487,Wrong Answer,"# -*- coding: utf-8 -*- +prev = '-' +for c in list(input()): + if c == prev: + print('no') + quit() + else: + prev = c +else: + print('yes')" +p03548,s149743773,Accepted,"x, y, z = map(int, input().split()) +print((x-z) // (y+z)) +" +p03282,s620433306,Accepted,"import sys + + +def input(): + return sys.stdin.readline().rstrip() + + +def main(): + S = input() + K = int(input()) + + i = 0 + + for i in range(K): + if S[i]==""1"": + continue + else: + print(S[i]) + exit() + print(1) + + +if __name__ == ""__main__"": + main() +" +p03994,s275999630,Accepted,"import string +abc = string.ascii_lowercase +s = list(input()) +K = int(input()) +index = 0 +while K > 0: + if index == len(s) - 1: + s[index] = abc[(abc.index(s[index]) + K) % 26] + break + tmp = 26 - abc.index(s[index]) + if tmp == 26: + index += 1 + continue + if K >= tmp: + s[index] = 'a' + index += 1 + K -= tmp + else: + index += 1 + +for i in s: + print(i, end='')" +p02661,s517564018,Wrong Answer,"n = int(input()) +x = [list(map(int,input().split())) for i in range(n)] + +if n%2==0: + print(int((x[(n//2)][-1]-x[(n//2)-1][0])//0.5)-1) +else: + tmp = x[n//2] + print(len(range(tmp[0], tmp[-1]+1)))" +p03282,s636867122,Accepted,"s=input() +k=int(input()) +if s.count('1') == len(s): + print(1) +else: + count = 0 + for i in s: + if i != '1': + print(i) + break + else: + count+=1 + if count == k: + print(1) + break +" +p02719,s883848378,Accepted,"def c_replacing_integer(): + N, K = [int(i) for i in input().split()] + return min(N % K, K - (N % K)) + +print(c_replacing_integer())" +p03262,s792266873,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import fractions +from functools import reduce +n,x = map(int,input().split()) +x_list = list(map(int,input().split())) +if n == 1: + print (abs(x_list[0]-x)) + exit (0) + +def gcd_list(numbers): + return reduce(fractions.gcd, numbers) + +y_list = [] +for i in x_list: + y_list.append(abs(i-x)) + +print (gcd_list(y_list))" +p03001,s533724425,Accepted,"W,H,x,y=map(int,input().split()) +if x==W/2 and y==H/2: + c=1 +else: + c=0 +print(W*H/2,c)" +p02983,s810116065,Accepted,"l, r = map(int, input().split()) +m = 2019 +if r - l >= 673: + print(0) +else: + ans = 2018 + l = l%m + r = r%m + for i in range(l, r): + for j in range(i+1, r+1): + ans = min(ans, (i*j)%m) + print(ans)" +p03943,s361420717,Accepted,"a, b, c = map(int, input().split()) +C = a + b +A = b + c +B = c + a + +if a == A or b == B or C == c: print(""Yes"") +else: print(""No"") +" +p03592,s289116750,Wrong Answer,"n,m,k = map(int,input().split()) + +def hantei(n,m,k): + for i in range(1,n+1): + for j in range(1,m+1): + if i*m + j*(n-2*i)==k: + return True + return False + +print(""Yes"" if hantei(n,m,k) else ""No"") +" +p03062,s354685185,Accepted,"import bisect +n = int(input()) +lis = list(map(int, input().split())) +lis = sorted(lis) + +a = bisect.bisect(lis, 0) +su = 0 +mi = 10**10 + +for b in lis: + su += abs(b) + mi = min(mi, abs(b)) + +if a % 2 == 0: + print(su) +else: + print(su - 2 * mi) +" +p04034,s403579191,Wrong Answer,"# agc002_b.py +N, M = map(int,input().split()) +flg = [False]*N +flg[0] = True +cnt = [1]*N +for i in range(M): + x, y = map(int,input().split()) + if not flg[x-1]: + continue + if cnt[x-1]>1: + flg[y-1] = True + elif cnt[x-1]==1: + flg[y-1] = True + flg[x-1] = False + else: + continue + cnt[x-1]-=1 + cnt[y-1]+=1 + +print(flg.count(True))" +p02787,s250724548,Wrong Answer,"import numpy as np + +H, N = map(int, input().split()) +AB = np.array([list(map(int, input().split())) for _ in range(N)]) + +INF = 10**7 + 2 +dp = np.full(2 * 10**4 + 2, INF, np.int32) +dp[0] = 0 + +for a, b in AB: + for _ in range(H // a): + prev = dp.copy() + np.minimum(dp[a:], prev[:-a] + b, out=dp[a:]) + +print(np.min(dp[H:])) +" +p02882,s365575478,Wrong Answer,"import math +a,b,x=map(int,input().split()) +v = a * b +x = x / a +if x < v/a: + c = x * 2 / b + d = math.sqrt(b * b + c * c) + print(math.degrees(math.asin(b/d))) +else: + rest = v - x + c = rest * 2 / a + d = math.sqrt(a * a + c * c) + print(math.degrees(math.acos(a/d)))" +p03943,s718438434,Accepted,"x=list(map(int,input().split())) +x.sort() +if x[0]+x[1]==x[2]: + print(""Yes"") +else: + print(""No"")" +p02727,s950414876,Accepted,"x, y, a, b, c = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) + +A.sort(reverse=True) +A = A[:x] +B.sort(reverse=True) +B = B[:y] + +AB = A + B +AB.sort(reverse=True) +total = sum(AB) +C.sort() + +while AB and C: + point = AB.pop() + candidate = C.pop() + if candidate > point: + total += candidate - point + else: + break + +print(total) +" +p03644,s790011257,Wrong Answer,"n = int(input()) +count = 0 +max = 0 +for i in range(1, n+1): + while(i%2 ==0): + i = i/2 + count +=1 + if(max < count): + max = count + count = 0 +print(2**max)" +p02771,s110557411,Wrong Answer,"a = input().split() +if a[0] == a[1] and a[0] == a[2]: + print(""No"") +else: + print(""Yes"")" +p03760,s520350357,Accepted,"o = input() +e = list(input())+[""""] + +for i, j in zip(o, e): + print(i+j, end="""")" +p02823,s856273883,Accepted,"N,A,B = map(int,input().split()) +if((B-A+1)%2==1): + print((B-A)//2) +else: + print(min(A-1,N-B)+1+(B-A-1)//2)" +p03360,s686967581,Accepted,"A, B, C = sorted([int(i) for i in input().split()]) +K = int(input()) +print(A + B + (C * (2**K))) +" +p03345,s645129945,Accepted,"a, b, c, k = map(int, input().split()) +if k % 2 == 0: + print(a-b) +else: + print(b-a)" +p02677,s364927296,Accepted,"import sys +import math + +A, B, H, M = map(int, input().split()) + +cA = 360*H/12 + 30 * M/60 +cB = 360*M/60 +cC = abs(cA - cB) +if cC > 180: + cC = 360 - cC + +coscC = math.cos(math.radians(cC)) +C = A**2 + B**2 - 2 * A*B*coscC + +print(C**(1/2)) +" +p04012,s875524629,Wrong Answer,"w = list(input()) +w = sorted(w) +flag = True +print(w) +for i in range(0,len(w)-1,2): + print(i) + if w[i]!=w[i+1]: + flag = False + break +if flag and len(w)%2==0: + print('Yes') +else: + print('No')" +p02790,s604471235,Accepted,"a, b = [int(i) for i in input().split()] + +list = [str(a)*b, str(b)*a] +list = sorted(list) + +print(list[0]) +" +p02576,s270437990,Wrong Answer,"n,x,t = (int(x) for x in input().split()) + +print( t * ( n//x + 1 ) )" +p02690,s661830347,Accepted,"X = int(input()) + +M = 21148 + +ns = [i**5 for i in range(M)] +n5s = {i**5:i for i in range(M)} + +result = None +for i in range(M): + b = ns[i] + if b + X in n5s: + result = n5s[b + X], i + if X - b in n5s: + result = i, -n5s[X - b] + +print(*result) +" +p03711,s354804624,Accepted,"x, y = map(int, input().split()) +a = [2] +b = [4, 6, 9, 11] +c = [1, 3, 5, 7, 8, 10, 12] +if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): + print(""Yes"") +else: + print(""No"")" +p03387,s707996624,Wrong Answer,"A,B,C = map(int, input().split()) + +ret = 0 + +if not (A%2 == B%2 and B%2 == C%2): + # どれか一つにイレギュラーがある + ret += 1 + if A%2 == B%2: + A += 1 + B += 1 + else: + B += 1 + C += 1 + +# print(A,B,C) +max_elem = max(A,B,C) +ret += (max_elem-A)//2 + (max_elem-B)//2 + (max_elem-C)//2 + +print(ret)" +p02973,s391821265,Wrong Answer,"import bisect +N = int(input()) +nums = [] + +for i in range(N): + num = int(input()) + if i == 0: + nums.append(num) + else: + if nums[-1] < num: + nums[-1] = num + else: + insert_index = bisect.bisect_left(nums, num) + if insert_index == 0: + nums.insert(0, num) + else: + nums[insert_index] = num +# print(nums) +# print(nums) +print(len(nums)) +" +p02771,s774210448,Accepted,"a,b,c=map(int,input().split()) +A=[a,b,c] +B=len(set(A)) +if B==2: + print('Yes') +else: + print('No')" +p02724,s969624267,Accepted,"x=int(input()) +a=x//500 +b=x%500 +c=b//5 +print(1000*a+5*c)" +p02933,s100198469,Wrong Answer,"a = int( input() ) +s = input() +if a < 3200: + print( s ) +else: + print( ""red"" )" +p02987,s643505734,Accepted,"import sys +input = sys.stdin.readline + +def main(): +# A,B = map(int, input().split()) + S = input().rstrip() + SS = sorted(S) + + result = 'No' + if SS[0] == SS[1]: + if SS[2] == SS[3]: + if SS[0] != SS[2]: + result = 'Yes' + print(result) + +if __name__ == ""__main__"": + main()" +p02946,s872328424,Wrong Answer,"K, X = map(int, input().split()) +for x in range(X-K+1,X+K-1): + print(x, end="" "")" +p03001,s114146166,Accepted,"w,h,x,y = map(int, input().split()) +if (x,y) == (w/2, h/2): print(w*h/2, 1) +else: print(w*h/2, 0)" +p02603,s836193025,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +assets = 1000 +for i in range(n - 1): + if a[i] < a[i + 1]: + assets = assets//a[i] * a[i + 1] + assets%a[i] +print(assets)" +p02784,s938043972,Accepted,"import sys +input = sys.stdin.readline + +H,N = map(int, input().split()) +A = list(map(int,input().split())) + +print(""Yes"" if sum(A)>=H else ""No"")" +p02951,s764017923,Accepted,"a,b,c = map(int, input().split()) + +tmp = a-b + +if tmp <= c: + print(c-tmp) +else: + print(0)" +p02628,s471903628,Wrong Answer,"import sys + +n, k = map(int, input().split()) +p = list(map(int,input().split())) + +if k < 3: + print(sum(p)) + sys.exit() + +p.sort() + +print(p[0] + p[1] + p[2])" +p03627,s427297687,Accepted,"import heapq +N = int(input()) +A = list(map(int, input().split()))+[0]*4 +A = list(map(lambda x: x*(-1), A)) +heapq.heapify(A) +a, b = -10**18, -10**18 +while True: + x = heapq.heappop(A) + if a == x: + break + else: + a = x +while True: + x = heapq.heappop(A) + if b == x: + break + else: + b = x +print(a*b)" +p02708,s845282273,Accepted,"import sys + +input = sys.stdin.readline + +P = 10 ** 9 + 7 + + +def main(): + N, K = map(int, input().split()) + + ans = 0 + for k in reversed(range(1, (N+1)+1)): + a = (N + (N-k+1))*k//2 + b = k*(k-1)//2 + ans += a - b + 1 + ans %= P + + if k == K : + break + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03720,s591556099,Accepted,"n,m=map(int,input().split()) +l=[[] for _ in range(n)] +for i in range(m): + a,b=map(int,input().split()) + l[a-1].append(b-1) + l[b-1].append(a-1) +for l1 in l: + print(len(l1))" +p02697,s947183876,Accepted," + +def main(): + N, M = map(int, input().split()) + skip = (N // 2) // 2 + 1 if N % 2 == 0 else None + count = 0 + left, right = 0, N + 1 + while count < M: + left += 1 + if left == skip: + continue + right -= 1 + print(left, right) + count += 1 + + +if __name__ == '__main__': + main() +" +p03160,s540456517,Wrong Answer,"n = int(input()) +h = [int(x) for x in input().split()] +inf = float('inf') +dp = [inf] * n # initialize dp +dp[0] = 0 +for i in range(1, n): + if i == 1: + dp[i] = abs(h[i] - h[i-1]) + elif abs(dp[i-1] + h[i] - h[i-1]) < abs(dp[i-2] + h[i] - h[i-2]): + dp[i] = dp[i-1] + abs(h[i] - h[i-1]) + else: + dp[i] = dp[i-2] + abs(h[i] - h[i-2]) +print(dp[-1])" +p03013,s803116888,Accepted," +n,m=map(int,input().split()) +a = [int(input()) for _ in range(m)] + +mod=10**9+7 +dp=[0]*(n+1) +dp[0]=1 +NG=[False]*n +for i in range(m): + NG[a[i]-1]=True + +for i in range(1,n+1): + if NG[i-1]==False: + dp[i]=(dp[i-2]+dp[i-1])%mod +print(dp[-1]) + +"""""" +#DP問題 +"""""" +" +p03077,s480154431,Accepted,"n=int(input()) +from math import ceil +a,b,c,d,e=[int(input()) for i in range(5)] +print(max( ceil(n/a),ceil(n/b),ceil(n/c),ceil(n/d),ceil(n/e), )+4)" +p02917,s800868947,Accepted,"def i(): + return int(input()) +def i2(): + return map(int,input().split()) +def s(): + return str(input()) +def l(): + return list(input()) +def intl(): + return list(int(k) for k in input().split()) + +n = i() +b = intl() + +a = b[0] + b[-1] +for i in range(n-2): + a += min( b[i], b[i+1] ) +print(a)" +p02862,s018548846,Accepted,"X,Y=map(int,input().split()) +mod=pow(10,9)+7 +m=(2*X-Y)//3 +n=(2*Y-X)//3 +if m!=(2*X-Y)/3 or n!=(2*Y-X)/3 or m<0 or n<0: + print(0) + +else: + bunsi = 1 + bunbo = 1 + for i in range(0, n): + bunsi = (bunsi * (m + 1 + i)) % mod + bunbo = (bunbo * (1 + i)) % mod + print((bunsi * pow(bunbo, mod - 2, mod)) % mod)" +p03327,s544890344,Wrong Answer,"n = int(input()) +print('ABC') if n > 0 and n < 100 else print('ABD')" +p03338,s177425304,Wrong Answer,"N=int(input()) +S=input() + +ans=1 + +for i in range(1,N): + X=S[:i] + Y=S[i:] + setX=set(X) + setY=set(Y) + intersectionXY=setX & setY + _temp=len(intersectionXY) + if _temp>ans: + ans=_temp + else: + pass +print(ans)" +p02663,s476654067,Wrong Answer,"H1, M1, H2, M2, K = [int(s) for s in input().split()] +if H2 < H1: + H2 += 24 +elif H2 == H1 and M1 > M2: + H2 += 24 +print(H2 * 60 + M2 - H1 * 60 + M1 - K) +" +p03067,s747848025,Wrong Answer,"a,b,c = map(int, input().split()) +print('Yes' if ab+w: + print(a-b-w) +elif a+w>b: + print(0) +else: + print(b-a-w)" +p02689,s638886113,Accepted,"import collections + +n,m = map(int, input().split()) +h = list(map(int, input().split())) + +gb = [1]*n; +for i in range(m): + a,b = map(int, input().split()) + a -= 1 + b -= 1 + if h[a] == h[b]: + gb[a] = 0 + gb[b] = 0 + + elif h[a] max1: + max1 = s + + if max1 > s > max2: + max2 = s + +for index, i in enumerate(li): + s = max(li) + + if s == li[index]: + print(max2) + else: + print(max1)" +p02817,s756143240,Accepted,"a, b = input().split() +print(b+a)" +p03449,s636322542,Wrong Answer,"N = int(input()) +h = list(map(int, input().split())) +l = list(map(int, input().split())) +c = h[0] + +for i in range(N): + if sum(h[i+1:])+l[N-1] < sum(l[i:]): + c += sum(l[i:]) + print(c) + exit() + elif i == N-1: + c += l[N-1] + print(c) + exit() + else: + c += h[i+1]" +p02582,s038108402,Accepted,"S = input() +# RC = S.count('R') +# if S[1] == 'S' and RC == 2: + # print(1) +# else: + # print(RC) + +rs = S.split('S') +ans = 0 +for r in rs: + ans = max(ans, len(r)) +print(ans) +" +p02608,s673252133,Wrong Answer,"n = int(input()) +ans = [0 for i in range(n)] + + +for i in range(101): + for j in range(101): + for k in range(101): + a = i*i +j*j + k*k + i*j +j*k + k*i + if a < n: + ans[a]+=1 +for i in ans: + print(i)" +p02823,s019937275,Wrong Answer,"N,A,B = map(int,input().split()) +n = B - A +if n % 2 == 0: + print(n//2) +else: + print(min(B-1,N-2))" +p02608,s674714207,Wrong Answer,"n = int(input()) +ans = [0 for _ in range(n)] +for i in range(1,32): + for j in range(1,32): + for k in range(1,32): + s = i**2 + j**2 + k**2 +i*j + j*k + k*i + if s <= n: + ans[s-1] += 1 +for i in range(n): + print(ans[i])" +p02897,s024601059,Wrong Answer,"n=int(input()) +print(1/n)" +p03645,s416703551,Wrong Answer,"n,m = map(int,input().split()) +l = [] +for _ in range(m): + a,b = map(int,input().split()) + l.append([a,b]) + +for x in l: + if x[0] == 1: + for y in l: + if y[1] == n: + print (""POSSIBLE"") + exit () +print (""IMPOSSIBLE"") +" +p03495,s670767366,Accepted,"from collections import defaultdict +N, K = map(int, input().split()) +A = list(map(int, input().split())) + +d = defaultdict(int) +for i in range(N): + d[A[i]] += 1 + +cnt = len(d.keys()) - K +d = sorted(d.items(), key=lambda x:x[1]) +ans = 0 +for val in d: + if cnt <= 0: + print(ans) + exit() + ans += val[1] + cnt -= 1" +p02621,s747921651,Wrong Answer,"N = int(input()) +ans = 0 +for j in range(1, N+1): + for i in range(1, N+1): + if i % j == 0: + ans += i +print(ans)" +p03221,s783561093,Wrong Answer,"n, m = map(int, input().split()) +l = [] + +for i in range(m): + p, y = input().split() + l.append([p, y, i]) + +l.sort() + +l[0][1] = 1 + +for i in range(1, m): + if l[i][0] == l[i - 1][0]: + l[i][1] = l[i - 1][1] + 1 + else: + l[i][1] = 1 + +sortthird = lambda val: val[2] +l.sort(key = sortthird) + +for i in l: + ans = ""0""*(6 - len(i[0])) + i[0] + ""0""*(6 - len(str(i[1]))) + str(i[1]) + print(ans)" +p03126,s311020830,Wrong Answer,"N, M = map(int, input().split()) +list=[] +s=[] +for i in range(N): + list.append(input().split()) + s = set(s) & set(list[1:]) + list=[] +print(len(s)) " +p02658,s863076979,Accepted,"# import numpy +n = int(input()) +a = list(map(int,input().split())) +re = 1 +if 0 in a: + print(""0"") +else: + for i in a : + re = re * i + if re > 1000000000000000000: + print(""-1"") + quit() + print(re)" +p02684,s153237123,Accepted,"n,k=map(int,input().split()) +A=list(map(int,input().split())) +s=[] +v=1 +ord=[-1]*(n+1) +c=1 +l=0 +while ord[v]==-1: + ord[v]=len(s) + s.append(v) + v=A[v-1] +c=len(s)-ord[v] +l=ord[v] + +if k b: + a -= 1 +else: + b -= 1 +ans += max(a, b) +print(ans) +" +p03434,s059867396,Accepted,"n = int(input()) +A = sorted(list(map(int,input().split())),reverse=True) +alice = 0 +bob = 0 +for i in range(n): + if i%2==0: + alice += A[i] + else: + bob += A[i] +print(alice-bob)" +p03617,s701949270,Accepted,"q,h,s,d = map(int, input().split()) +n = int(input()) +q_cp=q*4 +h_cp=h*2 +s_cp=s +d_cp=d/2 + +vals = [[q_cp,0.25],[h_cp,0.5],[s_cp,1],[d_cp,2]] +vals.sort() + +if vals[0][1] <= 1: + print(n * vals[0][0]) +else: + ans=d*(n//2) + if n%2==0: + print(ans) + else: + ans+=vals[1][0] + print(ans)" +p02622,s781116590,Accepted,"ls1 = input() +ls2 = input() + +num = len(ls1) + +ans = 0 + +for i in range(num): + if ls1[i] != ls2[i]: + ans += 1 + +print(ans)" +p02756,s678725068,Wrong Answer,"s = input() +q = int(input()) + +flag = 1 +for i in range(q): + st = input().split() + if int(st[0]) == 1: + flag *= -1 + else: + tmp = int(st[1])*flag + if tmp == 1 or -2: + s = st[2] + s + else: + s = s + st[2] + +if flag == -1: + s = s[::-1] +print(s)" +p02881,s112976030,Accepted,"def make_divisors(n): + ans = 10 ** 12 + 10 + i = 1 + while i*i <= n: + if n % i == 0: + t = 0 + if i != n // i: + t = i + (n//i) - 2 + else: + t = i * 2 - 2 + #print(i, n//i, t) + if ans > t: + ans = t + i += 1 + return ans + +n = int(input()) +print(make_divisors(n))" +p03136,s233588837,Wrong Answer,"N=int(input()) +A=sorted(map(int,input().split())) +ans=0 +for i in range(N-1): + ans+=A[i] +if ans>=A[N-1]: + print(""No"") +else: + print(""Yes"")" +p04012,s839390989,Accepted,"# -*- coding: utf-8 -*- +count = {} +for c in input(): + if c in count: + count[c] = not(count[c]) + else: + count[c] = False + +print(['Yes', 'No'][False in count.values()])" +p02983,s115371573,Accepted,"import sys +l,r = map(int,input().split()) +mn = 2018 +for i in range(l,r+1): + for j in range(i+1,r+1): + mod = (i * j) % 2019 + if mod == 0: + print(0) + sys.exit() + + mn = min(mn,mod) +print(mn)" +p03723,s402595747,Accepted,"a, b, c = map(int, input().split()) + +if ( a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b == c): + print(-1) + quit() + +count = 0 +while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0): + _a = b / 2 + c /2 + _b = a / 2 + c /2 + _c = a / 2 + b /2 + a = _a + b = _b + c = _c + count += 1 +print(count)" +p04044,s939565311,Accepted,"N, L = map(int, input().split()) +char_list = sorted([input() for i in range(N)]) + +combined_char = """" + +for cl in char_list: + combined_char += cl + +print(combined_char)" +p03836,s293035792,Accepted,"sx,sy,tx,ty = map(int, input().split()) + +x = tx - sx +y = ty - sy + +ans = '' +ans += 'U'*y+'R'*x +ans += 'D'*y+'L'*x +ans += 'L'+'U'*(y+1)+'R'*(x+1)+'D' +ans += 'R'+'D'*(y+1)+'L'*(x+1)+'U' +print(ans)" +p04029,s399926733,Accepted,"N = int(input()) +print((1 + N) * N // 2)" +p02796,s712219826,Wrong Answer,"# -*- coding: utf-8 -*- + + +def main(): + n = int(input()) + y = list() + + for i in range(n): + xi, li = map(int, input().split()) + y.append((xi - li + 1, xi + li - 1)) + + count = 1 + sorted_y = sorted(y, key=lambda x: x[1]) + end_point = sorted_y[0][1] + + for left, right in sorted_y[1:]: + if left > end_point: + end_point = right + count += 1 + + print(count) + + +if __name__ == '__main__': + main() +" +p02606,s227748620,Accepted,"l, r, d = map(int, input().split()) +ans = 0 +for i in range(l, r+1): + if i%d == 0: + ans += 1 + +print(ans)" +p02658,s711295797,Accepted,"def main (): + N = int(input()) + A = list(map(int,input(). split ())) + + if 0 in A: + print(0) + return + + prod = 1 + for a in A: + prod *= a + if prod > 1000000000000000000: + print(-1) + return + print(prod) +main ()" +p02621,s833552839,Accepted,"a = int(input()) +print(a + a**2 + a**3)" +p03264,s788143176,Accepted,"k = int(input()) +if k % 2 == 0: + print(k//2 * k//2) +else: + print(k//2 * (k//2 + 1))" +p02720,s376113316,Wrong Answer,"from collections import deque + +K = int(input()) +a = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) + + +for i in range(K-1): + j = a.popleft() + if j%10 != 0: + a.append((10*j) + ((j%10) -1)) + + a.append((10*j)+j%10) + + if j%10 != 9: + a.append((10*j) +((j%10)+1)) + +a.popleft()" +p02598,s382515712,Wrong Answer,"import math +n,k=map(int,input().split()) +log=list(map(int,input().split())) +a=1 +b=max(log) +c=(a+b)//2 +while True: + div=0 + for i in range(n): + div+=math.ceil(log[i]/c)-1 + if div<=k: + b=c + c=(a+b)//2 + else: + a=c + c=(a+b)//2 + + if c==a or c==b: + break +print(b)" +p03076,s469265766,Wrong Answer,"list1 = [] +for i in range(5): + a = input() + b = int(a[-1]) + c = int(a) + list1.append((b,c)) +aaa = sorted(list1) + +mini = [] +total = 0 +for i in range(5): + if aaa[i][0] != 0: + mini = aaa[i] + + a = aaa.pop(i) + break + +for i in aaa: + if i[0] != 0: + d = 10 - i[0] + ans = i[1] + d + else: + ans = i[1] + total += ans +try: + total += mini[1] +except: + total = 0 +print(total) + " +p02726,s758663639,Accepted,"n,x,y = map(int, input().split()) + +ret = [0] * (n-1) +for i in range(1, n): + for j in range(i+1, n+1): + p1 = j-i + p2 = abs(i - x) + 1 + abs(j - y) + p3 = abs(i - y) + 1 + abs(j - x) + if p1 > p2: + p1 = p2 + if p1 > p3: + p1 = p3 + ret[p1-1] += 1 + +for data in ret: + print(data) +" +p02909,s633601203,Wrong Answer,"S = input() +w = [""Sunny"",""Cloudy"", ""Rainy""] + +for i in range (len(w)): + if S == w[0] or S == w[1]: + print(w[i+1]) + exit() + else: + print(w[0]) + exit()" +p03106,s684274528,Wrong Answer,"a, b, k = [int(x) for x in input().split()] + +divisors = [] +for x in range(1, max(a, b)+1): + if a % x == 0 and b % x == 0: + divisors.append(x) + +print(divisors[k-1])" +p02595,s210491939,Accepted,"n, d = map(int, input().split()) +res = 0 +for i in range(n): + x, y = map(int, input().split()) + if pow(pow(x,2) + pow(y,2),1/2) <= d: + res += 1 +print(res)" +p03475,s996917228,Accepted,"n = int(input()) + +CSF = [tuple(map(int, input().split())) for _ in range(n-1)] + +for i in range(n-1): + t = 0 + for j in range(i, n-1): + if t <= CSF[j][1]: + t = CSF[j][1] + elif t % CSF[j][2] == 0: + pass + else: + t += CSF[j][2] - t % CSF[j][2] + t += CSF[j][0] + print(t) +print(0) +" +p03437,s471419781,Accepted,"#!/usr/bin/env python3 +import sys, math, itertools, collections, bisect +input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') +inf = float('inf') ;mod = 10**9+7 +mans = inf ;ans = 0 ;count = 0 ;pro = 1 + +x,y = map(int,input().split()) +if x%y == 0:print(-1) +else: print(x)" +p02556,s750807038,Wrong Answer,"import math as mt +import sys +import bisect +input=sys.stdin.readline +#t=int(input()) +t=1 + +mod=10**9+7 +for _ in range(t): + + n=int(input()) + l=[] + for i in range(n): + x,y=map(int,input().split()) + l.append(x+y) + + #u1,d1=map(int,input().split()) + #u2,d2=map(int,input().split()) + #l=list(map(int,input().split())) + l.sort() + print(l[-1]-l[0])" +p03659,s093579164,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +whole = sum(a) + +if n == 2: + print(abs(a[0] - a[1])) +else: + now = 0 + ans = float(""inf"") + for i in a: + now += i + diff = abs(whole - 2 * now) + ans = min(ans, diff) + + print(ans)" +p03030,s511558584,Accepted,"n = int(input()) +s = [] +r = [] +sr = [] +for i in range(n): + s, r = map(str, input().split()) + sr.append([i+1, s, int(r)]) +# print(sr) +sr1 = sorted(sr, key=lambda x:x[2], reverse=True) + +ans = sorted(sr1, key=lambda x:x[1]) + +for i in range(n): + print(ans[i][0])" +p03698,s374080406,Accepted,"import sys + +def solve(): + input = sys.stdin.readline + S = list(input().strip(""\n"")) + if len(S) == len(set(S)): print(""yes"") + else: print(""no"") + return 0 + +if __name__ == ""__main__"": + solve()" +p03131,s520182322,Accepted,"k,a,b = map(int,input().split()) +if a >= b-1 or k <= a: + print(k+1) +else: + print((k-a+1)//2*(b-a) + ((k-a+1)%2) + a) +" +p02772,s657542497,Accepted,"n = int(input()) +a = list(map(int,input().split())) +ok = True +for i in a: + if i%2 == 0 : + if i%3 != 0 and i%5 != 0: + ok = False + break + +if ok: + print(""APPROVED"") +else: + print(""DENIED"") + + + " +p02924,s921023249,Accepted,"n = int(input()) + +print((n*(n-1)//2))" +p02645,s509917733,Wrong Answer,"a=input() +#str = list(a) +print(a[0:2])" +p02708,s069240343,Accepted,"N, K = map(int,input().split()) +ans = 0 +MOD = int(1E+9 + 7) +for n in range(K,N+2): + x = (N+1-n) * n + 1 + ans += x + ans %= MOD +print (ans)" +p02726,s487718738,Wrong Answer,"N, X, Y = list(map(int, input().split())) +path = list(range(1, N+1)) +for i in range(N-1): + i += 1 + if i == 1: + count = 1 + else: + count = 0 + for j in path: + if j - i > 0: + count += 1 + if i == (Y - X): + count -= 1 + print(count) + +" +p02706,s495770199,Wrong Answer,"n,m=map(int,input().split()) + +a=list(map(int,input().split())) +cnt=0 + +for i in a: + cnt+=i + +if cnt<0: + print(-1) +else: + print(n-cnt) + +" +p03438,s752060110,Accepted,"n = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +m = sum(B)-sum(A) +cnt1 = 0 +cnt2 = 0 +for a, b in zip(A, B): + if a > b: + cnt1 += (a-b) + elif a < b: + cnt2 += (b-a+1)//2 + else: + pass + +if cnt1 <= m and cnt2 <= m: + print('Yes') +else: + print('No') +" +p03208,s096934549,Wrong Answer,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + n,k=map(int, input().split()) + l=[int(input()) for i in range(n)] + l.sort() + ans=10*18 + for i in range(0,n-k+1): + ans=min(ans,l[i+k-1]-l[i]) + print(ans) +resolve()" +p04033,s766672973,Accepted,"a, b = map(int, input().split()) + +if a > 0 and b > 0: + print('Positive') +elif a < 0 and b < 0: + if ((a - b) + 1) % 2 == 0: + print('Positive') + else: + print('Negative') +else: + print('Zero')" +p02639,s306184552,Accepted,"x1, x2, x3, x4, x5 = map(int,input().split()) +print(15-x1-x2-x3-x4-x5)" +p03997,s520701718,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) + +print(a * h - (a - b) * h) +" +p03001,s612224427,Wrong Answer,"def main(): + W, H, x, y = map(int, input().split()) + + S2 = W * H / 2 + if x == 0 or x == W or y == 0 or y == H: + print(S2, 0) + exit() + + print(W * H / 2, 1) + + +main() +" +p02791,s482360781,Accepted,"n = int(input()) +p = list(map(int, input().split())) +x = 2*(10**5)+1 +c = 0 +for i in p: + if i < x: + x = i + c += 1 +print (c) +" +p02546,s429722518,Accepted,"S = input() + +if S[-1] == 's': + print(S + 'es') +else: + print(S + 's')" +p02607,s547061495,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +count = 0 +for i in range(1,N): + if i % 2 != 0 and a[i] % 2 != 0: + count += 1 + else: + pass + +print(count)" +p02723,s786714090,Accepted,"S=input() +if S[2]==S[3] and S[4]==S[5]: + print(""Yes"") +else: + print(""No"")" +p03796,s555182116,Accepted,"import math +n=int(input()) +print(math.factorial(n)%(10**9+7))" +p02583,s069796949,Accepted,"n=int(input()) +a=input().split() +count=0 + +for t in range(n): + a[t]=int(a[t]) + +for i in range(n-2): + for j in range(n-2): + if j>=i: + for k in range(n-2): + if k>=j: + if a[i]!=a[j+1] and a[j+1]!=a[k+2] and a[k+2]!=a[i]: + if a[i]+a[j+1]>a[k+2] and a[j+1]+a[k+2]>a[i] and a[k+2]+a[i]>a[j+1]: + count+=1 +print(count)" +p03481,s153130014,Accepted,"def resolve(): + X,Y=map(int,input().split()) + cnt=0 + while X<=Y: + X=X*2 + cnt+=1 + print(cnt) + + +resolve() +" +p03998,s399641562,Accepted,"a = list(input()) +b = list(input()) +c = list(input()) + +s = a.pop(0) +for i in range(400): + if s == 'a': + if a == []: + break + s = a.pop(0) + elif s == 'b': + if b == []: + break + s = b.pop(0) + elif s == 'c': + if c == []: + break + s = c.pop(0) +print(s.upper())" +p02663,s382309364,Accepted,"H1, M1, H2, M2, K = map(int, input().split()) + +T1 = H1 * 60 + M1 +T2 = H2 * 60 + M2 + +print(T2 - T1 - K) +" +p02767,s272942415,Wrong Answer,"import numpy as np + +n = int(input()) +x = list(map(int, input().split())) + +m = int(np.median(x)) +k = int(np.std(x)) +ans = max(x) ** 2 * n + +# pos = m + k +# print(pos) +# cost = 0 + +low = max(1, m - k) +high = min(m + k, np.max(x)) + +for i in range(low, high, 1): + cost = 0 + for j in range (n): + cost += (x[j] - i) ** 2 + # print(cost) + if cost < ans: + ans = cost + +print(ans)" +p02988,s675448552,Accepted,"n=int(input()) +p=[int(_) for _ in input().split()] +count=0 +for i in range(n-2): + if p[i+1]!=min(p[i:i+3]) and p[i+1]!=max(p[i:i+3]): + count+=1 +print(count) +" +p03721,s162148440,Accepted,"N, K = [int(i) for i in input().split()] + +ab = [[int(i) for i in input().split()] for _ in range(N)] + +length = 0 +sorted_ab = sorted(ab, key=lambda x:x[0]) + +for x in sorted_ab: + length += x[1] + if length >= K: + output = x[0] + break + +print(output)" +p03774,s879352091,Accepted,"n,m=map(int,input().split()) +student=[list(map(int,input().split())) for _ in range(n)] +checkpoint=[list(map(int,input().split())) for _ in range(m)] +ans=[0]*n + +for i in range(n): + distance=10**9 + index=0 + for j in range(m): + if abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1]) a: + ans += r[i] + i += 1 + +print(ans)" +p03285,s084047669,Wrong Answer,"#105_B +N=int(input()) +flg=False +for i in range(0,N//7+1): + N=N-7*i + if N%4==0: + flg=True + break +print('Yes' if flg else 'No')" +p02615,s774775313,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a = sorted(a)[::-1] +s = 0 +for i in range(1, n): + s += a[i//2] +print(s)" +p02909,s552234383,Wrong Answer,"print('今日の天気を入力してね') +today_weather=input() +if today_weather==""Sunny"": + print('Cloudy') +elif today_weather==""Cloudy"": + print('Rainy') +else: + print('Sunny')" +p03720,s534131423,Accepted,"n,m = map(int,input().split()) +lst1 = [list(map(int,input().split())) for i in range(m)] + +lst2 = [0]*n + +for i,j in lst1: + lst2[i-1] += 1 + lst2[j-1] += 1 + +for i in lst2: + print(i) " +p03494,s597812452,Wrong Answer,"n=input() +n_list=list(map(int,input().split())) + +counter=0 +while all(i%2==0 for i in n_list): + n_list=[i/2 for i in n_list] + counter=+1 +print(counter) + +" +p03386,s987686326,Wrong Answer,"A, B, K = map(int, input().split()) + +n = [i for i in range(A, B+1)] + +if len(n) < K*2: + for j in range(len(n)): + print(n[j]) +else: + for j in range(K): + print(n[j]) + for j in reversed(range(len(n)-K,len(n))): + print(n[j])" +p02959,s565160472,Accepted,"n = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +before = sum(A) + +for i in range(n): + if A[i] > B[i]: + A[i] -= B[i] + else: + B[i] -= A[i] + A[i] = 0 + A[i + 1] = max(0, A[i + 1] - B[i]) +after = sum(A) + +answer = before - after +print(answer) +" +p03817,s184819613,Wrong Answer,"n = int(input()) +print(n//11*2+n%11//6+n%11%6)" +p02987,s035390186,Accepted,"s = list(str(input())) + +s_set = list(set(s)) +if len(s_set) != 2: + print('No') +else: + count1 = 0 + for i in range(len(s)): + if s[i] == s_set[0]: + count1 += 1 + count2 = 0 + for i in range(len(s)): + if s[i] == s_set[1]: + count2 += 1 + if count1 == 2 and count2 == 2: + print('Yes') + else: + print('No') +" +p02879,s318671385,Accepted,"a, b = map(int, input().split()) + +if a < 10 and b < 10: + print(a * b) +else: + print(-1) +" +p02642,s182913088,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a.sort() +m = a[-1] + +c = [0] * (m + 1) +for i in range(n): + for j in range(a[i], m + 1, a[i]): + c[j] += 1 + +ans = 0 +for e in list(set(a)): + if c[e] == 1: + ans += 1 + +print(ans) +" +p02547,s062860313,Wrong Answer,"x=int(input()) +l=[] +c=0 +for i in range(x): + a,b = map(int,input().split()) + l.append(a) + l.append(b) +for i in range(0,x*2,2): + if l[i]==l[i+1]: + c+=1 + print(l[i]) + if c>=3: + print(""YES"") + break + + else: + c=0 +if c<3: + print(""NO"") +print(c)" +p02778,s235027357,Accepted,"INT = lambda: int(input()) +INTM = lambda: map(int,input().split()) +STRM = lambda: map(str,input().split()) +STR = lambda: str(input()) +LIST = lambda: list(map(int,input().split())) +LISTS = lambda: list(map(str,input().split())) +def do(): + s=STR() + print(len(s)*'x') +if __name__ == '__main__': + do()" +p03087,s771026295,Wrong Answer,"N,Q = list(map(int,input().split())) +S = input() +L = [] +R = [] +for i in range(Q): + l,r=list(map(int,input().split())) + L.append(l) + R.append(r) +print(L) +print(R) + +dp = [0]*N +for j in range(N-1): + if S[j]=='A' and S[j+1]=='C': + dp[j+1] = dp[j]+1 + else: + dp[j+1] = dp[j] + +print(dp) +for k in range(Q): + print(dp[R[k]-1]-dp[L[k]-1])" +p03001,s694476590,Accepted,"w, h, x, y = map(int, input().split()) +ans = w*h/2 +if h/2 == y and w/2 == x: + flag = 1 +else: + flag = 0 +print('{} {}'.format(ans, flag))" +p03827,s663444922,Wrong Answer,"n = int(input()) +s = input() +count = 0 +count_list = [] + +for i in range(len(s)): + if s[i] == ""I"": + count += 1 + count_list.append(count) + else: + count -= 1 + count_list.append(count) + +print(max(count_list))" +p02994,s093796321,Accepted,"n,l=map(int,input().split() ) +if l*(l+n-1)<=0:print(sum(range(l,l+n))) +elif l>0:print(sum(range(l+1,l+n))) +else:print(sum(range(l,-1+l+n)))" +p03252,s550371048,Wrong Answer,"S = str(input()) +T = str(input()) +alp = ""abcdefghijklmnopqrstuvwxyz"" +for i in range(0,len(S)//2): + if S[i] != T[i]: + S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]})) + if S == T: + print(""Yes"") + exit() +print(""No"")" +p02624,s954620033,Wrong Answer,"import time +import math +N=int(input()) +if N==1: + print(1) + exit() + + +d=[1]*(N+1) + +ans=0 +for i in range(2,N+1): + j=0 + while i+j<=N: + d[i+j]+=1 + j+=i + ans+=d[i]*i + + +print(ans) + +" +p03487,s040491816,Wrong Answer,"import collections + +n = int(input()) +a = [int(i) for i in input().split()] +b = collections.Counter(a) +ans =0 +for i,n in b.items(): + ans += min(abs(n - i),n) +print(ans)" +p03796,s464988139,Accepted,"N = int(input()) +k=1 +for i in range(1,N+1): + k=k*i%(10**9+7) +print(k)" +p02754,s641120467,Accepted,"def main(): + n,a,b=map(int,input().split()) + k=n//(a+b) + print(a*k+min(n%(a+b),a)) +main()" +p03285,s267922078,Accepted,"import math +n = int(input()) +counter = False +#for n in range (0,100): +for i in range (math.ceil((n+1) / 4) ): + for j in range (math.ceil((n+1) / 7) ): + #print(n, i,j) + if i*4 + j*7 == n: + counter = True +if counter == True: + print(""Yes"") +else: + print(""No"") +" +p03252,s867313127,Wrong Answer,"s = input() +t = input() + +dic = {} + +for i,j in zip(s,t): + if j in dic: + if i not in dic[j]: + print(""No"") + exit() + else: + if j in dic: + print(""No"") + exit() + else: + dic[j] = i + +print(""Yes"")" +p03161,s116898055,Wrong Answer,"inf=(10**7)+1 +import sys +def get_array(): return list(map(int , sys.stdin.readline().strip().split())) +def get_ints(): return map(int, sys.stdin.readline().strip().split()) +def input(): return sys.stdin.readline().strip() +n,k=get_ints() +h=get_array() +li=[inf]*n +li[0]=0 + +for i in range(1,n): + l=max(0,i-k) + for j in range(l,i): + + + + + li[i]=min(li[i],li[j]+abs(h[i]-h[j])) +##print(li) +print(li[n-1]) +" +p02759,s398456294,Accepted,"N = int(input()) + +print((N+1) // 2) +" +p02924,s849631569,Accepted,"N = int(input()) +print(N*(N-1)//2) +" +p03163,s235064940,Wrong Answer,"def main(): + n, W, *wv = map(int, open(0).read().split()) + dp = [[0] * (W + 1)] + for i in range(n): + w = wv[i * 2] + v = wv[i * 2 + 1] + pv = dp[i][w] + dpj = [pv for _ in range(0, w)] + [max(dp[i][j], dp[i][j - w] + v) for j in range(w, W + 1)] + dp.append(dpj) + print(dp[-1][W]) + +main()" +p03471,s962588441,Accepted,"N,Y=map(int,input().split()) +ans=-1,-1,-1 +for i in range(N+1): + for j in range(N+1-i): + if 1<=N<=2000 and 10000*i+5000*j+1000*(N-i-j)==Y: + ans=i,j,N-i-j +print(*ans)" +p03281,s447525339,Accepted,"N = int(input()) + +def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + + # divisors.sort() + return len(divisors) + +ans = 0 + +for i in range(1,N+1): + a = make_divisors(i) + if a ==8 and i%2 == 1 : + ans += 1 + +print(int(ans))" +p04005,s444220330,Accepted,"A,B,C=sorted(map(int,input().split())) +if A*B*C%2: + print(A*B) +else: + print(0)" +p03723,s539254952,Accepted,"A, B, C = map(int,input().split()) +ans = 0 +while True: + if A & 1 or B & 1 or C & 1: break + elif A == B and B == C: + ans = -1 + break + else: + ans += 1 + A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2 +print(ans)" +p02922,s860021381,Wrong Answer,"# coding: utf-8 + +a,b=list(map(int,input().split())) + +mouse_tot = a +mouse_cnt = 1 +wa = a-1 + +while mouse_tot < b: + mouse_tot += wa + mouse_cnt += 1 + +print(mouse_cnt)" +p03474,s066793986,Accepted,"a, b = map(int, input().split()) +s = input() +t = s[:a] + s[a+1:] + +if s[a]=='-' and '-' not in t: + print(""Yes"") +else: + print(""No"")" +p02659,s364611260,Accepted,"import math +from decimal import Decimal as D, getcontext + +getcontext().prec = 1000 + +A, B = input().split() +A, B = D(A), D(B) +print(int(A * B // D(1))) +" +p02843,s741626887,Accepted,"import collections +import sys +import math +X=int(input()) +if X<100: + print(""0"") + sys.exit() +amari=math.floor(X/100) +kake=amari*5 +if amari*100<=X<=amari*100+kake: + print(""1"") +else: + print(""0"")" +p03623,s129892330,Accepted,"A,B,C = list(map(int,input().split())) +if abs(A-B) < abs(A-C): + print(""A"") +else: + print(""B"")" +p02743,s696396204,Accepted,"a,b,c=map(int,input().split()) +print(""Yes"" if 4*a*b<(c-a-b)**2 and c-a-b>0 else ""No"")" +p03659,s618090172,Accepted,"# 累積じゃね +n = int(input()) +arr = list(map(int, input().split())) +ruiseki = [0] * (n + 1) +for i in range(1, n + 1): + ruiseki[i] = ruiseki[i - 1] + arr[i - 1] +ans = 10**10 +for i in range(1, n): + takahashi = ruiseki[i] + raskal = ruiseki[n] - takahashi + ans = min(ans, abs(raskal - takahashi)) +print(ans)" +p03665,s712146594,Accepted,"n, p = map(int, input().split()) +A = list(map(int, input().split())) + +f = 0 +for a in A: + if a%2: + f = 1 + break + +if f: + ans = 2**(n-1) +else: + if p: + ans = 0 + else: + ans = 2**n +print(ans)" +p02831,s757406500,Wrong Answer,"num = [int(i) for i in input().split()] +kou = [min(num)] +for i in range(2,min(num)): + if min(num)%i==0: + kou.append(i) +a = 1 +for j in kou: + if max(num)%j==0: + a = a * j +print(int(num[0]*num[1]/a))" +p02922,s614691897,Wrong Answer,"a,b=map(int,input().split()) +import math +print(math.ceil(b/a))" +p03557,s020409473,Wrong Answer,"from bisect import bisect_right +from bisect import bisect_left +def main(): + n=int(input()) + A = list(map(int,input().split())) + B = list(map(int,input().split())) + C = list(map(int,input().split())) + + A.sort() + C.sort() + sum=0 + for i in range(n): + cnt=1 + cnt*= bisect_left(A,B[i]) + cnt*= n-bisect_right(A,B[i]) + sum+=cnt + + print(sum) + +if __name__ == '__main__': + main()" +p03106,s552963462,Accepted,"A,B,K=map(int,input().split()) +l=[] + +for i in range(1,min(A,B)+1): + if A%i==0 and B%i==0: + l.append(i) +print(l[-K])" +p03416,s779899600,Accepted,"a,b=map(int,input().split()) +count=0 + +for i in range(a,b+1): + val=str(i) + if (val[0]==val[-1]) and (val[1]==val[-2]): + count+=1 + +print(count)" +p02946,s427958518,Accepted,"k,x = map(int, input().split()) +ans = [] +for i in range(x-k+1, x+k): + ans.append(i) +print(' '.join(map(str, ans)))" +p03485,s989850986,Accepted,"a,b=map(int,input().split()) + +print(-(-(a+b)//2)) + + " +p03323,s738221264,Accepted,"a, b = map(int, input().split()) +if a <= 8 and b <= 8: + print('Yay!') +else: + print(':(') +" +p02971,s495057208,Accepted,"n = int(input()) +a = [ int(input()) for _ in range(n)] + +b = sorted(a,reverse=True) +x = b[0] +y = b[1] + +for i in a : + if i == x: + print(y) + else: + print(x) +" +p02836,s943414005,Accepted,"s = input() +ans = 0 +num = len(s)-1 +for i in range(0,(num//2)+1): + if s[i] != s[num-i]: + ans += 1 + +print(ans) +" +p03719,s081474183,Accepted,"A,B,C = map(int, input().split()) +if A <= C <= B: + print('Yes') +else: + print('No')" +p04031,s577658067,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +ans = 10**9 + +for i in range(min(a),max(a)+1): + cost = 0 + for j in range(n): + cost += (a[j]-i)**2 + ans = min(cost, ans) + +print(ans)" +p03817,s813017957,Accepted,"x = int(input()) +x-=1 +a = x//11 +if x%11>=6: + print(2*a+2) +else: + print(2*a+1)" +p02695,s525222000,Accepted,"import sys +from itertools import combinations_with_replacement as combi +input = sys.stdin.readline +N, M, Q = map(int, input().split()) +qs = [tuple(map(int, input().split())) for _ in range(Q)] +res = 0 +for c in combi([x for x in range(1, M + 1)], N): + t = 0 + for l, r, d, s in qs: + if c[r - 1] - c[l - 1] == d: t += s + res = max(res, t) +print(res)" +p03448,s085518327,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) +ans = 0 + +for i in range(1,a+1): + for j in range(1,b+1): + for k in range(1,c+1): + y = i*500 + j*100 + k*50 + if x == y: + ans += 1 + +print(ans)" +p03679,s725461806,Accepted,"x,a,b=map(int,input().split()) +if b-a<=0: + print(""delicious"") +elif b-a<=x: + print(""safe"") +else: + print(""dangerous"")" +p03605,s900642327,Accepted,"n=str(input()) +if n[0]=='9' or n[1]=='9': + print('Yes') +else: + print('No')" +p03815,s555359619,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Wed Sep 30 01:58:33 2020 + +@author: liang +"""""" +import math + +x = int(input()) + +ans = x // 11 *2 + math.ceil(x%11/6) + +print(ans)" +p02691,s787001520,Accepted,"#import numpy as np +import sys, math +from itertools import permutations, combinations +from collections import defaultdict, Counter, deque +from math import factorial#, gcd +from bisect import bisect_left #bisect_left(list, value) +sys.setrecursionlimit(10**7) +enu = enumerate +MOD = 10**9+7 +def input(): return sys.stdin.readline()[:-1] +def pri(x): print('\n'.join(map(str, x))) + +N = int(input()) +A = list(map(int, input().split())) + +cnt = 0 +d = defaultdict(int) +for i, a in enu(A): + l = (i+1) + a + r = (i+1) - a + cnt += d[r] + d[l] += 1 +print(cnt)" +p02861,s167255571,Accepted,"import itertools as it +import math +def Dist (x1,y1,x2,y2): + dis = (x2 - x1)**2 + (y2 - y1)**2 + return math.sqrt(dis) +N = int(input()) +Pos = [] +res = 0 +for i in range(N): + pos = list(map(int,input().split())) + Pos.append(pos) +array = list(it.permutations(i for i in range(N))) +for i in range(math.factorial(N)): + for j in range(N-1): + res += Dist(Pos[array[i][j]][0],Pos[array[i][j]][1],Pos[array[i][j+1]][0],Pos[array[i][j+1]][1]) +print(res / math.factorial(N))" +p04045,s251230010,Wrong Answer,"n, k = map(int, input().split()) +D = set(map(int, input().split())) +from itertools import count +for ans in count(n,1): + for c in str(ans): + if int(c) in D: + print(ans) + break + else: + print(ans) + break" +p03106,s248057328,Wrong Answer,"import sys +from itertools import combinations +import math + + +def I(): return int(sys.stdin.readline().rstrip()) + + +def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) + + +def S(): return sys.stdin.readline().rstrip() + + +def LS(): return list(sys.stdin.readline().rstrip().split()) + + +A, B, K = LI() +temp = 0 +for i in range(1, max(A, B)+1): + if A % i == 0 and B % i == 0: + temp += 1 + if temp == K: + print(i) + exit() +" +p02910,s808869273,Accepted,"# 初期入力 +S =input() + +# +flag = True + +for i,v in enumerate(S): + if (i+1) %2 ==1 and v in ""RUD"": + flag =""Yes"" + elif(i+1) %2 ==1 and v not in ""RUD"": + flag =""No"" + break + if (i+1) %2 ==0 and v in ""LUD"": + flag =""Yes"" + elif(i+1) %2 ==0 and v not in ""LUD"": + flag =""No"" + break +print(flag)" +p02829,s251991513,Accepted,"a = int(input()) +b = int(input()) + +print(6-a-b)" +p03795,s328750721,Accepted,"n = int(input()) +print(800 * n - 200 * (n // 15))" +p04012,s620095870,Accepted,"w = input() +if all([w.count(i)%2 == 0 for i in set(w)]): + print('Yes') +else: + print('No')" +p03639,s949916401,Accepted,"n = int(input()) +A = list(map(int, input().split())) +div = 0 +even = 0 +for a in A: + if a % 4 == 0: + div += 1 + elif a % 2 == 0: + even += 1 + +odd = n - div - even +if even: + odd += 1 +if div: + div += 1 + +if div >= odd or even == n: + print(""Yes"") +else: + print(""No"") +" +p03073,s309853619,Accepted,"S = input() +l = len(S) +bw = '01' * (l // 2 + 1) +wb = '10' * (l // 2 + 1) +bw_count = len([ 1 for a, b in zip(S, bw) if a != b ]) +wb_count = len([ 1 for a, b in zip(S, wb) if a != b ]) +print(min(bw_count, wb_count)) +" +p03611,s242467471,Accepted,"import sys + +n, *a = map(int, sys.stdin.read().split()) + +def main(): + m = 10 ** 5 + cnt = [0] * (m + 1) + for x in a: + cnt[x] += 1 + if x > 0: cnt[x-1] += 1 + if x < m: cnt[x+1] += 1 + print(max(cnt)) + +if __name__ == '__main__': + main()" +p03352,s157562095,Accepted,"X = int(input()) + +beki = [] +for i in range(1,32): + beki.append(i**2) +for i in range(1,11): + beki.append(i**3) +for i in range(1,6): + beki.append(i**4) +for i in range(1,4): + beki.append(i**5) +for j in range(6,10): + beki.append(2**j) + +beki = sorted(beki, reverse=True) +for a in beki: + if a <= X: + print(a) + break" +p03408,s371180597,Accepted,"N = int(input()) +s = [input() for _ in range(N)] +M = int(input()) +t = [input() for _ in range(M)] +print(max(max([s.count(e)-t.count(e) for e in s+t]),0)) +" +p02576,s409667006,Accepted,"n, x, t = map(int, input().split()) +if n % x == 0: + print((n//x)*t) +else: + print((n//x+1)*t)" +p02645,s196334776,Accepted,"s = input() +print(s[:3])" +p03351,s904562178,Wrong Answer,"a,b,c,d=map(int,input().split()) +if abs(a-c) 20190430: + print(""TBD"") +else: + print(""Heisei"") " +p03774,s193984908,Accepted,"n, m = map(int, input().split()) +s = [list(map(int, input().split())) for _ in range(n)] +p = [list(map(int, input().split())) for _ in range(m)] + +for i in range(n): + l = [0]*m + for j in range(m): + l[j] = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1]) + print((l.index(min(l)) +1))" +p02811,s075688567,Accepted,"k,x =map(int, input().split()) + +if (500*k)-x >= 0: + print(""Yes"") +else: + print(""No"")" +p02618,s014632339,Wrong Answer,"D = int(input()) + +cs = [int(i) for i in input().split()] + +last = {n: 0 for n in range(1, 27)} +ans = [] +for day in range(1, D-26): + ss = [int(i) for i in input().split()] + max_score = 0 + max_i = 1 + for i, s in enumerate(ss, 1): + human = day-last[i] + s_human = s + cs[i-1] * (human*2) + if s_human > max_score: + max_score = s_human + max_i = i + ans.append(max_i) + last[max_i] = day" +p02553,s944170060,Wrong Answer,"import sys +import collections as cc +import math as mt +I=lambda:list(map(int,input().split())) +a,b,c,d=I() +print(max(b*d,a*c,a*d,b*d)) +" +p03254,s367546514,Wrong Answer,"n, x = map(int, input().split()) +a = list(map(int, input().split())) +a.sort() + +s = 0 +num = 0 +for i in range(len(a)): + if x >= a[i]: + x -= a[i] + num += 1 + else: + break + +print(num)" +p03633,s963089156,Accepted,"from fractions import gcd +from functools import reduce +import sys +input = sys.stdin.readline + +def lcm_base(x, y): + return (x * y) // gcd(x, y) + +def lcm(numbers): + return reduce(lcm_base, numbers, 1) + +def main(): + N = int(input()) + T = [int(input()) for _ in range(N)] + print(lcm(T)) + +if __name__ == '__main__': + main()" +p02756,s723127819,Accepted,"s = input() +q = int(input()) + +reverse_flag = 0 +head = """" +back = """" +for _ in range(q): + query = input() + if query[0] == ""1"": + reverse_flag ^= 1 + else: + t,f,c = query.split() + f = int(f) + reverse_flag + if f%2 == 1: + head = c + head + else: + back = back + c +s = head + s + back +print(s if reverse_flag%2 == 0 else s[::-1])" +p02702,s360686262,Wrong Answer,"def main(): + s = input()[::-1] + l = len(s) + n = 2019 + dp = [0]*n + wk = 0 + r = 1 + for i in range(l): + wk += int(s[i])*r + wk %= n + dp[wk] += 1 + r*= 10 + r %= n + print(sum([i*(i-1)//2 for i in dp]),dp) +main()" +p02711,s224775657,Accepted,"n = input() +if '7' in n: + print('Yes') +else: + print('No')" +p04043,s693505335,Accepted,"A,B,C = map(int,input().split()) +count7 = 0 +count5 = 0 + +ans = [A,B,C] + +for i in ans: + if i == 7: + count7 += 1 + elif i == 5: + count5 += 1 + +if count7 == 1 and count5 == 2: + print('YES') +else: + print('NO')" +p03760,s240386876,Accepted,"from collections import deque +O = deque(input()) +E = deque(input()) +ans = [] +for _ in range(len(O)): + ans.append(O.popleft()) + if E: + ans.append(E.popleft()) +print("""".join(ans)) +" +p02727,s592337731,Accepted," +X, Y, A, B, C = map(int, input().split()) +P = list(map(int, input().split())) +Q = list(map(int, input().split())) +R = list(map(int, input().split())) + +P.sort() +Q.sort() +cand = P[-X:] + Q[-Y:] + R +cand.sort() +print(sum(cand[-(X + Y):])) +" +p03331,s886573680,Accepted,"# B +si = lambda: input() +ni = lambda: int(input()) +nm = lambda: map(int, input().split()) +nl = lambda: list(map(int, input().split())) +def calc(a,b): + sa=list(str(a)) + sb=list(str(b)) + res=0 + for aa in sa: + res+=int(aa) + for bb in sb: + res+=int(bb) + return res + +n=ni() +ans=10**6 +for i in range(1,n): + a=i + b=n-i + t=calc(a,b) + ans=min(ans,t) +print(ans) + +" +p02694,s117595247,Wrong Answer,"import math + +X = int(input()) + +t = 0 +m = 100 + +while m < X: + m = math.ceil(m * 1.01) + t += 1 + +print(t)" +p03799,s564118189,Accepted,"N, M = map(int, input().split()) + +res = 0 +if 2 * N <= M: + res += N + M -= 2 * N + res += M // 4 +else: + res += M // 2 + +print(res) +" +p02939,s758588841,Wrong Answer,"s = input() + +l = len(s) +ans = 1 +tmp = s[0] +nxt = """" +for i in range(1,l): + nxt += s[i] + if tmp == s[i]: + continue + else: + ans += 1 + tmp = nxt + nxt = """" + +print(ans)" +p03986,s131407811,Accepted,"x = input() +s = 0 +ans = 0 +for c in x: + if c == 'S': + s += 1 + else: + if s == 0: + ans += 2 + else: + s -= 1 +print(ans) +" +p02747,s161396810,Accepted,"s = input() + +if s == ""hi"" or s == ""hihi"" or s == ""hihihi"" or s ==""hihihihi"" or s ==""hihihihihi"" or s ==""hihihihihihihi"" or s ==""hihihihihihihihi"" or s ==""hihihihihihihihihi"" or s ==""hihihihihihihihihihi"": + print(""Yes"") +else: + print(""No"") +" +p03611,s008534463,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a = sorted(a) + +cnt = {} +for i in range(n): + if a[i] not in cnt: + cnt[a[i]] = 0 + cnt[a[i]] += 1 + +ans = 0 +for i in range(n): + tmp = cnt[a[i]] + if a[i] - 1 in cnt: + tmp += cnt[a[i] - 1] + if a[i] + 1 in cnt: + tmp += cnt[a[i] + 1] + ans = max(ans, tmp) +print(ans) + " +p02658,s528506132,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +def f(A): + for a in A: + if a == 0: + print(0) + return + v = 1 + for a in A: + v *= a + if v > int(1e+18): + print(-1) + return + print(v) + return + +f(A)" +p02996,s237659203,Accepted,"N=int(input()) +A=[tuple(map(int,input().split())) for i in range(N)] +A.sort(key=lambda x: x[1]) +a=0 +b=0 +c=0 +for i in range(len(A)): + a+=A[i][0] + b=A[i][1] + if a>b: + c+=1 + print('No') + break +if c==0: + print('Yes')" +p03944,s332402077,Wrong Answer," +W,H,N = map(int, input().split()) +bottom = [0, 0] +top = [W,H] + +for _ in range(N): + x,y,a = map(int, input().split()) + if a==1: + bottom[0] = max(bottom[0], x) + elif a==2: + top[0] = min(top[0], x) + elif a==3: + bottom[1] = max(bottom[1], y) + elif a==4: + top[1] = min(top[1], y) + +print(max(0, (top[0]-bottom[0])*(top[1]-bottom[1]))) +" +p03427,s757943593,Accepted,"# A - Digit Sum 2 + +N = input() +digit = len(N) +ans = 0 + +for i in range(digit): + ans += int(N[i]) + if i k: + flag = True + break + +if flag: + print("":("") +else: + print(""Yay"")" +p04030,s222525658,Accepted,"s = input() +a = """" +for i in s: + if i == ""0"" or i == ""1"": + a += i + else: + a = a[:-1] +print(a)" +p02663,s587834303,Accepted,"import sys +from functools import lru_cache + +#read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10**6) +def read(): + return int(readline()) +def reads(): + return map(int, readline().split()) +def mp(arg): + return map(int,arg.split()) + +h1,m1,h2,m2,k=reads() +limit=(h2-h1)*60+m2-m1 +res=0 +if limit-k>=0: + limit-=k +else:limit=0 +print(limit)" +p03250,s469481059,Accepted,"A, B, C = map(int, input().split()) +mx = max(A, B, C) +if mx == A: + print(10*A + B + C) +elif mx == B: + print(10*B + C + A) +else: + print(10*C + A + B)" +p02659,s563854572,Wrong Answer,"a,b=input().split() +a=int(a) +b=float(b) +z=a*b//1 +print(int(z)) +" +p03437,s093092200,Accepted,"x, y = map(int, input().split()) +if x % y == 0: + print(-1) +else: + print(x) +" +p02952,s031688332,Accepted,"def resolve(): + N = int(input()) + ans = 0 + for i in range(1,N+1): + if len(str(i))%2==1: + ans += 1 + print(ans) + +if '__main__' == __name__: + resolve()" +p02833,s536129068,Accepted,"import math as mt +N = int(input()) + +if N % 2 == 1 or N < 2: + print(0) + exit() + +r = 0 +L = int(mt.log(N,5)) +for i in range(1,L+1): + p = N//(5**i)//2 + r += p + #print(N,5**i,p) +print(r)" +p03077,s401357429,Accepted,"N=int(input()) +A=int(input()) +B=int(input()) +C=int(input()) +D=int(input()) +E=int(input()) +x=min(A,B,C,D,E) +if N%x==0: + print(((N//x)+4)) +else: + print(((N//x)+5))" +p02624,s877723504,Accepted,"N=int(input()) + +ans = 0 +for i in range(1,N+1): + j = N//i + ans += i*j*(j+1)//2 + +print(ans)" +p03417,s450464936,Accepted,"N, M = list(map(int,input().split())) +if N == 1 and M == 1: print(1) +elif N == 1: print(M - 2) +elif M == 1: print(N - 2) +else: print((N - 2) * (M - 2))" +p02756,s022938924,Accepted,"import sys +input = lambda: sys.stdin.readline().rstrip() +s=[i for i in input()] +x=0 ; st=[[],[]] +for _ in range(int(input())): + inp=list(map(str,input().split())) + if len(inp)==1: x^=1 + else: st[(int(inp[1])-1)^x].append(inp[2]) +if x==0: + st[0].reverse() + ans=st[0]+s+st[1] +elif x==1: + st[1].reverse() + s.reverse() + ans=st[1]+s+st[0] +print(''.join(ans)) + + " +p03639,s006636332,Accepted,"import numpy as np +import sys + +read= sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +MOD = 1000000007 +sys.setrecursionlimit(10**7) + + +N = int(input()) +a = list(map(int,input().split())) + +cnt4,cnt2 = 0,0 + +for i in a: + if i%4 == 0: + cnt4 += 1 + elif i%2 == 0: + cnt2 += 1 + +cnt2 = max(1,cnt2) + +print(""Yes"" if 2*cnt4 + cnt2 >= N else ""No"")" +p03243,s593684329,Accepted,"N = int(input()) +res = (N + 111 - 1) // 111 +print(res*111)" +p02713,s282289859,Accepted,"K = int(input()) + +def gcd(a,b): + if b == 0: + return a + else: + return gcd(b, a%b) + +def gcd3(a,b,c): + return gcd(a, gcd(b,c)) + +ans = 0 + +for x in range(1,K+1): + for y in range(1,K+1): + for z in range(1,K+1): + ans += gcd3(x,y,z) + +print(ans) +" +p02642,s942519108,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = set(A) +M = max(S) +A.sort() + +pre_a = 0 +for a in A: + if a == pre_a: + S.discard(a) + if a in S: + j = a * 2 + while j <= M: + S.discard(j) + j += a + pre_a = a +print(len(S))" +p03338,s669876825,Accepted,"def calc_intersection(): + n = int(input()) + s = input() + list_intersection = [] + + for i in range(1, n): + a = set(s[:i]) + b = set(s[i:]) + intersection_a_b = a.intersection(b) + list_intersection.append(len(intersection_a_b)) + return max(list_intersection) + + +if __name__ == '__main__': + print(calc_intersection())" +p03705,s829743297,Accepted,"n, a, b = map(int, input().split()) +if a > b: + print(0) +elif n == 1 and a != b: + print(0) +elif n == 1: + print(1) +else: + print((b-a)*(n-2)+1)" +p02603,s264123740,Accepted,"N=int(input()) +A=list(map(int,input().split())) +m=1000 +num=0 +for x in range(N-1): + if A[x]>A[x+1]: + m+=A[x]*num + num=0 + elif A[x]x: + if x>=a[i]: + x-=a[i] + cnt+=1 + else: + break + else: + cnt=N-1 + +print(cnt)" +p02780,s167716691,Accepted,"import numpy as np +n,k = map(int,input().split()) + +p = np.array(input().split(),np.int) + + +fs = p[:k] +f = sum(fs) +m = n - k + 1 +qs = np.zeros(m) +qs[0] = f +if n == k: + ans = (f + k)/2 + print(ans) +else: + for i in range(k,n): + a = qs[i-k] - p[i-k] + p[i] + qs[i-k+1] = a + ans = (max(qs)+k) / 2 + print(ans) + +" +p04019,s731590357,Accepted,"import bisect,collections,copy,heapq,itertools,math,operator,string +def I(): return int(input()) +def S(): return input() +def LI(): return list(map(int,input().split())) +def LS(): return list(input().split()) +################################################## +S = S() +ans = 1 +if 'S' in S: + if not 'N' in S: + ans = 0 +if 'N' in S: + if not 'S' in S: + ans = 0 +if 'E' in S: + if not 'W' in S: + ans = 0 +if 'W' in S: + if not 'E' in S: + ans = 0 +print({1:'Yes',0:'No'}[ans]) +" +p03695,s866871702,Accepted,"from collections import Counter +n = int(input()) +x = list(map(int,input().strip().split())) + +rate = [] +over = 0 +for i in range(n): + if x[i]//400 >=8: + over += 1 + else: + rate.append(x[i]//400) +elem = len(set(rate)) + +_min = elem +_max = elem +over +if elem == 0: + _min = 1 +#if elem + over >=8: +# _max = 8 + +print(str(_min),str(_max))" +p02754,s595576628,Accepted,"N, A, B = map(int, input().split()) + +period = N // (A + B) +number = N % (A + B) + +if number >= A: + print(A * period + A) +else: + print(A * period + number)" +p03126,s543427718,Accepted,"N,M = map(int,input().split()) +E = [] +for i in range(N): + S = list(map(int,input().split())) + S.remove(S[0]) + L = list(set(S)) + + E.extend(L) +p = 0 +for j in range (M): + if E.count(j+1) == N: + p += 1 +print(p)" +p02982,s296470875,Accepted,"import math +n, d = map(int, input().split()) +arr = [] +ans = 0 +for i in range(n): + x = list(map(int, input().split())) + arr.append(x) + +p = [] +for i in range(n): + for j in range(n): + if i < j: + p.append([i, j]) + +for ij in p: + y = arr[ij[0]] + z = arr[ij[1]] + d = 0 + for i, j in zip(y, z): + d += (i - j) ** 2 + d = math.sqrt(d) + if d == int(d): + ans += 1 +print(ans)" +p02676,s583659118,Wrong Answer,"K = int(input(), 10) +S = input() + +if 0 < K < 101 and 0 < len(S) < 101: + if len(S) < K: + print(S) + else: + print(S[:K] + ""..."") +elif K > 100 or K < 1: + print(""Please choose an interger between 1 to 100"") +elif len(S) > 100 or len(S) < 1: + print(""Please enter at least at least 1 string and not more than 100"")" +p02797,s338810161,Accepted,"N, K, S = map(int, input().split()) +print(*([S]*K+[S+1 if S!=10**9 else S-1]*(N-K)))" +p02676,s195859820,Wrong Answer,"K = input() +S = input() +K = int(K) +if len(S) < K: + print(S) +else: + a = S[:K] + ""..."" + print(a) +" +p03693,s982107930,Accepted,"s="""".join(input().split()) +print(""YES"" if int(s)%4==0 else ""NO"") +" +p03163,s152274333,Accepted,"n,w=map(int,input().split()) +l=[list(map(int,input().split())) for i in range(n)] + +dp=[[0 for i in range(w+1)] for j in range(n+1)] + +for i in range(n): + for sum_w in range(w+1): + + if sum_w-l[i][0]>=0: + dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-l[i][0]]+l[i][1]) + + dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]) + +print(dp[-1][-1])" +p02732,s581597538,Wrong Answer,"import bisect + +n = int(input()) +a = list(map(int, input().split())) +A = sorted(a) +s = [0]*(n+1) +b = [0]*(n+1) +c = [] +for i in range(1, n+1): + x = a[i-1] + s[i] = bisect.bisect_right(A, x) - bisect.bisect_left(A, x) + if b[a[i-1]] == 0: + c.append(s[i]*(s[i]-1)//2) + b[a[i-1]] = 1 +S = sum(c) +print(c) +for i in range(1, n+1): + print(S - s[i] + 1)" +p02811,s489084718,Wrong Answer,"k,x = map(int, input().split()) +print('No' if x*500 t: + print(""No"") + break + t += A + if len(H) == 0: + print(""Yes"")" +p02836,s522135788,Wrong Answer,"s=input() +ans = 0 +for i in range(len(s)//2+1): + if s[i] != s[len(s)-1-i]: + ans+=1 +print(ans)" +p03760,s226440654,Accepted,"O = str(input()) +E = str(input()) +st = '' +if len(O) == len(E): + for i in range(len(O)): + st += O[i] + st+= E[i] + print(st) +else: + for i in range(len(O)-1): + st += O[i] + st+= E[i] + + print(st+O[-1]) + " +p02952,s085165453,Accepted,"n = int(input()) + +ans = 0 +for i in range(1, n + 1): + num = i + digits = 0 + while num: + digits += 1 + num //= 10 + if digits % 2 == 1: + ans += 1 + +print(ans) +" +p02951,s819390768,Accepted,"A,B,C=map(int,input().split()) + +if (A-B)>=C: + print(""0"") +else: + print(C-A+B)" +p02594,s652053822,Accepted,"#!/usr/bin/env python3 + +import sys +import math +from bisect import bisect_right as br +from bisect import bisect_left as bl +sys.setrecursionlimit(2147483647) +from heapq import heappush, heappop,heappushpop +from collections import defaultdict +from itertools import accumulate +from collections import Counter +from collections import deque +from operator import itemgetter +from itertools import permutations +mod = 10**9 + 7 +inf = float('inf') +def I(): return int(sys.stdin.readline()) +def LI(): return list(map(int,sys.stdin.readline().split())) + +x = I() +if x >= 30: + print('Yes') +else: + print('No')" +p03067,s337079862,Accepted,"A, B, C = map(int, input().split()) +print(""Yes"" if A < C < B or B < C < A else ""No"")" +p03814,s554580933,Accepted,"s = input() +revs = s[::-1] +MAX = 0 +for i in range(len(s)): + if s[i]==""A"": + begin = i + break + +for i in range(len(s)): + if revs[i]==""Z"": + end = i+1 + break +print(len(s)-end-begin+1)" +p02814,s854017777,Wrong Answer,"import fractions +from functools import reduce +n,m = map(int,input().split()) +a = list(map(int,input().split())) + +def lcm_base(x, y): + return (x * y) // fractions.gcd(x, y) +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +b = [i//2 for i in a] +c = lcm_list(b) + +if c > m: + print(0) +else: + d = m // c + if d % 2 == 0: + ans = d//2 + else : + ans = d//2 + 1 + print(ans) +" +p02814,s625070113,Accepted,"from fractions import gcd +def lcm(a,b): + return (a*b)//gcd(a,b) +n,m = map(int,input().split()) +a = list(map(int,input().split())) +ans = 1 +for i in a: + ans = lcm(ans,i) +for i in a: + if (ans//i) % 2 == 0: + print(0) + exit() +print(((m//(ans//2))+1)//2)" +p02987,s720241631,Accepted,"import collections + +s = list(input()) +c = collections.Counter(s) + +if len(c) == 2 and c.most_common()[0][1] == 2: + print(""Yes"") +else: + print(""No"")" +p02682,s492200258,Wrong Answer,"N = input().split() + +a =int(N[0]) +b =int(N[1]) +c =int(N[2]) +d =int(N[3]) + +A = min(a,d) + + + + +q = d - a + +if b < q: + print(A) +else: + print(A - d - a -b)" +p02601,s888441017,Accepted,"a, b, c = map(int,input().split()) +k = int(input()) + +for i in range(k): + if b <= a: + b *= 2 + elif c <= b: + c *= 2 + else: + break + +if a >= b or b >= c: + print('No') +else: + print('Yes')" +p02859,s781048833,Accepted,"r = int(input()) + +print(r * r)" +p03493,s819169942,Wrong Answer,"import sys + +def main(): + N = int(input()) + A = list(map(int, input().split())) + + t = 0 + while True: + for i in range(N): + if A[i] % 2 == 0: + A[i] //= 2 + else: + print(t) + sys.exit() + t += 1 +" +p03860,s812414654,Accepted,"s = input() +print(s[0] + s[8] + s[-7])" +p03624,s047850524,Accepted,"s = input() +for l in [chr(i) for i in range(97, 97+26)]: + if l not in s: + print(l) + exit() +print('None')" +p03557,s823572665,Accepted,"import sys +input=sys.stdin.readline +from bisect import bisect_right, bisect_left +n=int(input()) +a = [list(map(int, input().split())) for _ in range(3)] +a[0].sort() +a[2].sort() + + + +cnt=0 +for i in range(n): + index_1 = bisect_left(a[0],a[1][i]) + index_2 = n-bisect_right(a[2],a[1][i]) + cnt+=index_1*index_2 +print(cnt) +" +p02639,s364593366,Wrong Answer,"x = list(map(int, input().split())) +for i, item in enumerate(x): + if item == 0: + print(i) + break" +p03377,s430698478,Wrong Answer,"a, b, x = map(int,input().split()) + +if a+b > x: + if a < x: + print(""YES"") +else: + print(""NO"") +" +p02641,s108502866,Accepted,"def main(): + import sys + read = sys.stdin.buffer.read + readline = sys.stdin.buffer.readline + readlines = sys.stdin.buffer.readlines + sys.setrecursionlimit(10 ** 7) + + x, n = map(int, readline().split()) + p = list(map(int, readline().split())) + check = float('inf') + ans = 0 + for i in range(1000): + if i not in p: + if check > abs(x - i): + ans = i + check = abs(x - i) + print(ans) + + +if __name__ == '__main__': + main() +" +p02729,s497535370,Accepted,"def saiki(n): + + if n == 0: + return 0 + else: + return n + saiki(n - 1) + +def number(n , m): + + ans = saiki(n) + saiki(m) - n - m + + return ans + +def main(): + n , m = map(int , input().split()) + print(number(n , m)) + +if __name__ == '__main__': + main()" +p03543,s539358520,Accepted,"s = input() +print('Yes' if (s[0]==s[1]==s[2]) or (s[1]==s[2]==s[3]) else 'No')" +p02633,s881064191,Accepted,"from sys import stdin + +input = stdin.readline + +def main(): + X = int(input().rstrip()) + ans = 1 + n = X + while(n % 360 != 0): + n += X + ans += 1 + print(ans) + +if __name__ == ""__main__"": + main() + +" +p03836,s450805749,Accepted,"sx , sy , tx , ty = map(int,input().split()) +a = [] + +for _ in range(tx - sx): + a.append(""R"") +for _ in range(ty - sy): + a.append(""U"") +for _ in range(tx - sx): + a.append(""L"") +for _ in range(ty - sy): + a.append(""D"") + +a.append(""D"") + +for _ in range(tx - sx + 1): + a.append(""R"") +for _ in range(ty - sy + 1): + a.append(""U"") + +a.append(""L"") +a.append(""U"") + +for _ in range(tx - sx + 1): + a.append(""L"") +for _ in range(ty - sy + 1): + a.append(""D"") + +a.append(""R"") + +print("""".join(a))" +p03632,s334406004,Accepted,"A,B,C,D = map(int, input().rstrip().split()) +print(min([B, D]) - max([A,C]) if min([B, D]) - max([A,C]) > 0 else 0)" +p03475,s281423152,Accepted,"from sys import stdin +N=list(map(int,stdin.readline().strip().split()))[0] +eki=[list(map(int,input().split())) for _ in range(N-1)] + +for i in range(len(eki)): + x = eki[i][1]+eki[i][0] + for j in range(i+1,len(eki)): + if eki[j][1] >x: + x=eki[j][1] + x += eki[j][0] + elif x%eki[j][2]==0:x+=eki[j][0] + else: + x+=eki[j][0]+eki[j][2]-x%eki[j][2] + print(x) +print(0)" +p03799,s379268042,Accepted,"def solve(): + N, M = map(int, input().split()) + if M<=2*N: + ans = M//2 + else: + ans = N+(M-2*N)//4 + return ans +print(solve())" +p02779,s965552473,Wrong Answer,"import numpy as np + +n = int(input()) +A = [int(a) for a in input().split()] +A.sort() +A.append(-1) + +B = [-1] + A[:-1] + +A = np.array(A) +B = np.array(B) + +s = A-B +ans = len(np.nonzero(s)[0]) +if ans == n+1: + print(""Yes"") +else: + print(""No"")" +p02688,s757855293,Accepted,"N, K = map(int, input().split()) + +L = [0 for i in range(N+1)] + +for i in range(K): + d = int(input()) + LL = list(map(int, input().split())) + for j in range( len(LL) ): + L[ LL[j] ] += 1 + +ans = 0 +for i in range(1,N+1): + if L[i] == 0: + ans += 1 +print(ans)" +p03672,s631010920,Accepted,"#!/usr/bin/env python3 +import sys + + +def solve(S: str): + for i in reversed(range(1, len(S) // 2)): + if S[:i] == S[i:2 * i]: + print(2 * i) + return + + +def main(): + def iterate_tokens(): + for line in sys.stdin: + for word in line.split(): + yield word + tokens = iterate_tokens() + S = next(tokens) # type: str + solve(S) + + +if __name__ == '__main__': + main() +" +p02819,s849216208,Accepted,"x = int(input()) +for i in range(x, x+10**5): + for j in range(2, int(x**0.5)+1): + if i%j == 0: + break + else: + print(i) + break +" +p03127,s438245802,Accepted,"from fractions import gcd +from functools import reduce +n = int(input()) +a = list(map(int, input().split())) +print(reduce(gcd, a)) +" +p02880,s753915110,Accepted,"a = int(input()) +flag = 1 + +for i in range(1,10): + for j in range(1,10): + if i * j == a: + flag = 0 + +if flag == 0: + print(""Yes"") +else: + print(""No"")" +p03379,s826916789,Accepted,"import copy + +def main(): + N = int(input()) + X = [int(x) for x in input().split("" "")] + sortedX = copy.deepcopy(X) + sortedX.sort() + cand = [sortedX[int(N / 2) - 1], sortedX[int(N / 2)]] + + for xi in X: + if xi <= cand[0]: + print(cand[1]) + else: + print(cand[0]) + +main() +" +p02693,s674303341,Accepted,"k=int(input()) +a,b=map(int,input().split()) +for i in range(a,b+1): + if i%k==0: + print('OK') + exit() +print('NG')" +p03329,s941137276,Wrong Answer,"N = int(input()) +kouho = [1] +for i in range(1, 100): + t = 6 ** i + if t <= 10 ** 5: + kouho.append(t) + else: + break +for i in range(1, 100): + t = 9 ** i + if t <= 10 ** 5: + kouho.append(t) + else: + break +#print(kouho) + +kouho.sort(reverse=True) + +ans = 0 +cur = 0 +while N > 0: + if N >= kouho[cur]: + N -= kouho[cur] + ans += 1 + else: + cur += 1 +print(ans) +" +p03069,s441989322,Wrong Answer,"N = int(input()) +stones = input() + +w_cnt = stones.count('.') +b_cnt = N-w_cnt +first_bi = max(0, stones.find('#')) +last_wi = max(0, stones.rfind('.')) +pw_cnt = stones[first_bi:].count('.') +pb_cnt = stones[:last_wi].count('#') + +print(min(w_cnt, b_cnt, pw_cnt, pb_cnt))" +p03206,s689349560,Wrong Answer,"d = int(input()) +c = 'Christmas' +e = 'Eve' +if d == 25: + print(c) +elif d == 24: + print(c + e) +elif d == 23: + print(c + e + e) +else: + print(c + e + e + e)" +p03759,s847390916,Accepted,"# AtCoder abc058 a +# ストレッチ課題 + +# 入力 +a, b, c = map(int, input().split()) + +# 判定 +if (b - a) == (c - b): + print(""YES"") +else: + print(""NO"") +" +p03339,s815973409,Accepted,"n = int(input()) +s = input() + +left = [0] * n +right = [0] * n + +tmp = 0 +for i in range(1, n): + if s[i - 1] == ""W"": + tmp += 1 + left[i] = tmp + else: + left[i] = tmp + +tmp = 0 +for i in range(n - 2, -1, -1): + if s[i + 1] == ""E"": + tmp += 1 + right[i] = tmp + else: + right[i] = tmp + +res = 10**9 +for i in range(n): + res = min(res, left[i] + right[i]) +print(res) +" +p03548,s119050466,Accepted,"import math +import string + +def intinput(): + return int(input()) + +def listintinput(): + return list(map(int,input().split())) + +def splitintinput(): + return map(int,input().split()) + +X, Y, Z = splitintinput() +print(int((X-Z)/(Y+Z))) +" +p03286,s008070279,Accepted,"from collections import deque +import sys +input = sys.stdin.readline +import bisect as bi +from operator import mul +from functools import reduce +import math + +def main(): + n = int(input()) + n += 1 if n > 0 else -1 + + s = """" + while abs(n) > 1: + c = ""1"" if n % 2 == 0 else ""0"" + s = c+s + n = n // -2 + (0 if n > 0 else 1) + + print(0 if not s else s) +main() +" +p03971,s809001340,Accepted,"N,A,B=map(int,input().split()) +S=input() +t_count=0 +b_count=0 +flag=None + +for i in S: + if i==""c"": + print(""No"") + else: + if i==""a"": + t_count+=1 + if t_count<=A+B: + print(""Yes"") + else: + print(""No"") + else: + b_count+=1 + if b_count<=B: + t_count+=1 + if t_count<=A+B: + print(""Yes"") + else: + print(""No"") + else: + print(""No"")" +p02912,s247188450,Accepted,"import heapq as hq +n,m=input().split() +hq.heapify(a:=[-int(x) for x in input().split()]) +for i in range(int(m)):hq.heappush(a,-(-hq.heappop(a)//2)) +print(-sum(a))" +p03449,s642770360,Accepted,"import bisect,collections,copy,heapq,itertools,math,string +import sys +def S(): return sys.stdin.readline().rstrip() +def M(): return map(int,sys.stdin.readline().rstrip().split()) +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +def LS(): return list(sys.stdin.readline().rstrip().split()) +N = I() +A1 = LI() +A2 = LI() +ans = 0 +for i in range(N): + tmp = sum(A1[0:i+1]) + sum(A2[i:]) + ans = max(ans, tmp) +print(ans)" +p02607,s222649563,Wrong Answer,"a=int(input()) +lst=list(map(int,input().split())) +print(a,lst) +cnt=0 +for i in range(0,a,2): + if (lst[i] % 2==1) : + cnt+=1 + print(i) +print(cnt)" +p03103,s823290126,Accepted,"n,m=map(int,input().split()) +l=[] +for _ in range(n): + a,b=map(int,input().split()) + l.append([a,b]) +l.sort() +ans=0 +for a,b in l: + ans+=min(b,m)*a + m=max(0,m-b) +print(ans)" +p02690,s440381087,Accepted,"x = int(input()) + +div = set() +for i in range(1, int(x**0.5)+1): + if x % i == 0: + div.add(i) + div.add(x//i) + +div = list(div) + +for d in div: + for a in range(int(pow(x, 1/2))+1): + b = a - d + if a**5 - b**5 == x: + print(a, b) + break +" +p03380,s696597871,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) + +m = max(a) +res = 0 +ans = 0 +for i in a: + if i != m: + if abs(m//2-i) < res: + res = abs(m//2-i) + ans = i + +print(m,ans)" +p03565,s842547754,Wrong Answer,"s,t=input(),input() +ls=len(s) +lt=len(t) +ans='' +for i in range(ls-lt+1): + c=0 + for j in range(lt): + if s[i+j]==t[j] or s[i+j]=='?': + c+=1 + if c==lt: + ans=s[:i]+t+s[i+lt:] + print(ans.replace('?','a')) + break +else: + print('UNRESTORABLE')" +p03455,s224369653,Wrong Answer,"input_list = input().split(' ') +a = int(input_list[0]) +b = int(input_list[0]) + +N = a*b + +if N%2==0: + print('Even') +else: + print('Odd') + +del input_list" +p02612,s064201814,Accepted,"n = int(input()) +m = 1000 +while m < n: + m = m + 1000 +print(m-n)" +p02647,s933113154,Wrong Answer,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +for _ in range(k): + b = [0] * n + for i in range(n): + left = max(0, i - a[i]) + right = min(n-1, i + a[i]) + b[left] += 1 + if right + 1 < n: b[right + 1] -= 1 + + a[0] = b[0] + for i in range(1, n): + a[i] = a[i-1] + b[i] + + if k >= 20: + break + +print(*a)" +p02676,s865968488,Accepted,"K = int(input()) +S = input() + +ans = """" +if len(S) <= K: + ans = S +else: + ans = S[:K] + ""..."" + +print(ans)" +p02972,s522627791,Accepted,"n=int(input()) +A=list(map(int,input().split())) +choice=[0]*n +ans=[] +cnt=0 +for i in reversed(range(n)): + a=i+1 + c=0 + a+=i+1 + while a<=n: + c+=choice[a-1] + a+=i+1 + if c%2!=A[i]: + choice[i]+=1 + ans.append(i+1) + cnt+=1 +if cnt==0: + print(0) +else: + print(cnt) + ans.sort() + print(*ans, sep=' ')" +p02687,s897930845,Wrong Answer,"def awc(s): + print(""ARC"" if s == ""ABC"" else ""ABC"") + +if __name__ == ""__main__"": + import sys + in_str = [] + for line in sys.stdin: + in_str.append(line) + awc(in_str[0]) +" +p03017,s058174159,Accepted,"n, a, b, c, d = map(int, input().split()) +s = input() +flag1, flag2 = False, False +if d > c: + flag = ""##"" not in s[b: d] and ""##"" not in s[a: c] +else: + flag = ""..."" in s[b - 2: d + 1] + +print(""Yes"" if flag else ""No"")" +p02600,s379881103,Wrong Answer,"x = int(input()) +if x in range(400,599): + print(8) +if x in range(600,799): + print(7) +if x in range(800,999): + print(6) +if x in range(1000,1199): + print(5) +if x in range(1200,1399): + print(4) +if x in range(1400,1599): + print(3) +if x in range(1600,1799): + print(2) +if x in range(1800,1999): + print(1) +" +p02787,s109931940,Accepted," +h,n=map(int,input().split()) +a=[[int(i) for i in input().split()]for i in range(n)] +inf=10**9 +dp=[inf]*(h+1) #0-9 +dp[0]=0 +mini=inf +for i in range(h+1): + if dp[i]==inf: + continue + for ata,mp in a: + if i+ata>=h: + tmp=dp[i]+mp + mini=min(mini,tmp) + continue + dp[i+ata]=min(dp[i+ata],dp[i]+mp) +print(mini)" +p03997,s837824072,Accepted,"#ABC045.A +a = int(input()) +b = int(input()) +h = int(input()) +#面積を計算する +x = (a+b)*h//2 +print(x)" +p03073,s336322521,Wrong Answer,"s = list(input()) +n = len(s)-1 +a = [1]+[0]*n +b = [0]+[1]*n +difA = 0 +difB = 0 + +for i in range(1,n): + a[i] = 0 if a[i-1] == 1 else 1 + b[i] = 0 if b[i-1] == 1 else 1 + +for j in range(n+1): + if a[j] != int(s[j]): + difA += 1 + if b[j] != int(s[j]): + difB += 1 + +ans = min(difA,difB) + +print(ans)" +p02862,s066551609,Accepted,"mod = 10 ** 9 + 7 +x, y = map(int, input().split()) +a = (2 * y - x) // 3 +b = (2 * x - y) // 3 +if (x + y) % 3 != 0 or a < 0 or b < 0: + print(0) + exit() +n = a + b +r = min(a, b) +ans = 1 +for i in range(r): + ans = ans * (n - i) * pow(i + 1, mod - 2, mod) % mod +print(ans) + +" +p02547,s156124000,Accepted,"N = int(input()) +count = 0 +for i in range(N): + d1, d2 = map(int, input().split()) + if d1 == d2: + count += 1 + if count >= 3: + print(""Yes"") + break + else: + count = 0 +if count < 3: + print(""No"") +" +p03071,s251366517,Accepted,"import math +def ip():return int(input()) +def inp():return map(int,input().split()) +def inpstr():return map(str,input().split()) +def linp():return list(map(int,input().split())) +def linpstr():return list(map(str,input().split())) + +a,b=inp() +ans=0 +if a=b+w*t: + print('YES') + else: + print('NO') +else: + if b+w*t>=a+v*t: + print('YES') + else: + print('NO') +" +p02645,s198594719,Accepted,print(input()[:3]) +p03252,s251257639,Accepted,"s = list(input()) +t = list(input()) +n = len(s) + +s_par = [i for i in range(n + 1)] +t_par = [i for i in range(n + 1)] + +def operation(x, par): + for i in range(n): + for j in range(i): + if x[i] == x[j]: + par[i] = par[j] + break + return par + +if operation(s, s_par) == operation(t, t_par): + print('Yes') +else: + print('No')" +p02701,s408188707,Wrong Answer,"n = int(input()) +s = ["""" for i in range(n)] +ans = 0 +for i in range(n): + a = input() + s[i] = a +sorted(s) +ans = len(s) +for i in range (n): + if s[i] == s[i-1]: + ans -= 1 +print(ans)" +p03624,s943387866,Accepted,"S=input() +alf=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] +for i in range(len(S)): + if S[i] in alf: + alf.remove(str(S[i])) + +if len(alf)>0: + print(alf[0]) + exit() +print('None')" +p03617,s562039343,Accepted,"q,h,s,d=map(int,input().split()) +n=int(input()) +n*=4 +j=4*(2*q 0: + print('Negative') + else: + print('Positive')" +p03162,s641098890,Accepted,"n = int(input()) +a, b, c = [], [], [] +for _ in range(n): + ai, bi, ci = map(int, input().strip().split()) + a.append(ai) + b.append(bi) + c.append(ci) +dp = [] +dp.append((a[0], b[0], c[0])) +for i in range(1, n): + prev = dp[i-1] + chosen_a = a[i] + max(prev[1], prev[2]) + chosen_b = b[i] + max(prev[0], prev[2]) + chosen_c = c[i] + max(prev[0], prev[1]) + dp.append((chosen_a, chosen_b, chosen_c)) +res = dp[n-1] +print(max(res[0], res[1], res[2]))" +p02832,s144340748,Accepted,"N = int(input()) +A = list(map(int, input().split())) +min = 1 +check = True +count = 0 +for i in range(N): + if A[i] != min: + A[i] = 0 + count += 1 + elif A[i] == min: + min += 1 +if A == [0] * N: + print(-1) +else: + print(count)" +p02836,s797548806,Accepted,"s = input() +ans = 0 +for i in range(len(s)//2): + if s[i]!=s[-i-1]: + ans += 1 +print(ans)" +p02861,s588190534,Accepted,"n=int(input()) +city=[list(map(int,input().split())) for _ in range(n)] +length=[] +for i in range(n-1): + for j in range(i+1,n): + len=((city[i][0]-city[j][0])**2+(city[i][1]-city[j][1])**2) + length.append(len**(0.5)) +ans=sum(length)*2/n +print(""{:.7f}"".format(ans))" +p03778,s844656849,Wrong Answer,"W,a,b = map(int,input().split()) + +if b>=a+W: + print(b-a-W) +else: + print(a-b-W)" +p02786,s222533320,Wrong Answer,"H = int(input()) + +ans = 0 +n = 1 + +def calc(h,n): + a = h//2 + if a==1: + n += 2 + else: + n += 2*calc(a,n) + return n + + +if H == 1: + print(1) +else: + ans = calc(H,n) +print(ans)" +p03971,s354844834,Accepted,"N,A,B=map(int,input().split()) +S=input() +an=0 +bn=0 + +for i in list(S): + if i == ""a"" and an+bn10 or B>10: + print(-1) +else: + print(A*B) +" +p03407,s798025345,Wrong Answer,"def main(): + from sys import stdin, setrecursionlimit + #setrecursionlimit(10**6) + r = stdin.readline()[:-1] + #n = int(stdin.readline()[:-1]) + #r = [stdin.readline() for i in range(n)] + #t = [int(stdin.readline()) for i in range(n)] + + #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!' + #res = 0 + a, b, c = map(int, r.split()) + if a+b > c: + print('No') + else: + print('Yes') + #print() + +if __name__ == '__main__': + main() + +" +p03773,s266823026,Accepted,"a, b = (int(i) for i in input().split()) +print((a+b)%24)" +p02842,s162311062,Accepted,"n = int(input()) + +import math + +x = math.ceil(n / 1.08) +m = math.floor(x * 1.08) + +if m == n: + print(int(x)) +else: + print(':(')" +p02623,s215704712,Accepted,"N,M,K = map(int,input().split()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +tmpA = [0]*(N+1) +tmpB = [0]*(M+1) +ans = 0 + +import bisect +for i in range(1,N+1): + tmpA[i] = tmpA[i-1] + A[i-1] +for i in range(1,M+1): + tmpB[i] = tmpB[i-1] + B[i-1] +for i in range(N+1): + tmp = tmpA[i] + if tmp > K: + break + index = bisect.bisect_right(tmpB,K-tmp) + ans = max(i+index-1,ans) +print(ans)" +p02699,s112406786,Wrong Answer,"S,W=[int(i) for i in input().split()] +print(""unsafe"" if S= x for k in S[1:]]): + L.append(S[0]) + +if len(L) >0: + print(min(L)) +else: + print(-1) +" +p03971,s358834975,Accepted,"N, A, B = map(int, input().split()) +S = input() + +count_all = 0 +rank_b = 1 +for c in S: + if c == ""a"": + if count_all < (A + B): + print(""Yes"") + count_all += 1 + else: + print(""No"") + elif c == ""b"": + if count_all < (A + B) and (rank_b <= B): + print(""Yes"") + count_all += 1 + rank_b += 1 + else: + print(""No"") + elif c == ""c"": + print(""No"") +" +p04020,s452900543,Wrong Answer,"import math +N=int(input()) +ans=0 +flag=0 +for i in range(N): + a=int(input()) + ans+=a//2 + a%=2 + if a==1: + if flag: + ans+=1 + a-=1 + flag=0 + else: + flag=1 + else: + flag=0 +print(ans) + + " +p02623,s318998553,Accepted,"n,m,k=map(int,input().split()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +a, b = [0], [0] + +for i in range(n): + a.append(a[i] + A[i]) +for i in range(m): + b.append(b[i] + B[i]) + +ans, j = 0, m + +for i in range(n+1): + if a[i] > k: + break + while b[j] > k - a[i]: + j -= 1 + ans = max(ans, i + j) + +print(ans)" +p02627,s421261354,Accepted,"S=input() +if S.islower(): + print('a') +else: + print('A')" +p02790,s849955605,Accepted,"n,m=input().split() +if int(n)>int(m): + print(m*int(n)) +else: + print(n*int(m))" +p02771,s406867013,Accepted,"abc = [int(i) for i in input().split()] +if len(set(abc)) == 2: + print(""Yes"") +else: + print(""No"")" +p04011,s416806644,Accepted,"n=int(input()) +k=int(input()) +x,y=int(input()),int(input()) +if(n= 2000 else ""No"")" +p04011,s212885465,Accepted,"# 一泊X円、N(泊数)がK泊より多ければその分だけ一泊Y円 +N = int(input()) +K = int(input()) +X = int(input()) +Y = int(input()) +# K泊より多い場合はその分だけ単価Y円を掛ける +if N >= K: + total_price = K * X + (N - K) * Y +# K泊より少ない場合は泊数に単価X円を掛ける +else: + total_price = N * X + +print(total_price) +" +p02646,s253956562,Accepted,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) +if(VT*(V-W)): + print(""NO"") +else: + print(""YES"")" +p02693,s090790510,Accepted,"k = int(input()) +a, b = map(int, input().split()) + +ans = ""NG"" +for i in range(a, b + 1): + if i % k == 0: + ans = ""OK"" + break +print(ans) +" +p02572,s142610413,Accepted,"import math + +n = int(input()) +aL = list(map(int, input().split("" ""))) + +MOD = 10**9 + 7 + +aL2 = [aL[-1]] +for a in reversed(aL[:-1]): + aL2.append((aL2[-1] + a) % MOD) +aL2 = list(reversed(aL2)) + +ans = 0 +for i in range(n - 1): + ans += aL[i] * aL2[i + 1] + ans %= MOD + +print(ans)" +p02933,s157848475,Accepted,"a = int(input()) +s = input() +if a >= 3200: + print(s) +else: + print(""red"")" +p02683,s697493823,Accepted,"n, m, x = map(int, input().split()) +a = [[] for i in range(n)] +c = [0] * n +for i in range(n): + c[i], *a[i] = map(int, input().split()) +ans = 1e9 +for mask in range(2 ** n): + cost = 0 + b = [0] * m + for i in range(n): + if mask & (1 << i): + cost += c[i] + for j in range(m): + b[j] += a[i][j] + cnt = True + for j in range(m): + cnt &= b[j] >= x + if cnt: + ans = min(ans, cost) + +if ans < 1e9: + print(ans) +else: + print(-1) +" +p03380,s769861290,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a.sort() +ans = 0 +max_a = max(a) +del a[-1] +target = int(1e9+1) +for aa in a: + if abs(max_a - target*2) >= abs(max_a - aa*2): + target = aa +print(max_a, target) +" +p04044,s356003707,Accepted,"N,L = map(int,input().split()) +S = [input() for i in range(N)] +S.sort() +ans = """".join(S) +print(ans)" +p02983,s655005073,Wrong Answer,"L, R = map(int, input().split()) + +L2 = L%2019 +R2 = R%2019 + +if L2 == 0 or R2 == 0: + print(0) + exit() + +if L + 2019 < R: + print(0) + exit() + +length = abs(R2-L2+1) +ans = [] +for i in range(length): + if L2 < R2: + k = (L2+i) % 2019 + ans.append(k) + elif L2 > R2: + k = (R2+i) % 2019 + ans.append(k) + +list.sort(ans) +print(ans) +print((ans[0]*ans[1])%2019)" +p03617,s042822386,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) + +min_1l = min([4 * Q, 2 * H, 1 * S]) +min_2l = min([8 * Q, 4 * H, 2 * S, D]) + +ans = 0 +if min_2l == D: + ans = D * (N // 2) + (N % 2) * min_1l +else: + ans = N * min_1l + +print(ans) +" +p02923,s934960512,Accepted,"n = int(input()) +h = list(map(int, input().split())) +t = 0 +result = 0 +for i in range(n - 1): + if h[i + 1] <= h[i]: + t += 1 + else: + result = max(t, result) + t = 0 +result = max(t, result) +print(result)" +p03239,s502889324,Wrong Answer,"N, T = map(int, input().split()) +M = 10000 +for n in range(N): + c, t = map(int, input().split()) + if T >= t: + M = min(M, c) +print(M) +" +p02691,s475533950,Wrong Answer,"N=int(input()) +a=input().split() +A=[int(number) for number in a] +pluss=[] +minuss=[] +number=1 +for a in A: + plus=a+number + minus=abs(a-number) + pluss.append(plus) + minuss.append(minus) + number+=1 +answer=0 +suuji=0 +for n in pluss: + answers=minuss[suuji:] + answer+=answers.count(n) + suuji+=1 + + +print(answer) + +" +p02900,s372341892,Accepted,"def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + +a, b = map(int, input().split()) +print(len(set(prime_factorize(a)) & set(prime_factorize(b))) + 1)" +p03043,s515061837,Accepted,"import math +n, k = map(int, input().split()) +ans = 0.0 +if n >= k: + ans += (n-k+1)/n + +for i in range(1, min(n+1, k)): + now = i + p = 1/n + while(now = 0 and C <= c: + cnt += 1 + +print(cnt)" +p02708,s730209253,Accepted,"n, k = map(int, input().split()) +MOD = 1e9+7 + +def s(i,n): + s1 = (2 * i * i) + s2 = (3 * n * (i+1)) + s3 = 8 + + d = (s2 + s3 - s1) + + ans = ( int((i * d)/6 + 0.5) ) + + return ans + +ans = int(s(n+1,n) - s(k-1,n)) % MOD +if ans < 0: + ans += MOD + +print(int(ans))" +p02623,s266673299,Accepted,"a,b,k = map(int,input().split()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +from itertools import accumulate + +A = list(accumulate(A)) +B = list(accumulate(B)) +A = [0] + A +B = [0] + B + +ans = 0 +num = b +for i in range(a+1): + if A[i] > k: + continue + while True : + if A[i] + B[num] > k: + num -=1 + else: + ans = max(ans,i+num) + break +print(ans)" +p03644,s841013245,Accepted,"N = int(input()) + +l = [i for i in range(1, N+1)] +l1 = l.copy() +c = [0]*N + +while True: + exist_even = False + for i in range(N): + if l[i] % 2 == 0: + exist_even = True + if not exist_even: + break + + for i in range(N): + if l[i] % 2 == 0: + l[i] = l[i] // 2 + c[i] += 1 + +idx = c.index(max(c)) +print(l1[idx])" +p03417,s599687119,Wrong Answer,"N,M = map(int,input().split()) + +if(N==1): + if M==1: + print(1) + elif M==2: + print(0) + else: + print(M-2) +elif(N==2): + print(0) +else: + if M==1: + print(1) + elif M==2: + print(0) + else: + print((N-2)*(M-2))" +p02795,s073260864,Accepted,"import math + +h = int(input()) +w = int(input()) +n = int(input()) + +if h > w: + h, w = w, h +print(math.ceil(n / w))" +p02646,s161849130,Accepted,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) + +L = abs(A-B) +S = V - W +if S * T >= L: + print(""YES"") +else: + print(""NO"") +" +p03323,s414744787,Accepted,"a, b = map(int, input().split()) + +if a>8 or b>8: + print(':(') +else: + print('Yay!')" +p02577,s068562241,Wrong Answer,"def solve(s): + suma = 0 + for x in s: + suma += int(x) + if suma % 9 == 0: + print(""YES"") + else: print(""NO"") +s = input() +solve(s)" +p04031,s194399879,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) + +def minimize(list): + min = 0 + for i in range(-100,101): + num = 0 + for j in range(len(list)): + num = num + (int(list[j]) - i)**2 + if min == 0: + min = num + elif min > num: + min = num + return min + +print(minimize(a))" +p02747,s755880579,Accepted,"#coding:utf-8 + +import queue + + + +def main(): + s = input() + t = '' + for _ in range(10): + t += 'hi' + if t == s: + print('Yes') + break + else: + print('No') + +if __name__ == '__main__': + main()" +p03327,s102434560,Wrong Answer,"n = int(input()) +ans = 'AB' +if n <= 999: + ans += 'C' +else: + ans += 'D' + n -= 999 +print(ans+'{:03}'.format(n)) + +" +p03951,s236770478,Wrong Answer,"from collections import defaultdict +from collections import deque +import itertools +import math + +def readInt(): + return int(input()) +def readInts(): + return list(map(int, input().split())) +def readChar(): + return input() +def readChars(): + return input().split() + +n = readInt() +s = input() +t = input() + +if s==t and len(s)>=n: + print(n) + exit() +if n>=len(s)+len(t): + print(n) + exit() + +de = 0 +for i in range(min(len(s),len(t))): + if s[i*-1-1]==t[i]: + de+=1 + else: + break + +print(len(s)+len(t)-de)" +p03474,s062294491,Accepted,"a,b = map(int,input().split()) +s = list(input()) +for i in range(a+b+1): + if i < a and not s[i].isdigit(): + print('No') + exit() + elif i == a and s[i] != '-': + print('No') + exit() + elif i > a and not s[i].isdigit(): + print('No') + exit() +print('Yes')" +p03380,s268339858,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a.sort() +M = max(a) +m = M / 2 + +diff = 10 ** 9 +r = None +for i in range(n): + if a[i] == M: + continue + else: + if abs(m - a[i]) < diff: + diff = abs(m - a[i]) + r = a[i] + +print(M, r) +" +p02880,s942818207,Wrong Answer,"a = int(input()) +for n in range(1,9): + for k in range(1,9): + if n*k==a: + print('Yes') + break + else: + continue + break +else: + print('No') +" +p03814,s675236458,Wrong Answer,"s=list(input()) +ans,c,f=0,0,0 +for i in range(len(s)): + if s[i]=='A' and f==0:f=1 + if f==1: c+=1 + if i x * x + y * y: + cnt += 1 + +print(cnt)" +p03254,s640284546,Wrong Answer,"N, x = map(int, input().split()) +a = list(map(int, input().split())) +a.sort() + +count = 0 +for ai in a: + if ai <= x: + x -= ai + count += 1 + else: + break + +if x > 0: + count -= 1 + +print(count)" +p03680,s310318142,Accepted,"n = int(input()) +l = list(int(input()) for _ in range(n)) +num = 1 +ans = -1 + +for i in range(n): + if num == 2: + ans = i + break + num = l[num-1] +print(ans)" +p03611,s841041569,Accepted,"N = int(input()) +A = list(map(int, input().split())) +dic = {} +for a in A: + if a in dic: + dic[a] += 1 + else: + dic[a] = 1 + if a-1 in dic: + dic[a - 1] += 1 + else: + dic[a - 1] = 1 + if a + 1 in dic: + dic[a + 1] += 1 + else: + dic[a + 1] = 1 +m = 0 +for v in dic.values(): + if m < v: + m = v +print(m)" +p03785,s096911217,Wrong Answer,"n, c, k = map(int, input().split()) +tList = [int(input()) for _ in range(n)] +tList.sort() +ans = [] +while 1: + limit = tList[0] + k + for i in range(min(c, len(tList))): + mark = i + if tList[i] > limit: + break + ans.append(tList[:mark + 1]) + tList = tList[mark + 1:] + if tList == []: + break +print(len(ans))" +p02603,s797109901,Wrong Answer,"n, *a = map(int, open(0).read().split()) +a += 1, +m = 1000 +from itertools import* +for i in [list(k) for p, k in groupby(range(n+1), key = lambda j:a[j] >= a[j-1]) if p]: + m = m // a[i[0]] * a[i[-1]] + m % a[i[0]] +print(m)" +p03774,s083979411,Accepted,"n,m=map(int,input().split()) +student=[] +for _ in range(n): + a,b=map(int,input().split()) + student.append([a,b]) + +checkpoint =[] +for _ in range(m): + c,d = map(int,input().split()) + checkpoint.append([c,d]) + +for i in range(n): + s = student[i] + dist = float('inf') + + num=0 + for j in range(m): + c=checkpoint[j] + tmp = abs(s[0]-c[0]) + abs(s[1]-c[1]) + + if tmp < dist: + dist = tmp + num=j+1 + + print(num) + +" +p02687,s141255519,Accepted,"s = str(input()) + +if s == ""ABC"": + print(""ARC"") +else: + print(""ABC"") +" +p02711,s836267259,Wrong Answer,"N = 127 +N = str(N) +list_N = list(N) +list_N = [int(s) for s in list_N] +print(list_N) + +if(list_N[0] != 7 and list_N[1] != 7 and list_N[2] != 7): + print(""No"") +else: + print(""Yes"")" +p03035,s011550817,Wrong Answer,"A,B = map(int,input().split()) + +if A >= 13: + print(B) +elif 6<=A<=12: + print(B/2) +else: + print(""0"")" +p02923,s049672107,Accepted,"N = int(input()) +H = list(map(int,input().split())) +b = [0]*N +mb = 0 +for i in range(N-2,-1,-1): + if H[i+1] <= H[i]: + b[i] = b[i+1]+1 + else: + b[i]= 0 + mb = max(mb,b[i]) +print(mb) +" +p02970,s040843799,Accepted,"import math +N,D = map(int,input().split()) +print(math.ceil(N/(D*2+1)))" +p02814,s309716774,Accepted,"from fractions import gcd +n,m=map(int,input().split()) +*a,=map(int,input().split()) + +g=a[0] +lcm=a[0] + +for i in range(1,n): + g=gcd(lcm,a[i]) + lcm*=a[i] + lcm//=g + +for i in range(n): + if lcm//a[i]%2==0: + print(0) + exit(0) + +print((2*m//lcm+1)//2)" +p02552,s515084122,Accepted,print(1-int(input())) +p02848,s215832508,Wrong Answer,"N=int(input()) +S=input() +ans="""" +for s in S: + if ord(""Z"") < ord(s)+N: + ans+=chr(ord(""A"")+ord(""Z"")-(ord(s)+N)) + else: + ans+=chr(ord(s)+N) +print(ans)" +p02861,s044226263,Accepted,"import math + +n=int(input()) +M=[] +for i in range(n): + x,y=map(int,input().split()) + M.append([x,y]) + +D=[] +for i in range(n-1): + for j in range(i+1,n): + D.append(math.sqrt((M[i][0]-M[j][0])**2+(M[i][1]-M[j][1])**2)) + +print(sum(D)*2/n)" +p03208,s229675472,Wrong Answer,"n,k=map(int,input().split()) +h=[int(input())for _ in range(n)] +h.sort() +ls=[] + +for i in range(n-2): + ls+=str(abs(h[i]-h[i+2])) + +print(min(ls))" +p02597,s864614399,Wrong Answer,"n=int(input()) +s=input() + +cntw=[0]*(n+1) +totr=0 +totw=0 + +for i in range(n): + if s[i]=='W': + cntw[i+1]=cntw[i]+1 + totr+=1 + else: + cntw[i+1]=cntw[i] + totw+=1 +ans=10**6 +for i in range(n): + w=cntw[i] + r=n-i-(totw-cntw[i]) + ans=min(ans,max(w,r)) + +print(ans)" +p03274,s684485538,Wrong Answer,"#!/usr/bin/env python +# coding: utf-8 + +# In[26]: + + +N,K = map(int, input().split()) +x = list(map(int, input().split())) + + +# In[33]: + + +ans = max([abs(y) for y in x]) +for i in range(N-K+1): + tmp = x[i:i+K] + ans = min(abs(tmp[0])+(tmp[K-1]-tmp[0]),abs(tmp[K-1])+(tmp[K-1]-tmp[0])) +print(ans) + + +# In[ ]: + + + + +" +p03773,s910593738,Wrong Answer,"a, b = map(int, input().split()) +if a + b > 24: + print((a + b) - 24) +else: + print(a + b)" +p03359,s664982837,Accepted,"import sys +import math + +a,b = map(int, input().split()) +if (b 1e+18: + print(-1) + break + else: + print(prod) + +if __name__ == ""__main__"": + main()" +p02647,s066327488,Accepted,"N,K = map(int,input().split()) +A = list(map(int,input().split())) + +for k in range(1,min(K+1,45)): + B = [0]*N + for i in range(N): + l = max(0,i-A[i]) + r = min(N-1,i+A[i]) + B[l] += 1 + if r+1 < N: + B[r+1] -= 1 + + for i in range(1,N): + B[i] += B[i-1] + A = B +print(*A)" +p04005,s932487120,Wrong Answer,"import sys +sys.setrecursionlimit(10**6) + +a=list(map(int,input().split())) + +newa=sorted(a) + +#print(a) +#print(newa) +#print(newa[2]) + +if newa[2]%2==0 or newa[1]%2==0 or newa[0]%2==0: + print(""0"") +else: + print(a[0]*a[1])" +p03815,s565443280,Accepted,"x = int(input()) +print(2 * (x // 11) + ((x % 11 - 1) // 6 + 1))" +p03852,s356474383,Wrong Answer,"A=input() +if A==""a"": + print(""vowel"") +if A==""i"": + print(""vowel"") +if A==""u"": + print(""vowel"") +if A==""e"": + print(""vowel"") +if A==""o"": + print(""vowel"") +else : + print(""consonant"")" +p02691,s670864794,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int, input().split())) +l = [i + a[i] for i in range(n)] +r = [i - a[i] for i in range(n)] +countl = Counter(l) +countr = Counter(r) +ans = sum([countl[i]*countr[i] for i in countl.keys()]) +print(ans)" +p03407,s890379280,Accepted,"a, b, c = map(int, input().split()) +print('Yes' if a + b >= c else 'No')" +p02597,s071098404,Wrong Answer,"N = int(input()) +c = input() +ans = 0 +fs = 0 +ls = N - 1 +for _ in range(N): + for i, ci in enumerate(c[fs:ls]): + if ci == 'W': + break + fs += 1 + for i , ci in enumerate(c[fs:ls:-1]): + if ci == 'R': + break + ls -= 1 + if fs == ls: + break + ans += 1 + fs += 1 + ls -= 1 + #print(c[fs:ls] + 1) + if len(c[fs:ls + 1]) <= 1: + break +print(ans) + +" +p03795,s091176908,Wrong Answer,"n = int(input()) +if 1 <= n < 100: + ans = 800 * n - 200 * (n // 15) + print(ans)" +p03827,s633384664,Accepted,"n = int(input()) +s = input() + +x = 0 + +ans = 0 +for c in s: + if c == ""I"": + x += 1 + else: + x -= 1 + ans = max(x, ans) + +print(ans) +" +p03262,s789543332,Wrong Answer,"import fractions +n,x = map(int,input().split()) +s = set(map(int,input().split())) +s.add(x) +l = list(s) +l.sort() +t = set([]) +for i in range(len(l)-1): + t.add(l[i+1]-l[i]) +u = list(t) +if len(u) == 1: + print(u[0]) + exit() +y = fractions.gcd(u[0],u[1]) +if len(u) == 2: + print(y) + exit() +else: + for i in range(1,len(u)-1): + y = fractions.gcd(y,l[i+1]) + print(y)" +p02765,s810987064,Accepted,"n, r= map(int, input().split()) +ans = 0 +if n < 10: ans = 100 * (10 - n) + r +else: ans = r +print(ans)" +p02660,s680908898,Accepted,"def factorization(n): + arr = [] + temp = n + for i in range(2, int(-(-n**0.5//1))+1): + if temp%i==0: + cnt=0 + while temp%i==0: + cnt+=1 + temp //= i + arr.append(cnt) + if temp!=1: + arr.append(1) + if n==1: + arr.append(0) + return arr +def kak(n): + return ((1+8*n)**(1/2)-1)//2 + +A=factorization(int(input())) +print(int(sum([kak(i) for i in A])))" +p03360,s825836909,Accepted,"a = list(map(int, input().split())) +k = int(input()) + +am = max(a) +mp = a.index(am) + +for i in range(k): + am = am*2 + +a[mp] = am +print(sum(a))" +p03711,s817338062,Accepted,"x, y = map(int, input().split()) + +l = [4,6,9,11] +t = [1,3,5,7,8,10,12] + + +if x == y: + print(""Yes"") +elif x in l and y in l or x in t and y in t: + print(""Yes"") +else: + print(""No"") + +" +p02660,s882246835,Accepted,"import math +n = int(input()) +lis = [] +for i in range(2,math.ceil(math.sqrt(n))+1): + cnt = 0 + while n % i == 0: + n //= i + cnt += 1 + if cnt:lis.append(cnt) +if n != 1: + lis.append(1) +ans = 0 + +if lis == []: + if n == 1: + print(0) + exit() + else: + print(1) + exit() +for num in lis: + go = 1 + while num >= go: + ans += 1 + num -= go + go += 1 +print(ans) +" +p02675,s626760470,Accepted,"s = int(input()) + +if s % 10 == 2 or s % 10 == 4 or s % 10 == 5 or s % 10 == 7 or s % 10 == 9: + print(""hon"") +elif s % 10 == 0 or s % 10 == 1 or s % 10 == 6 or s % 10 == 8: + print(""pon"") +else: + print(""bon"") +" +p03062,s437173466,Accepted,"n = int(input()) +l = [int(i) for i in input().split()] + +total = 0 +ct = 0 +min_num = 10**9 +for i in l: + total += abs(i) + ct += 1 if i < 0 else 0 + min_num = min(min_num,abs(i)) + +if ct%2: + print(total - min_num*2) +else: + print(total)" +p03038,s444048822,Accepted,"from collections import Counter +N, M = map(int, input().split()) +cnt = Counter(map(int, input().split())) + +for _ in range(M): + B, C = map(int, input().split()) + cnt[C] += B + +ans = 0 +for n, c in sorted(cnt.items(), reverse=True): + if N == 0: + break + mi = min(c, N) + ans += mi * n + N -= mi +print(ans) +" +p02690,s561809628,Accepted,"import itertools +X = int(input()) + +l = [i for i in range(-1000, 1000)] +c = itertools.permutations(l, 2) +for a, b in c: + if a**5 - b**5 == X: + print(a, b) + break +" +p02963,s607530665,Wrong Answer,"s = int(input()) +q, r = divmod(s, 10**9) +print(0, 0, 10**9, 10**9-r, 1, q+1)" +p03433,s597373090,Accepted,"n=int(input()) +a=int(input()) +if n%500<=a: + print('Yes') +else: + print('No')" +p03543,s074554215,Accepted,"s = input() +if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]: + print('Yes') +else: + print('No') +" +p03163,s259115619,Wrong Answer,"n, w = map(int, input().split()) +a = [[int(i) for i in input().split("" "")] for j in range(n)] +dp = [[0]*(w+1) for i in range(n+1)] +for i in range(1, n+1): + w_, v_ = a[i-1] + for j in range(1, w+1): + if j < w_: + dp[i][j] = dp[i-1][j] + else: + dp[i][j] = max(dp[i-1][j-w_]+v_, dp[i-1][w]) +print(dp[n][w])" +p03472,s230493502,Accepted,"import sys +import math +input=sys.stdin.readline + +n,h=map(int,input().split()) + +once=[] +infinity=[] + +for i in range(n): + a,b=map(int,input().split()) + once.append(b) + infinity.append(a) + +once.sort(reverse=True) + +pin=max(infinity) + +once2=[] +for i in range(n): + if once[i]>pin: + once2.append(once[i]) + + else: + break + +ans=0 +for i in once2: + ans+=1 + h-=i + if h<=0: + print(ans) + exit() + +ans+=math.ceil(h/pin) + + +print(ans) + " +p02600,s394065073,Accepted,"N = int(input()) +kyu = 1 +for i in range(1800, 0, -200): + if i <= N: + break + kyu += 1 +print(kyu) +" +p02711,s561874389,Accepted,"N=input() +if ""7"" in N: + print(""Yes"") +else: + print(""No"")" +p03107,s918917906,Wrong Answer,"s=list(input()) +from collections import Counter +d=Counter(s) +print(min(d[0], d[1]))" +p03836,s775873384,Accepted,"p,q,x,y=map(int,input().split()) +x-=p +y-=q +u='U'*y+'R'*x +d='D'*y+'L'*x+'LU' +print(u+d+u+'RDRD'+d)" +p02792,s769398116,Accepted,"N = int(input()) +c = [] +for i in range(10): + c.append([0] * 10) +for i in range(N): + s = str(i+1) + i1 = int(s[0]) + i2 = int(s[-1]) + c[i1][i2] += 1 +total = 0 +for i in range(10): + for j in range(10): + total += c[i][j] * c[j][i] +print(total)" +p03943,s424932638,Accepted,"s = list(map(int, input().split())) +s.sort() +print('Yes' if s[0] + s[1] == s[2] else'No')" +p02554,s928913753,Accepted,"n=int(input()) +ans=10**n-2*9**n+8**n +print(ans%(10**9+7)) +" +p03659,s265151404,Accepted,"N = int(input()) +a = list(map(int,input().rstrip().split("" ""))) +K = sum(a) +now = 0 +ans = 10 ** 15 +for i in range(N -1): + now += a[i] + K -= a[i] + ans = min(ans,abs(K - now)) +print(ans)" +p02775,s032268039,Accepted,"l = list(input()) +l2 = [] +for i in l[::-1]: + l2.append(int(i)) + +l2.append(0) +count = 0 + +for i in range(len(l2)): + if l2[i] <= 4: + count += l2[i] + elif l2[i] == 5: + if l2[i+1] <=4: + count += 5 + else: + count += 5 + l2[i+1] += 1 + else: + count += 10-l2[i] + l2[i+1] += 1 +print(count)" +p03548,s163013136,Accepted,"X, Y, Z = map(int, input().split()) +ans = 0 + +X -= Z +while True: + if X >= Y+Z: + ans += 1 + X -= (Y+Z) + else: + break + +print(ans) +" +p02784,s757287364,Wrong Answer,"hp,kind = input().split("" "") +sp_atk = [int(i) for i in input().split()] + +if int(hp) < sum(sp_atk): + print(""Yes"") +else: + print(""No"")" +p03319,s100569241,Accepted,"import math +n,k = map(int, input().split()) +a = list(map(int,input().split())) +for i in range(n): + if n/(k+((k-1)*i)) <= 1: + print(i+1) + break" +p02696,s254236900,Accepted,"a, b, n = list(map(int, input().split())) +if n < b: + t = n +else: + t = b - 1 +mx = a * (t) // b - a * ((t) // b) +print(mx) +" +p03469,s375580648,Wrong Answer,"s = input() +if s[:4] != ""2018"": + s = ""2018"" + s[3:] +print(s)" +p03042,s603999512,Accepted,"S = input() +f = int(S[:2]) +s = int(S[2:]) +if 1 <= f <= 12: + if 1 <= s <= 12: + print('AMBIGUOUS') + else: + print('MMYY') +elif 1 <= s <= 12: + print('YYMM') +else: + print('NA') +" +p02627,s304771482,Accepted,"alphabet=input() # 入力アルファベット + +if alphabet.isupper(): # 入力アルファベットが大文字のとき + print(""A"") +else: # 小文字のとき + print(""a"")" +p02993,s295291917,Accepted,"S = input() +for i in range(len(S) - 1): + if (S[i] == S[i + 1]): + print('Bad') + exit(0) +print('Good') +" +p03042,s502975304,Accepted,"def solve(): + S = input() + l = int(S[:2]) + r = int(S[2:]) + + if 1 <= l <= 12: + if 1 <= r <= 12: + return 'AMBIGUOUS' + else: + return 'MMYY' + else: + if 1 <= r <= 12: + return 'YYMM' + else: + return 'NA' + +print(solve())" +p02706,s734864579,Accepted,"n,m = map(int, input().split()) +l = list(map(int, input().split())) +a = sum(l) + +if a > n: + print('-1') +else: + print(n - a)" +p02640,s421848113,Accepted,"import sys +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines + +def main(): + x,y = map(int, readline().split()) + + a = 4 * x - y + b = y - 2 * x + + if a % 2 == 0 and b % 2 == 0: + if a >= 0 and b >= 0: + print(""Yes"") + else: + print(""No"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main() +" +p02660,s082610859,Accepted,"from collections import Counter + +def prime_fact(n): + P = [] + for i in range(2, int(n**0.5)+1): + while n % i == 0: + P.append(i) + n //= i + if n != 1: + P.append(n) + return P + +n = int(input()) +cnt = Counter(prime_fact(n)) +#print(cnt) + +ans = 0 +for c in cnt.values(): + tmp = 1 + while c >= tmp: + c -= tmp + ans += 1 + tmp += 1 + +print(ans)" +p02811,s707539070,Accepted,"def f(A,B): + if A*500>=B: + return ""Yes"" + else: + return ""No"" +A,B=map(int,input().split()) +print(f(A,B))" +p03544,s537245755,Accepted,"n=int(input()) +def fibonacci(n): + fib = [2, 1] + for i in range(2, n): + fib.append(fib[i - 2] + fib[i - 1]) + + return fib[n -1] +print(fibonacci(n+1))" +p03699,s594376950,Accepted,"n = int(input()) +s = [int(input()) for i in range(n)] +s.sort() +if sum(s) % 10 != 0: + print(sum(s)) +else: + for i in range(n): + if s[i] % 10 != 0: + print(sum(s)-s[i]) + exit() + print(0)" +p02795,s191631266,Accepted,"H,W,N=[int(input()) for i in range(3)] +print(-(-N//max(H,W)))" +p02639,s734750268,Wrong Answer,"x=list(map(int,input().split())) +for i in range(4): + if x[i]==0: + print(i+1) + break +" +p03838,s081704213,Wrong Answer,"x, y = map(int, input().split()) +ans = abs(abs(x)-abs(y)) +if x < 0 and y < 0: + if x > y: + ans += 2 +elif x < 0 or y < 0: + ans += 1 +print(ans)" +p03814,s117393340,Accepted,"S=input() + +for i in range(len(S)): + if S[i]=='A': + S=S[i:] + break + +for i in range(len(S)-1,0,-1): + if S[i]=='Z': + S=S[:i+1] + break + +print(len(S))" +p02899,s894785206,Accepted,"N = int(input()) +A = list(map(int, input().split())) +Ans = [0]*N + +for i, a in enumerate(A): + Ans[a-1] = str(i+1) + +print(' '.join(Ans)) +" +p02795,s902297418,Accepted,"h=int(input()) +w=int(input()) +n=int(input()) +if h M: + break + +if Y > M: + print(-1) +else: + print(Y)" +p03012,s515168572,Wrong Answer,"a = list(map(int,input().split())) +difference = 100 +for i in range(len(a)): + if abs(sum(a[:i]) - sum(a[i:])) < difference: + difference = abs(sum(a[:i]) - sum(a[i:])) +print(difference) +" +p02881,s272948374,Wrong Answer,"n=int(input()) +ans=10**12 +a=1 +while n**0.5>a: + if a*(n//a)==n: + ans=min(ans,a+n//a-2) + a+=1 +print(ans) +" +p02935,s003365013,Accepted," + +n = int(input()) + +A = sorted([int(x) for x in input().split()]) + +a = (A[0] + A[1]) / 2 + +for q in A[2:]: + a = (a + q) / 2 + +print(a) +" +p03681,s014998038,Accepted,"N, M = map(int, input().split()) + +MOD = 1000000007 + +if abs(N - M) > 1: + print(0) + exit(0) + +dogs = 1 +for i in range(1, N + 1): + dogs *= i + dogs %= MOD + +monks = 1 +for i in range(1, M + 1): + monks *= i + monks %= MOD + +res = (dogs * monks) % MOD +if (N + M) % 2 == 0: + res *= 2 + res %= MOD + +print(res) +" +p02948,s387155753,Wrong Answer,"N, M = map(int, input().split()) +AB = [] +for i in range(N): + tmp = list(map(int, input().split())) + eff = [tmp[1]/tmp[0]] + AB.append(eff+tmp) +AB.sort(reverse=True) +#print(AB) + +left_data = M-1 +i = 0 +r = 0 +while left_data > 0: + if AB[i][1] <= left_data: + r += AB[i][2] + left_data -= 1 + else: + i += 1 + if i == N: + break +print(r) +" +p02678,s105312298,Accepted,"import heapq + +N, M = list(map(int, input().split())) +path = [[] for _ in range(N + 1)] +for _ in range(M): + A, B = list(map(int, input().split())) + path[A].append(B) + path[B].append(A) + +#print(N, M, path) + +hq = [(0, 0, 1)] + +mark = [None] * (N + 1) + +while hq: + cost, prev, node = heapq.heappop(hq) + #print(cost, prev, node) + if not mark[node]: + mark[node] = prev + for nxt in path[node]: + heapq.heappush(hq, (cost + 1, node, nxt)) + +if all(mark[2:]): + print('Yes') + for m in mark[2:]: + print(m) +else: + print('No')" +p02641,s290116516,Wrong Answer,"x, n = map(int, input().split()) +p = [int(_) for _ in input().split()] + +arr = [0] * 1000 +for i in p: + arr[i] = 1 + +ans1 = 0 +for i in range(x, 0, -1): + if arr[i] == 0: + ans1 = i + break + +#print(arr) + +ans2 = 0 +for i in range(x, 102): + if arr[i] == 0: + ans2 = i + break + +if ans1 == 0: + print(ans2) +else: + if abs(ans1-x) <= abs(x-ans2): + print(ans1) + else: + print(ans2)" +p03380,s133855211,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +def comb(a, b): + s = 1 + for i in range(a, b, -1): + s *= i + return s/2 +import math + +MA = max(A) +ans = (0, 0) +AL = 0 +for i in A: + if i == MA: + continue + if i < int(MA / 2) - 1: + continue + r = math.factorial(MA) // (math.factorial(MA-i) * math.factorial(i)) + if AL < r: + AL = r + ans = (MA, i) + +print(ans[0], ans[1])" +p02939,s479023710,Accepted,"s = list(input()) + +n = len(s) +hst = [""#""] +sk = """" + +for i in range(n): + sk += s[i] + if hst[-1] != sk: + hst.append(sk) + sk = """" + +print(len(hst)-1)" +p03759,s496963938,Accepted,"a, b, c, = map(int,input().split()) +print(""YES"" if b * 2 - (a + c) == 0 else ""NO"")" +p02860,s440183492,Accepted,"n=int(input()) +s=input() +print(""Yes"" if n%2==0 and s[:n//2]==s[n//2:] else ""No"")" +p02847,s568523140,Accepted,"s=input() +if s==""MON"": + print(""6"") +elif s==""TUE"": + print(""5"") +elif s==""WED"": + print(""4"") +elif s==""THU"": + print(""3"") +elif s==""FRI"": + print(""2"") +elif s==""SAT"": + print(""1"") +else: + print(""7"") + " +p03385,s163563859,Accepted,"def abc_of_ABC(s): + + return ""Yes"" if s.count(""a"") == 1 and s.count(""b"") == 1 else ""No"" + +def main(): + s = str(input()) + print(abc_of_ABC(s)) + +if __name__ == '__main__': + main()" +p02793,s391924370,Accepted,"from math import gcd + +N = int(input()) +A = list(map(int,input().split())) + +def lcm(a,b): + return a*b//gcd(a,b) + +lcm_a = 1 + +for i in A: + lcm_a = lcm(lcm_a,i) + +ans = 0 +for i in A: + ans += lcm_a//i + +print(ans%(10**9+7)) +" +p03211,s339676058,Wrong Answer,"s=input() +ans=1000 +for i in range(len(s)-3): + ans=min(ans,abs(int(s[i:i+3])-753)) +print(ans)" +p03012,s163340890,Accepted,"n = int(input()) +w = list(map(int, input().split())) +a = sum(w) // 2 +c = 0 +t = [] +for i in range(n): + t.append(abs(sum(w[i:]) - sum(w[:i]))) +print(min(t)) +" +p03645,s063180648,Wrong Answer,"import sys +from collections import defaultdict +from collections import deque + +n, m = map(int, input().split()) + +graph = defaultdict(list) + +for _ in range(m): + a, b = map(lambda x: int(x), input().split()) + graph[a].append(b) + graph[b].append(a) + +q = deque([1]) +cnt = 0 + +while q and cnt <= 2: + cnt += 1 + node = q.popleft() + after = graph[node] + + for a in after: + if a == n: + print(""POSSIBLE"") + sys.exit() + q.append(a) + +print(""IMPOSSIBLE"")" +p04031,s859830711,Wrong Answer,"s = list(map(lambda x: ord(x) - ord('a'), list(input()))) + +ans = [""-1"", ""-1""] +# print(s) +if len(s) == 2: + if set(s) == 1: + print(1, 2) + exit() + else: + print("" "".join(ans)) + exit() + +for i in range(len(s) - 2): + # print(len(set(s[i:i+3]))) + if len(set(s[i:i+3])) <= 2: + # print(s[i:i+3]) + ans = [str(i+1), str(i+3)] + break + +print("" "".join(ans))" +p03767,s879494942,Accepted,"N = int(input()) +a = list(map(int, input().split())) +a.sort(reverse = True) +res = 0 +for i in range(1,2*N,2): + res += a[i] +print(res)" +p03419,s751343411,Accepted,"n, m = map(int, input().split()) +if n*m==1: + print(1) +elif n==1: + print(m-2) +elif m==1: + print(n-2) +else: + print((n-2)*(m-2))" +p02697,s900254433,Wrong Answer,"import sys +import os + +def file_input(): + f = open('../Beginner_Contest_165/input.txt', 'r') + sys.stdin = f + +def main(): + #file_input() + # input() + N,M=map(int, input().split()) + cen=int(N/2) + ans=[] + for i in range(M): + ans.append([cen-i,cen+1+i]) + [print(str(i[0])+"" ""+str(i[1])) for i in ans] + +if __name__ == '__main__': + main() +" +p02622,s145946283,Accepted,"s=input() +t=input() +c=0 +for i in range(len(s)): + if s[i]!=t[i]: + c+=1 +print(c) + " +p03544,s339329030,Accepted,"n = int(input()) +n0 = 2 +n1 = 1 + +if n == 1: + print(1) +else: + for _ in range(1, n): + n2 = n0+n1 + n0, n1 = n1, n2 + print(n2) +" +p02995,s794182109,Accepted,"import math +l = list(map(int,input().split())) + +def lcm(x, y): + return (x * y) // math.gcd(x, y) + +l[0] -= 1 +la = l[0] - l[0] // l[2] - l[0] // l[3] + l[0] // lcm(l[2], l[3]) +lb = l[1] - l[1] // l[2] - l[1] // l[3] + l[1] // lcm(l[2], l[3]) +print(lb - la)" +p03495,s510385244,Wrong Answer,"r,k = map(int,input().split()) +b = input().split() +s = set(b) +n = [b.count(i) for i in s] +n.sort() +ans = 0 +for i in range(len(s)-k): + ans += n[i] + print(n[i]) +print(ans)" +p02899,s759197200,Accepted,"#!/usr/bin/env python +# coding: utf-8 + +# In[21]: + + +N = int(input()) +A = list(map(int, input().split())) + + +# In[22]: + + +A_s = sorted(enumerate(A), key=lambda x: x[1], reverse=False) +# print(A_s) +odr = [str(idx+1) for idx,x in A_s] +print("" "".join(odr)) + + +# In[ ]: + + + + +" +p02765,s118309112,Wrong Answer,"N, R = list(map(int,input().split("" ""))) + +if N < 10: + print(R-100*(10-N)) +else: + print(R)" +p02572,s055000196,Accepted,"n=int(input()) +i = list(map(int, input().split())) + +m=sum(i) + +ans=0 +for k in range(n): + ans+=(i[k]*(m-i[k])) +ans=ans//2 +ans=ans%(10**9+7) +print(ans)" +p02598,s716473196,Accepted,"import math + +n,k = map(int,input().split()) +a = list(map(int,input().split())) + +def cal(lis,x): + an = 0 + for i in range(len(lis)): + an += (math.ceil(lis[i] / x) - 1) + + return an + +left = 0 +right = 10**9 + +for i in range(100): + m = (left + right) / 2 + + b = cal(a,m) + + if b > k: + left = m + else: + right = m + +print(math.ceil(m))" +p03037,s764995657,Accepted,"n,m = map(int,input().split()) +l = [0 for _ in range(m)] +r = [0 for _ in range(m)] +for i in range(m): + l[i],r[i] = map(int,input().split()) +s = [0 for _ in range(n+1)] +for i in range(m): + s[l[i]-1] += 1 + s[r[i]] -= 1 +h = [0] +for i in range(n): + h.append(s[i]+h[i]) +ans = 0 +for i in range(n+1): + if(h[i] == m): + ans += 1 +print(ans)" +p03282,s164383851,Accepted,"S = list(input()) +K = int(input()) +for i in S: + if i != ""1"": + break +i = S.index(i) +if K <= i: + print(1) +else: + print(S[i]) +" +p03644,s467314223,Wrong Answer,"n=int(input()) + +for i in range(n+2): + if 2**i<=n: + print(2**i) +" +p02951,s631779027,Accepted,"a,b,c = map(int,input().split()) +print(max(0,c-(a-b)))" +p03293,s696486389,Wrong Answer,"s = list(input()) +t = list(input()) +f = False +l = len(s) +p = ["""" for _ in range(l)] +for i in range(l): + if s == p: + print(""as"") + f = True + break + for j in range(l): + p[(j+i)%l] = t[j] +if f: print(""Yes"") +else: print(""No"")" +p03795,s870824575,Wrong Answer,"import sys +from io import StringIO +import unittest +import math + +def resolve(): + s,c= map(int,input().split()) + + if s>=c/2: + print(str(math.floor(c/2))) + else: + zanc = c - (s * 2) + print(str(s + math.floor(zanc/4)))" +p02731,s179367147,Wrong Answer,"L=int(input()) +if L%3==0: + print((L//3)**3) +elif L%3==1: + print((L//3)*(L//3)*(L//3+1)) +else: + print((L//3)*(L//3+1)*(L//3+1)) +" +p02983,s399062655,Accepted,"l, r = map(int, input().split()) + +MOD = 2019 +r = min(r, l + MOD - 1) + +res = MOD - 1 +for i in range(l, r): + for j in range(i + 1, r + 1): + res = min(res, (i % MOD) * (j % MOD) % MOD) +print(res) + +" +p03042,s108726626,Wrong Answer,"def main(): + S = input() + if int(S[:2]) > 12 and 12 >= int(S[2:]) > 0: + print(""YYMM"") + elif 0 < int(S[2:]) <= 12 and 12 < int(S[:2]): + print(""MMYY"") + elif 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12: + print(""AMBIGUOUS"") + else: + print(""NA"") + + +if __name__ == '__main__': + main() +" +p02787,s676140905,Accepted,"#E re +H, N = map(int, input().split()) +A = [0] * N +B = [0] * N +for i in range(N): + A[i], B[i] = map(int, input().split()) +DP = [float('inf')] * (H+1) +DP[0] = 0 + +for i in range(N): + for j in range(H): + nj = min(j+A[i], H) + DP[nj] = min(DP[nj], DP[j]+B[i]) + +print(int(DP[H])) +" +p03986,s423043452,Accepted,"S = input() +a = b = c = 0 +for s in S: + if s == 'S': + a += 1 + else: + if a == 0: + b += 1 + else: + a -= 1 +print(a+b)" +p03778,s758705795,Wrong Answer,"w,a,b = map(int,input().split()) +aw = a+w +bw =b+w +print(min(abs(a-b),abs(b-aw),abs(bw-a)))" +p02854,s110646630,Wrong Answer,"from itertools import accumulate + + +def main(): + section_num = int(input()) + length = list(map(int, input().split())) + accumulate_length = list(accumulate(length)) + answer = float(""inf"") + for i in range(1, section_num): + answer = min(answer, abs(accumulate_length[-1] - 2 * accumulate_length[i])) + print(answer) + + +if __name__ == '__main__': + main() + +" +p03359,s619603653,Accepted,"a, b = map(int, input().split()) +if a > b: + print(a-1) +else: + print(a)" +p03427,s343792941,Accepted,"def resolve(): + N = int(input()) + N += 1 + + ans = 0 + for i, n in enumerate(range(len(str(N)))): + if i == 0: + continue + ans += int(9) + ans += int(str(N)[0])-1 + print(ans) + return + + +resolve()" +p03944,s162152220,Wrong Answer,"W, H, N = map(int,input().split()) +l = 0; r = W; u = H; d = 0 + +for i in range(N): + x, y, a = map(int,input().split()) + if a == 1: + l = max(l,x) + elif a == 2: + r = min(r,x) + elif a == 3: + d = max(d,y) + else: + u = min(u,y) + +print(max(0,(r-l)*(u-d))) " +p03478,s576563508,Accepted,"n, a, b = map(int, input().split()) +cnt = 0 +for i in range(1, n+1): + s = list(str(i)) + t = 0 + for j in range(len(s)): + t += int(s[j]) + if a<=t and t<=b: + cnt += i +print(cnt) + " +p03475,s429756812,Accepted,"n = int(input()) +arr = [list(map(int, input().split())) for _ in range(n-1)] +for i in range(n): + t = 0 # 初期条件 + for j in range(i, n-1): + ci, si, fi = arr[j] # 各駅の条件を代入 + if t <= si: # まだ始発が出発していないとき + t = si + else: # すでに出発している時 + t = ((t + fi - 1)//fi) * fi + t += ci # 電車に乗っている時間 + print(t)" +p03624,s451756059,Wrong Answer,"S = set(input()) +for i in range(97, 122): + if chr(i) not in S: + print(chr(i)) + exit() +print('None')" +p03836,s609367225,Accepted,"sx,sy,tx,ty = map(int,input().split()) +x = (tx-sx) +y = (ty-sy) + +order = ""L"" + +order += ""U""*(y+1) +order += ""R""*(x+1) +order += ""D"" + +order += ""R"" +order += ""D""*(y+1) +order += ""L""*(x+1) +order += ""U"" + +order += ""U""*y +order += ""R""*x +order += ""D""*y +order += ""L""*x +print(order) +" +p02678,s901837690,Accepted,"import queue + +N, M = map(int, input().split()) + +rooms = [[] for _ in range(N + 1)] +parents = [-1] * (N + 1) +for m in range(M): + A, B = map(int, input().split()) + rooms[A].append(B) + rooms[B].append(A) + +q = queue.Queue() +q.put((1, 0)) +while(not q.empty()): + x, p = q.get() + if parents[x] != -1: + continue + parents[x] = p + for connection in rooms[x]: + if parents[connection] == -1: + q.put((connection, x)) +print('Yes') +for p in parents[2:]: + print(p)" +p03797,s299143479,Accepted,"n,m = map(int,input().split()) +if 2*n >= m: + print(m//2) +else: + print(n+(m-2*n)//4)" +p03077,s531798753,Wrong Answer,"N = int(input()) +A = [0] * 5 +for i in range(5): A[i] = int(input()) +ans = 5 +print(ans + N // min(A))" +p02778,s360320381,Accepted,"s = input() +print('x'*len(s))" +p03285,s443552735,Accepted,"n = int(input()) +ans = 0 +for i in range(n//7+1): + if (n-i*7)%4 == 0: + ans = 1 + break +print([""No"",""Yes""][ans])" +p03711,s767362367,Accepted,"x,y = map(int, input().split()) +A = [1,3,5,7,8,10,12] +B = [4,6,9,11] +C =[2] +if x in A and y in A or x in B and y in B or x in C and y in C: + print(""Yes"") +else: + print(""No"")" +p02843,s876152848,Wrong Answer,"x = int(input()) + +x_sur = x % 100 + +if x_sur > 15: + print(0) +else: + print(1) +" +p04044,s371675916,Wrong Answer,"n, l = map(int, input().split()) +moji_array = list(map(str, input().split())) + +moji_array.sort() + +result = ''.join(moji_array) +print(result)" +p02759,s241116785,Accepted,"# coding: utf-8 +# Your code here! +import math +N = int(input()) + +print(math.ceil(N / 2))" +p02697,s179019022,Wrong Answer,"import sys +readline = sys.stdin.readline + +n,m = map(int,readline().split()) + +l=1 +r=n +for i in range(m): + print(l,r) + r -= 1" +p03854,s964213321,Accepted,"s=input() +s=s[::-1] + +for i in range(100000): + if s[:5] == 'maerd': + s = s[5:] + if s[:5] == 'esare': + s = s[5:] + if s[:6] == 'resare': + s = s[6:] + if s[:7] == 'remaerd': + s = s[7:] + +if len(s)==0: + print('YES') +else: + print('NO')" +p02813,s866219778,Accepted,"import itertools + +n = int(input()) +lst = [int(elem) for elem in range(1, n+1)] +p = list(itertools.permutations(lst)) + +ps = [int(elem) for elem in input().split()] +qs = [int(elem) for elem in input().split()] + +print(abs(p.index(tuple(ps)) - p.index(tuple(qs))))" +p02854,s060974827,Accepted,"N = int(input()) +nums = list(map(int, input().split())) +L = [0 for _ in range(N)] +R = [0 for _ in range(N)] +L[0] = nums[0] +for i in range(N-1): + L[i+1] = L[i] + nums[i+1] + R[N-i-2] = R[N-i-1] + nums[N-i-1] +ans = 10**20 +for i in range(N): + ans = min(ans, abs(R[i]-L[i])) +print(ans) + + " +p03338,s840723268,Wrong Answer,"n = int(input()) +s = input() +mx = -1 +for i in range(1,n-1): + x = set(s[0:i]) + y = set(s[i:]) + mx = max(mx,len(x & y)) +print(mx) + +" +p03281,s898785272,Wrong Answer,"N = int(input()) +if (N < 105): + print(0) +if (105 <= N < 135): + print(1) +if (135 <= N < 189): + print(2) +else: + print(3)" +p02608,s965938531,Wrong Answer,"#!/usr/bin/env python3 +n = int(input()) +cnt = [0] * (1 + n) +for a in range(1, 32): + for b in range(1, 32): + for c in range(1, 32): + k = a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a + if k > n: + continue + cnt[k] += 1 +for i in range(1, n + 1): + print(cnt[i]) +" +p02935,s579495817,Accepted," +n = int(input()) +a = list(map(int,input().split())) +a.sort() +ans = a[0] +for i in range(n-1): + ans = (ans + a[i+1])/2 +print(ans)" +p03071,s026968348,Accepted,"a,b = map(int,input().split()) + +print(max(2*a-1,a+b,2*b-1))" +p03371,s926976362,Accepted,"A,B,C_AB,X,Y = map(int, input().split()) +if A+B >= 2*C_AB: + print(2*C_AB*(min(X,Y)) + min(A,2*C_AB)*(X-min(X,Y)) + min(B,2*C_AB)*(Y-min(X,Y))) +else: + print(A*X+ B*Y) +" +p03241,s163784255,Accepted,"def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + return divisors +n, m = map(int, input().split()) +divs = make_divisors(m) +divs.sort() +ans = 0 +for d in divs: + if m // d >= n: + ans = d +print(ans)" +p03659,s703042141,Wrong Answer,"import itertools +n = int(input()) +a = list(itertools.accumulate(list(map(int, input().split())))) +ans = 1000000000 +sum_a = a[-1] +for i in range(n): + ans = min(ans,abs(sum_a - 2 * a[i])) +print(ans)" +p02836,s646917418,Wrong Answer,"s = input() +rs = reversed(s) + +acc = sum([c == rc for c, rc in zip(s, rs)]) + +print(acc // 2)" +p02645,s112215882,Wrong Answer,"s = str(input()) +nikname = s[2:5] +print(nikname)" +p03107,s139291145,Accepted,"s = input() +cnt0 = s.count('0') +cnt1 = s.count('1') +print(min(cnt0, cnt1) * 2)" +p02786,s953725385,Wrong Answer,"h = int(input()) +print(2 ** (h - 1) - 1)" +p02597,s330663443,Wrong Answer,"#!/usr/bin/env python3 +"""""" +RWとなってなければおk +WRはだめ +"""""" + + +def main(): + import sys + + input = sys.stdin.readline + + N = int(input()) + c = input() + + white, red = 0, c.count('R') + ans = N + for i in range(N): + if c[i] == 'W': + white += 1 + else: + red -= 1 + res = max(white, red) + ans = min(ans, res) + print(ans) + + +if __name__ == '__main__': + main() +" +p03042,s462236230,Wrong Answer,"a,b,c,d=input() +x=int(a+b) +y=int(c+d) +if 1<=x<=12 and 1<=y<=12: + print('AMBIGUOUS') +elif 1<=x<=12 and 0<=y<=99: + print('MMYY') +elif 0<=x<=99 and 1<=y<12: + print('YYMM') +else: + print('NA')" +p02690,s864231895,Wrong Answer,"x=int(input()) +for i in range(240): + for j in range(240): + if (120-i)**5-(120-j)**5==x: + print(i,j) + exit()" +p03986,s454292960,Accepted,"X = list(input()) + +cnt = 0 +s = 0 +for i in range(len(X)): + if X[i] == ""S"": + s += 1 + else: + if s: + cnt += 2 + s -= 1 +print(len(X)-cnt)" +p02700,s905863441,Wrong Answer,"a,b,c,d = (map(int,input().split())) +while True: + a = a-d + if a<=0: + print ('No') + break + c = c-d + if c<=0: + print ('Yes') + break" +p03827,s196793654,Wrong Answer,"# -*- coding: utf-8 -*- + +def main(): + + N = int(input()) + S = input() + + listS = list(S) + num = 0 + listNum = [] + + for i in listS: + if i == 'I': + num += 1 + listNum.append(num) + + elif i == 'D': + num += -1 + listNum.append(num) + + ans = max(listNum) + print(ans) + + +if __name__ == ""__main__"": + main()" +p02818,s925996649,Accepted,"a,b,k=map(int,input().split()) +print(max(0,a-k),max(0,b-max(0,k-a)))" +p03106,s913014451,Accepted,"a,b,k = map(int,input().split()) +i = 1 +cand = [] +while i<101: + if a%i == 0 and b%i==0: + cand.append(i) + i += 1 + +print(cand[-k]) + " +p02687,s917751507,Accepted,"s = input() + +if s == 'ABC': + print('ARC') +else: + print('ABC')" +p02829,s094844046,Wrong Answer,"a = int(input()) +b = int(input()) +print(i for i in range(1,4) if i != a and i != b)" +p02555,s040223480,Accepted,"S = int(input()) +ans = [0]*2001 +mod = 10**9+7 + +for i in range(0,76): + if i <= 2: + ans[i] = 0 + elif i <= 5: + ans[i] = 1 + + + +for m in range(6,S+1): + ans[m] = ans[m-1] + ans[m-3] + +print(ans[S]%mod)" +p02584,s592055705,Accepted,"X, K, D = list(map(int, input().split())) + +if abs(X) > K*D: + print(abs(X) - K*D) +else: + X = abs(X) + K -= X//D + X = X%D + if K%2 == 0: + print(X) + else: + print(abs(X-D))" +p02756,s014114206,Wrong Answer,"S = input() +Q=int(input()) +Query=[S] +flag = True +for i in range(Q): + x=input().split() + if len(x)==1: + flag = not flag + else: + if flag: + if x[1]==""1"": + Query=[x[2]]+Query + else: + Query.append(x[2]) + else: + if x[1]==""1"": + Query.append(x[2]) + else: + Query=[x[2]]+Query +if flag==False: + Query.reverse() + +print("""".join(Query))" +p02847,s528830635,Accepted,"S = input() +D = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] +print(7 - D.index(S))" +p02725,s706868306,Accepted,"#!/usr/bin/env python3 +def main(): + K, N = map(int, input().split()) + A = [int(x) for x in input().split()] + + max_length = A[0] + K - A[-1] + for i in range(1, len(A)): + max_length = max(max_length, A[i] - A[i - 1]) + print(K - max_length) + + +if __name__ == '__main__': + main() +" +p02833,s003539064,Accepted,"N = int(input()) + +if N & 1 == 0: + sum = 0 + N //= 10 + while N != 0: + sum += N + N //= 5 + print(sum) +else: + print(0)" +p02755,s762463990,Accepted,"a,b=map(int,input().split()) +import math +x=min(math.floor(a/0.08),math.floor(b/0.1)) +y=max(math.floor((a+1)/0.08),math.floor((b+1)/0.1)) +for i in range(x,y): + if math.floor(i*0.08)==a and math.floor(i*0.1)==b: + print(i) + exit() +print(-1) + " +p02829,s997620507,Accepted,"val = {1, 2, 3} +val.remove(int(input())) +val.remove(int(input())) +print(list(val)[0])" +p03360,s692630091,Accepted,"a=list(map(int,input().split())) +k=int(input()) +a.sort() +for i in range(k): + a[-1]*=2 +print(sum(a))" +p03627,s816628999,Accepted,"from collections import defaultdict + +N = int(input()) +A = list(map(int, input().split())) +d = defaultdict(int) + +max1, max2 = 0, 0 + +for a in A: + d[a] += 1 + if d[a] == 2: + if a > max1: + max2 = max1 + max1 = a + elif a > max2: + max2 = a + +if d[max1] >= 4: + ans = max1 * max1 +else: + ans = max1 * max2 +print(ans) + +" +p02780,s611232883,Wrong Answer,"import itertools + +def solve(): + N, M = map(int, input().split()) + A = list(map(int, input().split())) + l = list(itertools.accumulate(A)) + + if A[0] == 1 and len(A) == 1: + return 1 + + ans = 0 + for i in range(M, N): + ans = max(ans, l[i] - l[i-M]) + + ans = (ans+1) / 2 + + return ans + +print(solve()) +" +p02695,s991865397,Accepted,"import itertools +n,m,q = map(int,input().split()) +mx = 0 +a = [0]*q +b = [0]*q +c = [0]*q +d = [0]*q +for i in range(q): + ai,bi,ci,di = map(int,input().split()) + a[i] = ai-1 + b[i] = bi-1 + c[i] = ci + d[i] = di +mx = 0 +l = [i for i in range(m)] +for v in itertools.combinations_with_replacement(l, n): + s = 0 + for i in range(q): + if v[b[i]] - v[a[i]] == c[i]: + s += d[i] + if s > mx: + mx = s +print(mx) + + +" +p02988,s616442630,Wrong Answer,"n = int(input()) +ps = list(map(int, input().split())) +ans = 0 + +for i in range(1, len(ps)-1): + if ps[i] == min(ps[i-1], ps[i], ps[i+1]): + ans += 1 +print(ans) +" +p03627,s826791764,Accepted,"import collections + +n=int(input()) +a=list(map(int,input().split())) +c = collections.Counter(a) + +rkey=list(set(a)) +list.sort(rkey, reverse=True) +rvalue=[c[i] for i in rkey] + +for i in range(len(rvalue)): + if rvalue[i]>=4: + print(rkey[i]**2) + exit() + elif rvalue[i]>=2: + width=rkey[i] + rvalue.pop(i) + rkey.pop(i) + break +else: + print(""0"") + exit() +for i in range(len(rvalue)): + if rvalue[i]>=2: + height=rkey[i] + break +else: + print(""0"") + exit() +print(width*height) +" +p02724,s685616769,Wrong Answer,"a=int(input()) +if a % 500 == 0: + print(a * 2) +else: + print(round(a,-2) * 2 + int((a % 500) / 5) * 5)" +p02988,s132551741,Accepted,"N = int(input()) +P = list(map(int, input().split())) +ans = 0 +for i in range(1, N-1): + if P[i-1] < P[i] < P[i+1]: + ans += 1 + elif P[i+1] < P[i] < P[i-1]: + ans += 1 +print(ans) " +p03632,s950090301,Wrong Answer,"A, B, C, D = map(int, input().split()) +if A=0 and y >=0: + print(abs(x-y)) +elif x<=0 and y<=0 and x=30 else 'No')" +p03437,s334340196,Accepted,"X, Y = map(int, input().split()) +k = 1 +if X % Y == 0: + print(-1) + exit() +while 1: + if (k * X) % Y == 0: + k += 1 + else: + ans = k * X + break +print(ans)" +p02615,s566568535,Accepted,"n = int(input()) +friendliness = [int(s) for s in input().split()] + +friendliness.sort(reverse=True) +print(friendliness[0] + 2 * sum(friendliness[1:n//2]) + (n%2) * friendliness[n//2]) +" +p03625,s791180578,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = sorted(A, reverse=True) +w, h = 0, 0 + +cnt = 0 +tmp = S[0] +for i in range(N): + if S[i] == tmp: + cnt += 1 + if cnt == 2: + if w == 0: + w = tmp + cnt = 0 + else: + h = tmp + break + else: + cnt = 1 + tmp = S[i] + +ans = w * h +print(ans) +" +p03565,s917883789,Wrong Answer,"s=input() +t=input() +sl=len(list(s)) +tl=len(list(t)) +for i in range(sl-tl+1): + c=0 + for j in range(tl): + if s[i+j]==t[j] or s[i+j]=='?':c+=1 + else:break + if c==tl: + print((s[:i]+t+s[i+tl:]).replace(""?"", ""a"")) + exit() +print('UNRESTORABLE')" +p02633,s843519720,Accepted,"from sys import stdin +x = int(stdin.readline().rstrip()) + +def gcd(a, b): + while b: + a, b = b, a % b + return a +def lcm(a, b): + return a * b // gcd(a, b) + +ans = int(lcm(x, 360) / x) +print(ans)" +p02553,s396011786,Accepted,"a,b,c,d = map(int,input().split()) +ans = 0 +x = a*c +y = a*d +z = b*c +w = b*d +print(max(x,y,z,w))" +p02819,s713284460,Accepted,"import math +s=int(input()) +def sosuuukana(x): + y=int(math.sqrt(x)) + f=0 + for i in range(2,y+1): + if x%i==0: + f=f+1 + break + return f +while sosuuukana(s)>0: + s=s+1 +else: + print(s)" +p03797,s550942282,Accepted,"N,M = map(int,input().split()) +cnt = 0 + +m = int(M/2) + +if N >= m: + cnt = m +elif m > N: + cnt = N + M -= 2*N + cnt += int(M/4) + +print(cnt)" +p03251,s607536406,Wrong Answer,"n, m, x, y = map(int,input().split()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) + +c = max(a)+1 +d = min(b) +e = 0 + +if c > d: + print(""War"") +else: + for i in range(c,d+1): + if x < i and i <= y: + print(""No War"") + print(i) + e = 1 + break + if e == 0: + print(""War"")" +p02699,s114340428,Wrong Answer,"s, w = map(int, input().split()) +" +p03785,s975862517,Wrong Answer,"n, c, k = map(int, input().split()) +T = sorted([int(input()) for _ in range(n)]) + +peo = 1 +bus = 1 +out = T[0] + k + +for t in T: + if t <= out and peo < c: + peo += 1 + else: + out = t + k + peo = 1 + bus += 1 + +print(bus)" +p03475,s105117881,Wrong Answer,"N=int(input()) + +csflist=[] +for i in range(N-1): + c,s,f=map(int,input().split()) + csflist.append((c,s,f)) + +for i in range(N): + sec=0 + for j in range(i,N-1): + c,s,f=csflist[j] + if sec0: + sec+=f-(sec%f) + sec+=c +print(sec)" +p02621,s537786531,Accepted,"#!/usr/bin/env python3 + +a = int(input()) + +print(a+a**2+a**3) +" +p02767,s371786435,Accepted,"n = int(input()) +x = list(map(int, input().split())) +minx = min(x) +maxx = max(x) +list = [] +for i in range(minx,maxx+1): + klist = [] + for j in x: + k = (j-i)*(j-i) + klist.append(k) + #print(klist) + list.append(sum(klist)) +print(min(list))" +p02888,s402750415,Accepted,"import bisect +n = int(input()) +lines = list(int(i) for i in input().split()) +lines.sort() +counter = 0 + +for i in range(n-2): + for j in range(i+1, n-1): + counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1) + +print(counter)" +p03474,s470023407,Wrong Answer,"a,b=input().split() +c=input() +a=int(a) +b=int(b) +d=0 +if c[a]==""-"": + for i in range(a): + if c[i]==""-"": + d=d+1 + if d==1: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p03779,s307240534,Accepted,"N = int(input()) + +ans = 0 + +for i in range(1,10**9): + ans += i + if ans >= N: + print(i) + break" +p02742,s308353101,Accepted,"a , b = map(int , input() . split()) +if a == 1 or b == 1 : + print(1) +elif a * b % 2 == 0 : + print(a * b // 2) +else : + print(a * b // 2 + 1 )" +p02772,s794125776,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +for i in a: + if not i%2==0 and (i%3==0 or i%5==0): + print(""DENIED"") + exit() +print(""APPROVED"")" +p02900,s714275561,Accepted,"import fractions +def factorization(n): + arr=[] + tmp=n + for i in range(2,int(n**0.5)+1): + if(tmp%i==0): + cnt=0 + while tmp%i==0: + cnt+=1 + tmp//=i + arr.append([i,cnt]) + arr.append([1,1]) + if(tmp!=1): + arr.append([tmp,1]) + return arr +A,B=map(int,input().split()) +g=fractions.gcd(A,B) +li=factorization(g) +print(len(li))" +p02693,s749572190,Accepted,"num=int(input()) +date1=input().rstrip().split("" "") +A=int(date1[0]) +B=int(date1[1]) +C=int((A-A%num)/num) +D=int((B-B%num)/num) +if A%num==0 or B%num==0: + print(""OK"") +elif C==D: + print(""NG"") +else: + print(""OK"")" +p03087,s815334737,Accepted,"import sys + + +N, Q = map(int, input().split()) +S = input() + +AC = [0] * N + +for i in range(1, N): + a = 0 + if S[i - 1] == 'A' and S[i] == 'C': + a = 1 + AC[i] = AC[i - 1] + a + +LR = [map(int, x.split()) for x in sys.stdin.readlines()] + +for l, r in LR: + print(AC[r - 1] - AC[l - 1]) +" +p02993,s177169914,Accepted,"x = input() +for i in range(1,len(x)): + if x[i-1] == x[i]: + print(""Bad"") + break + if i == len(x)-1: + print(""Good"") + break" +p03323,s163553876,Accepted,"a,b = map(int,input().split()) +if a <= 8 and b <= 8: + print('Yay!') +else: + print(':(')" +p02556,s316135730,Accepted,"n = int(input()) +xy = [list(map(int, input().split())) for _ in range(n)] + +xy.sort(key=lambda x: x[0] + x[1]) +mn1, mx1 = xy[0], xy[-1] +xy.sort(key=lambda x: x[0] - x[1]) +mn2, mx2 = xy[0], xy[-1] + +li = [mn1, mx1, mn2, mx2] +ans = 0 +for x1, y1 in li: + for x2, y2 in li: + dist = abs(x1 - x2) + abs(y1 - y2) + ans = max(ans, dist) + +print(ans) +" +p03377,s760554808,Wrong Answer,"A,B,X=map(int,input().split()) +if A<=X and A+B>=X: + print(""Yes"") +else: + print(""No"")" +p02792,s261311324,Accepted,"def resolve(): + N = int(input()) + c = [[0] * 10 for _ in range(10)] + for k in map(str, range(1, N+1)): + i = int(k[0]) + j = int(k[-1]) + c[i][j] += 1 + n = 0 + for i in range(10): + for j in range(10): + n += c[i][j] * c[j][i] + print(n) + +resolve()" +p03803,s440252825,Accepted,"a,b=map(int,input().split()) +if a==1: + a=100 +if b==1: + b=100 +if a>b: + print('Alice') +elif a==b: + print('Draw') +else: + print('Bob') +" +p03437,s874741674,Accepted,"X, Y = map(int, input().split()) + +if X % Y == 0: + print(-1) +else: + print(X)" +p03799,s750388496,Accepted,"s, c = map(int, input().split()) +ans = 0 + +ans += min(s, c // 2) +c -= ans * 2 +ans += c // 4 + +print(ans) +" +p02732,s907035215,Wrong Answer,"from collections import Counter +from scipy.misc import comb + +N = int(input()) +A = list(map(int, input().split())) +c = Counter(A) + +num = 0 +for v in c.values(): + if v > 1: + num += comb(v, 2) + +for k in range(N): + print(num - (c[k]-1))" +p03037,s312548596,Accepted,"N, M = map(int, input().split()) +LR = [list(map(int, input().split())) for _ in range(M)] + +left = 1 +right = N + +for l, r in LR: + left = max(left, l) + right = min(right, r) + +ans = right - left + +print(ans + 1 if ans >= 0 else 0) +" +p02835,s901167725,Accepted,"total = sum(list(map(int, input().split()))) +if total >= 22: + print('bust') +else: + print('win') +" +p02811,s920980873,Accepted,"K, X = list(map(int, input().split())) + +if 500 * K >= X: + print('Yes') +else: + print('No')" +p03449,s247417277,Accepted,"n = int(input()) +a1 = list(map(int, input().split())) +a2 = list(map(int, input().split())) + +for i in range(1, n): + a1[i] += a1[i - 1] + +for i in range(n - 2, -1, -1): + a2[i] += a2[i + 1] + +res = 0 +for i in range(n): + tmp = a1[i] + a2[i] + res = max(tmp, res) + +print(res) +" +p03360,s215821282,Wrong Answer,"a,b,c=map(int,input().split()) +k = int(input()) + +a1 = max(a,b,c) +b1 = min(a,b,c) +c1 = (a + b + c) - (a1 + b1) + +multipled_num = 2 * k * a1 + +print(multipled_num + b1 + c1)" +p02958,s520264118,Accepted,"import copy + +n = int(input()) +lis = list(map(int, input().split())) + +tlis = copy.deepcopy(lis) + +sortlis = sorted(lis) + + +for i in range(n-1): + for j in range(i,n): + tmp = tlis[i] + tlis[i] = tlis[j] + tlis[j] = tmp + if tlis == sortlis: + print('YES') + exit() + else: + tlis = copy.deepcopy(lis) + +print('NO')" +p02720,s412970925,Accepted,"from collections import deque +k = int(input()) +a = deque([1,2,3,4,5,6,7,8,9]) +count=0 +while count !=k: + b = a.popleft() + count += 1 + if b%10==0: + a.append(b*10) + a.append(b*10+1) + elif b%10==9: + a.append(b*10+8) + a.append(b*10+9) + else: + a.append(b*10+b%10-1) + a.append(b*10+b%10) + a.append(b*10+b%10+1) +print(b)" +p03109,s690922428,Accepted,"s = input() +print(""Heisei"" if s <= ""2019/04/30"" else ""TBD"") + + + + +" +p03126,s854917535,Accepted,"n,m = map(int,input().split()) +s = set(range(1,m+1)) +for i in range(n): + k,*a = map(int,input().split()) + s &= set(a) +print(len(s))" +p02819,s809330074,Wrong Answer,"m = int(input()) +if m <= 2 : + print('2') +else: + n = 10**5 + primes = set(range(2, n+1)) + for i in range(2, int(n**0.5+1)): + primes.difference_update(range(i*2, n+1, i)) + primes=list(primes) + + for i in range(len(primes)-1): + if primes[i] < m and m <= primes[i+1]: + print(primes[i+1]) + +" +p02730,s547369726,Wrong Answer,"import math + +def check_kai(arr): + len_a = len(arr) + check_len = int(math.ceil(len_a/2)) + lef = arr[0:check_len] + arr.reverse() + rig = arr[0:check_len] + if lef == rig: + return True + else: + return False + + +input = list(input()) +N = len(input) + +if check_kai(input) and check_kai(input[0:(int((N-1)/2))]) and check_kai(input[int((N+3)/2):]): + print('Yes') +else: + print('No') +" +p03860,s755535913,Wrong Answer,"a, b, c = input().split() + +print(""A"" + b.upper() + ""C"")" +p02719,s946603037,Wrong Answer,"s = input().split("" "") +N = int(s[0]) +K = int(s[1]) + +if N == 0: + print(K) +elif N == 1 or K == 1: + print(""0"") +elif N == K: + print(""0"") +elif N % K == 0 or K % N == 0: + print(""0"") +elif N % 2 == 0 and K % 2 == 0: + print(""2"") +else: + print(""1"")" +p03456,s983167672,Wrong Answer,"import math +a, b = input().split() +ab = int(a + b) +result = math.sqrt(ab) + +if result ** 2 == ab: + print('Yes') +else: + print('No')" +p03243,s502029384,Accepted,"import bisect + +inf = 10**15 +mod = 10**9+7 + +kouho = [111, 222, 333, 444, 555, 666, 777, 888, 999] +n = int(input()) +ind = bisect.bisect_left(kouho, n) +print(kouho[ind])" +p03012,s920221154,Accepted,"N = int(input()) +W = list(map(int, input().split())) +m = 1e+10 +suma = W[0] +sumb = sum(W[1:]) +for i in range(1, N): + suma += W[i] + sumb -= W[i] + m = min(m, abs(suma - sumb)) +print(m)" +p04011,s811633400,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) + +if n > k: + print(x * k + y * (n - k)) +else: + print(x * n) +" +p04011,s524108544,Wrong Answer,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +a = 0 +b = 0 +c = 0 +e = 0 + +for i in range(k): + a = k * x + +b = n - k + +for d in range(b): + c = b * y + +e = a + c +print(e)" +p03317,s077117808,Accepted,"import math +n,k=[int(i) for i in input().split()] +a=[int(i) for i in input().split()] + + +def get_1_index(a): + for i,j in enumerate(a): + if j==1: + return i + + +index=get_1_index(a) + +mae=index +usiro=n-index-1 + +# print(math.ceil(mae/(k-1))+math.ceil(usiro/(k-1))) +print(math.ceil((n-1)/(k-1)))" +p02801,s837554051,Accepted,"a = input() +a = ord(a)+1 +print(chr(a))" +p03693,s664268894,Accepted,"r, g, b = input().split() + +ans = int(r) * 100 + int(g) *10 + int(b) + +if ans % 4 == 0: + print(""YES"") +elif ans % 4 != 0: + print(""NO"")" +p03494,s472358305,Accepted,"n=int(input()) +a= list(map(int, input().strip().split())) +def how_many_times_divisible(n): + ans = 0 + while n % 2 == 0: + n /= 2 + ans += 1 + return ans +ans = min(map(how_many_times_divisible, a)) +print(ans) +" +p03041,s826275153,Wrong Answer,"n,k= map(int,input().split()) +s=input() +print(s.lower()[k-1])" +p03637,s142703462,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +odd = 0 +double = 0 +quatro = 0 + +for i in a: + if i % 2 == 1: + odd += 1 + else: + if i % 4 == 0: + quatro += 1 + else: + double += 1 + +if double == N: + print(""Yes"") + exit() +plus = 0 +if double != 0: + plus = 1 +if plus + odd - 1 <= quatro: + print(""Yes"") +else: + print(""No"") +" +p04020,s783694928,Accepted,"n = int(input()) +a = [] +for i in range(n): + a.append(int(input())) +res = 0 +for i in range(n): + res += a[i] // 2 + if a[i] % 2 == 1: + if i != n-1: + if a[i+1] != 0: + res += 1 + a[i+1] -= 1 + +print(res)" +p03730,s901267409,Accepted,"A,B,C=map(int,input().split()) +ans='NO' +for i in range(1,B+1): + if (A*i)%B==C: + ans='YES' + +print(ans)" +p03760,s279273545,Accepted,"ans='' +a, b = (input() for _ in range(2)) + +if len(b) < len(a): + b += ' ' +for i, j in zip(a, b): + ans += i + j +print(ans)" +p03069,s713717439,Wrong Answer,"import sys +def input(): return sys.stdin.readline().strip() +def mapint(): return map(int, input().split()) +sys.setrecursionlimit(10**9) + +N = int(input()) +S = list(input()) + +lis = [1 if s=='#' else 0 for s in S] +from itertools import accumulate +lis = list(accumulate(lis)) + +ans = 10**18 +cnt = 0 +for i in range(N-1, -1, -1): + s = S[i] + ans = min(ans, cnt+lis[i]) + if s=='.': + cnt += 1 + +print(ans)" +p02861,s751354892,Wrong Answer,"import itertools +import math +import statistics + +N = int(input()) +direction = [list(map(int,input().split())) for _ in range(N)] +_l = itertools.permutations(direction,N) +l = [] +for lst in _l: + l.append([[0,0]] + list(lst)) + +s = [] +for d in l: + tmp = 0 + for i in range(len(d)-1): + tmp += math.sqrt((d[i+1][0]-d[i][0])**2 + (d[i+1][1]-d[i][1])**2) + s.append(tmp) +print(sum(s)/len(s))" +p03627,s720897929,Accepted,"N = int(input()) +A = [int(i) for i in input().split()] + +from collections import Counter + +Acnt = Counter(A) + +ans = [-1] * 2 +for key,cnt in Acnt.items(): + if cnt >= 4: + if key > ans[0]: + ans[0] = key + if key > ans[1]: + ans[1] = key + elif cnt >= 2: + if key > ans[0]: + ans[0] = key + + ans.sort() + +if -1 in ans: + print(0) +else: + print(ans[0] * ans[1])" +p02621,s126873709,Accepted,"a = int(input()) +print(a + a**2 + a**3)" +p02958,s440358007,Accepted,"n = int(input()) +p1 = list(map(int, input().split())) +p2 = p1.copy() +p2.sort() +cnt = 0 +for i in range(n): + if p1[i] != p2[i]: + cnt += 1 +if cnt <= 2: + print(""YES"") +else: + print(""NO"")" +p03469,s948237123,Accepted,"s = list(input()) +s[3] = ""8"" +print(*s, sep="""")" +p03328,s284757955,Accepted,"a,b = map(int,input().split()) +c = b - a +n = (c - 1) * c // 2 +print(n - a)" +p02683,s902576393,Wrong Answer,"import numpy as np +import itertools +N, M, X = (int(i) for i in input().split()) +Y = np.zeros((N, M+1)) +for i in range(N): + Y[i,:] = [int(i) for i in input().split()] +C = Y[:,0] +A = np.matrix(Y[:,1:]) +res = np.inf +f = '0'+str(N)+'b' +for i in range(2**N): + z = np.array([int(s) for s in list(format(i, f))]) + cost = z @ C + skill = z * A + if (skill >= X).all() and (cost < res): + res = cost +if np.isinf(res): + print(-1) +else: + print(res)" +p02576,s195355259,Accepted,"N,X,T=map(int,input().split()) + +if N%X==0: + print(str(((N//X))*T)) +else: + print(str(((N//X)+1)*T))" +p03377,s468602544,Accepted,"import sys +import heapq, math +from itertools import zip_longest, permutations, combinations, combinations_with_replacement +from itertools import accumulate, dropwhile, takewhile, groupby +from functools import lru_cache +from copy import deepcopy + +A, B, X = map(int, input().split()) +print(""YES"" if A <= X <= A + B else ""NO"")" +p03838,s532384857,Accepted,"x,y = map(int,input().split()) + +#最初に反転するか +#1を増やし続ける +#最後に反転するか +#この組み合わせにより4パターンについて計算すればよい + +ans=float('inf') +#反転なし、反転なし +if x<=y: + ans = min(ans,y-x) +#あり、なし +if -x<=y: + ans = min(ans,y+x+1) +#なし、あり +if x<=-y: + ans = min(ans,-y-x+1) +#あり、あり +if -x<=-y: + ans = min(ans,-y+x+2) +print(ans)" +p03478,s967247317,Wrong Answer,"import numpy as np +N, A, B = map(int, input().split()) + +total = 0 +for i in range(N+1): + a = i + lis =[] + while i >0: + lis.append(i%10) + i //=10 + lis.reverse() + lis = np.array(lis) + SUM = np.sum(lis) + + if SUM >=A and SUM <=B: + total += a" +p03161,s456976359,Wrong Answer,"N, K = map(int, input().split()) +h = list(map(int, input().split())) + +dp = [float(""inf"") for _ in range(N)] + +def cost(n, m): + return abs(h[n] - h[m]) + +dp[0] = 0 + +for i in range(N): + for j in range(1, K + 1): + if (i + j) <= N -1: + dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j)) + +print(dp)" +p02708,s585303996,Accepted,"n,k=map(int,input().split()) +# 累積和!max-min+1 +csl=[] +sum=0 +for i in range(n+1): + sum+=i + csl.append(sum) +#3 2 +#[0, 1, 3, 6] +# 0 1 2 3 +cnt=0 +for i in range(k,n+1): + max=csl[n]-csl[n-i] + min=csl[i-1] + #初めの数も含むの+1 + cnt+=(max-min+1) + cnt%=(10**9+7) +#0~nまで全選択の+1 +print(cnt+1)" +p03774,s637759923,Accepted,"n, m = map(int, input().split()) +ab = [list(map(int, input().split())) for _ in range(n)] +cd = [list(map(int, input().split())) for _ in range(m)] + +for i in range(n): + tmp = float(""inf"") + ans = 0 + y = float(""inf"") + for j in range(m): + x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) + if x < tmp or x == tmp and i < y: + tmp = x + ans = j + 1 + y = i + print(ans)" +p03352,s837667824,Accepted,"X = int(input()) +if X==1: + print(1) +else: + cmax = 1 + for i in range(2,int(X**0.5)+1): + k = 2 + while i**k<=X: + cmax = max(cmax,i**k) + k += 1 + print(cmax)" +p02595,s641123542,Accepted,"n, d = map(int, input().split("" "")) +ans = 0 +for i in range(n): + x, y = map(int, input().split("" "")) + if (d ** 2 >= x ** 2 + y ** 2): + ans += 1 +print(ans) +" +p02659,s722891563,Wrong Answer,"import numpy as np +import sys +a,b=input().split() +a=float(a)/10000; +b=float(b)*10000; +print(int(float(a)*float(b)))" +p02694,s022620005,Accepted,"X = int(input()) + + +kouza = 100 +count = 0 +while X > kouza: + kouza = int(kouza * 1.01) + count += 1 +print(count)" +p03262,s955319151,Accepted,"def gcd(a, b): + while b: + a, b = b, a % b + return a + + +def main(): + N, X, *xn = map(int, open(0).read().split()) + ans = None + for x in xn: + if ans is not None: + if abs(X - x) % ans: + ans = gcd(ans, abs(X - x)) + else: + ans = abs(X - xn[0]) + print(ans) + return + + +main() +" +p04045,s309912900,Wrong Answer,"N, L = map(str, input().split()) +P = list(map(str, input().split())) +U = sorted(list(set([str(i) for i in range(10)])-set(P))) +#print(U) +for i in range(len(N)): + #print(N[i]) + if N[i] in P: + #print(N[i]) + for j in U: + #print(j) + if j >=N[i]: + N=N.replace(N[i],j) + #print(N) + break +print(N)" +p02790,s656697462,Accepted,"a, b = input().split() +A = a*int(b) +B = b*int(a) +print(min(A, B))" +p02719,s346346262,Wrong Answer,"N,K=map(int,input().split()) +kari=int(N/K) +M=N-K*(kari) +L=abs(M-K) +B=abs(L-K) +print(min(N,abs(M-K),L,B,abs(M)))" +p04031,s886543956,Wrong Answer,"_ = int(input()) +a = [int(x) for x in input().split()] + +answer = 10**10 +for y in range(-100, 100): + acc = 0 + for x in a: + acc += (x - y) * (x - y) + answer = min(answer, acc) +print(answer) +" +p03035,s537762441,Accepted,"age, b = map(int, input().split()) + +if age >= 13: + print(b) +elif 6 <= age < 13: + print(b // 2) +else: + print(0) +" +p02771,s938536461,Accepted,"a,b,c = map(int, input().split()) +s = {a,b,c} +if len(s) == 2: + ans = 'Yes' +else: + ans = 'No' + +print(ans)" +p02987,s615318132,Accepted,"s=input() +if len(set(s))==2 and s.count(s[0])==2: + print('Yes') +else: + print('No')" +p03359,s569802898,Accepted,"a, b = map(int, input().split()) +if b >= a: + print(a) +else: + print(a - 1) +" +p03695,s139300443,Wrong Answer,"n = int(input()) +a_list = [int(x) for x in input().split()] +s = set() +o = 0 +for a in a_list: + r = a // 400 + if r >= 8: + o += 1 + else: + s.add(r) +c = len(s) +print(c if c > 0 else 1, min(c + o, 8))" +p02780,s757010256,Accepted,"N, K = map(int, input().split()) +p = list(map(int, input().split())) + +a = [0 for _ in range(N+1)] + +for i in range(N): + a[i+1] = (1+p[i])/2 + a[i] + +ans = 0 + +for i in range(N-K+1): + ans = max(ans, a[i+K]-a[i]) + +# print(a) +print(ans)" +p03545,s444774132,Wrong Answer,"In = [int(i) for i in input()] +flag = 0 +for op1 in [""+"",""-""]: + for op2 in [""+"",""-""]: + for op3 in [""+"",""-""]: + if eval(""{}"".format(In[0])+op1+""{}"".format(In[1])+op2+""{}"".format(In[2])+op3+""{}"".format(In[3]))==7: + print(""{}"".format(In[0])+op1+""{}"".format(In[1])+op2+""{}"".format(In[2])+op3+""{}=7"".format(In[3])) + flag = 1 + break + if flag: + break" +p02607,s648072627,Accepted,"N = int(input()) +A = list(map(int, input().split())) +cnt=0 +for i in range(1,N+1): + if A[i-1]%2==1 and i%2==1: + cnt+=1 +print(cnt)" +p02689,s245779888,Accepted,"n,m = map(int,input().split()) +h=[] +h.extend(input().split()) +h=list(map(int,h)) +cnt = [0]*n +cnt2 = [0]*n +ans = 0 + +for i in range(m): + a,b = map(int,input().split()) + if h[a-1] > h[b-1]: + cnt[a-1] += 1 + if h[a-1] < h[b-1]: + cnt[b-1] +=1 + cnt2[a-1] +=1 + cnt2[b-1] +=1 + +for p in range(n): + if cnt[p]==cnt2[p]: + ans += 1 +print(ans)" +p03555,s375853306,Accepted,"A=input() +B=input() +if A[0]==B[2] and A[1]==B[1] and A[2]==B[0]: + print(""YES"") +else: + print(""NO"")" +p02548,s156686694,Accepted,"N = int(input()) + +count = 0 +for i in range(N): + count += int((N-1)/(i+1)) +print(count) +" +p03695,s179284774,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +A = map( lambda x:x//400, A) +A = list(map( lambda x:x if x<8 else 8, A)) +cnt8 = A.count(8) +print(cnt8) +A = list(sorted(set(A))) +if 8 in A: + A.remove(8) +sum = len(A) +if sum == 0 and cnt8 > 0: + print(1, end=' ') +else: + print(sum, end=' ') +sum += cnt8 +if sum > 8: + print(8) +else: + print(sum)" +p03827,s589892904,Accepted," +import math +import itertools +import statistics +#import collections +n = int(input()) +s = input() + +x = 0 +a = [] +for i in range(n): + if s[i]==""I"": + x += 1 + else: + x -= 1 + a.append(x) + +print(max(max(a), 0))" +p02718,s411419634,Accepted,"N, M = list(map(int, input().split())) +A = list(map(int, input().split())) +cnt = 0 + +L = sum(A) * (1 / (4 * M)) +for i in range(N): + if A[i] >= L: + cnt += 1 + +if cnt >= M: + print(""Yes"") +else: + print(""No"")" +p02607,s880963060,Accepted,"n = int(input()) +L = list(map(int,input().split())) +cnt = 0 +for i in range(n): + if (i+1)%2 == 1 and L[i]%2 == 1: + cnt +=1 +print(cnt)" +p02835,s664310268,Accepted,"get_input = input().split() +A1 = int(get_input[0]) +A2 = int(get_input[1]) +A3 = int(get_input[2]) + +if A1 + A2 + A3 >= 22: + print(""bust"") +else: + print(""win"") +" +p02785,s215123880,Accepted,"n,k=map(int,input().split()) +h=list(map(int,input().split())) +c=0 +if n<=k: + print(""0"") +else: + h.sort() + for i in range(k): + h.pop(-1) + for x in h: + c+=x + print(c)" +p03261,s478442677,Accepted,"N=int(input()) +W=[input() for _ in range(N)] + +w=set(W) +answer=""Yes"" + +if len(w)==len(W): + for i in range(1,N): + if W[i-1][len(W[i-1])-1]==W[i][0]: + pass + else: + answer=""No"" + break + print(answer) +else: + print(""No"")" +p02725,s995029254,Accepted,"k,n = list(map(int,input().split())) +a = list(map(int,input().split())) + +dp = [0 for i in range(n)] +dp[0] = abs(k-a[-1]) + a[0] + +for i in range(1,n): + dp[i] = abs(a[i]-a[i-1]) + +print(sum(dp) - max(dp))" +p03327,s926900830,Accepted,"N = int (input()) + +if N < 1000: + print('ABC') +elif N >= 1000: + print('ABD')" +p03994,s884595972,Wrong Answer,"x=input() +x=list(x) +y=int(input()) +a=(len(x)) + +for i in range(a): + if ord(x[i])+y>=123: + y=y-(123-ord(x[i])) + x[i]='a' +while (ord(x[a-1])+y)>=123: + y=((ord(x[a-1])+y)-97)%26 +x[a-1]=chr(y+97) +print(*x,sep='')" +p03126,s131234303,Accepted,"n, m = map(int,input().split()) + +result = [j for i in range(n) for j in list(map(int,input().split()))[1:]] +count = 0 +for i in range(m): + if result.count(i+1) == n: + count+=1 + +print(count) + + " +p03711,s968566642,Wrong Answer,"x,y = map(int,input().split()) +#print(x,y) + +a = [1,3,5,7,8,12] +#print(a) +b = [4,6,9,11] +c = [2] + +if x in a and y in a: + print(""YES"") +elif x in b and y in b: + print(""YES"") +elif x in c and y in c: + print(""YES"") +else: + print(""NO"")" +p02547,s710071671,Wrong Answer,"n = int(input()) +d1 = [0]*n +d2 = [0]*n +h = 'No' +for i in range(n): + d1[i], d2[i] = map(int, input().split()) + if i > 2: + if d1[i] == d2[i]: + if d1[i-1] == d2[i-1]: + if d1[i-2] == d2[i-2]: + h = 'Yes' + break +print(h)" +p03160,s505600614,Accepted,"n=int(input()) +arr=[int(i) for i in input().split()] +dp=[0]*(n+1) +dp[2]=abs(arr[0]-arr[1]) +for i in range(3,n+1): + dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3])) + +print(dp[n]) + +" +p03067,s102807295,Wrong Answer,"a,b,c = map(int,input().split()) + +if a < c < b: + print(""Yes"") +else: + print(""No"") +" +p03251,s745566760,Accepted,"import sys +input = sys.stdin.readline + + +N,M,X,Y=list(map(int,input().split())) +x =list(map(int,input().split())) +y = list(map(int,input().split())) +x.append(X) +y.append(Y) + +if min(y) - max(x) >0: + print('No War') +else: + print('War') + +" +p03548,s611325650,Accepted,"x, y, z = map(int, input().split()) +print((x - z) // (y + z))" +p03814,s386296594,Accepted," +s = input() + +A = [i for i, x in enumerate(s) if x == ""A""] +Z = [i for i, x in enumerate(s) if x == ""Z""] + +print(max(Z) - min(A) + 1) +" +p03637,s688380430,Accepted,"n=int(input()) + +L=list(map(int,input().split())) +a=0 +b=0 + +for i in range(n): + if L[i]%4==0: + b+=1 + if L[i]%2==1: + a+=1 + +if a+b==n and a-b==1: + print('Yes') + exit() +if b>=a: + print('Yes') +else: + print('No')" +p02796,s461684765,Accepted,"n = int(input()) +xl = [list(map(int, input().split())) for _ in range(n)] +le = [[p[0]-p[1], p[0]+p[1]] for p in xl] +le.sort(key = lambda x : x[1]) + +ans = 0 +right = -(10 ** 9) - 1 +for i in range(n): + if right <= le[i][0]: + ans += 1 + right = le[i][1] +print(ans)" +p02718,s067332689,Accepted,"N,M = map(int,input().split()) +A = list(map(int,input().split())) + +sum_A = sum(A) +A.sort(reverse=True) +x = sum_A/(4*M) +count = 0 +for i in range(N): + if A[i] >= x: + count += 1 +if count >= M: + print(""Yes"") +else: + print(""No"")" +p03017,s322012339,Wrong Answer,"n, a, b, c, d = map(int, input().split()) +s = input() +ans = 'Yes' +if '##' in s[a:max(c,d)]: + ans = 'No' +else: + if c > d and '...' not in s[a-1:c]: + ans = 'No' +print(ans)" +p03076,s729954874,Accepted,"import itertools +t = [] +for _ in range(5): + t.append(int(input())) + +most_fast = 10**5 + +for i in itertools.permutations(t,5): + time = 0 + for j in range(4): + time += i[j] + if time % 10 != 0: + time += 10 - (time % 10) + time += i[4] + if time <= most_fast: + most_fast = time + +print(most_fast)" +p02860,s559661036,Accepted,"n = int(input()) +s = input() + +if n % 2 == 1: + print(""No"") + exit(0) + +for i in range(n//2): + if s[i] != s[i + n //2]: + print(""No"") + exit(0) + +print(""Yes"")" +p03106,s930548622,Wrong Answer,"a, b, c = map(int, input().split()) +d = 0 +i = 1 +while True: + if a % i ==0 and b % i ==0: + d += 1 + if d == c: + print(i) + exit() + i += 1" +p02702,s977351696,Accepted,"import sys +readline = sys.stdin.readline + +S = readline().strip() +S = list(map(int, S)) +N = len(S) +P = 2019 + +rems = [0] * N +a = 1 +b = 0 +for i in range(N): + b = (b + (a * S[N - i - 1]) % P) % P + rems[N - i - 1] = b + a = a * 10 % P + +rems = rems + [0] + +counts = [0] * P + + +for i in range(len(rems)): + counts[rems[i]] += 1 + +ans = 0 +for c in counts: + ans += c * (c - 1) // 2 + +print(ans)" +p03286,s931018083,Wrong Answer,"N = int(input()) + +ans = [] +while N != 0: + if N % 2 == 1: + ans.append(""1"") + N -= 1 + else: + ans.append(""0"") + N //= - 2 + +ans = """".join(ans)[::-1] +print(ans) +" +p02720,s896427334,Wrong Answer,"from collections import deque +K = int(input()) +d = deque(range(1, 10)) +for i in range(K): + x = d.popleft() + if x % 10 != 0: + d.append(10*x-1) + d.append(10*x) + if x % 10 != 9: + d.append(10*x+1) +print(x)" +p03285,s965487337,Accepted,"n = int(input()) + +answer = False +for num_4 in range(n//4+1): + if (n-num_4*4)%7 == 0: + answer = True + break + +if answer : + print(""Yes"") +else : + print(""No"")" +p03150,s455129500,Accepted,"S = input() + +for i in range(len(S)): + for j in range(len(S)): + if S[:j]+S[i:] == ""keyence"": + print(""YES"") + exit() +print(""NO"")" +p04043,s827122252,Accepted,"a,b,c = map(int,input().split()) +if a == b == 5 and c== 7: + print(""YES"") +elif a == c == 5 and b== 7: + print(""YES"") +elif c == b == 5 and a== 7: + print(""YES"") +else: + print(""NO"")" +p02983,s956867567,Accepted,"l,r = map(int,input().split()) +li = [] +r = min(r,l+4040) +for i in range(l,r): + for j in range(i+1,r+1): + li.append(i*j%2019) +print(min(li))" +p02787,s741747369,Accepted,"H, N = map(int, input().split()) +A = [] +B = [] +for _ in range(N): + a, b = list(map(int, input().split())) + A.append(a) + B.append(b) + +dpl = H+max(A) +x = 10**10 +dp = [x]*dpl +dp[0] = 0 + +for a, b in zip(A, B): + for i in range(a, dpl): + dp[i] = min(dp[i-a]+b, dp[i]) + for i in range(dpl-2, -1, -1): + dp[i] = min(dp[i+1], dp[i]) + +print(dp[H])" +p03324,s451515393,Wrong Answer,"d,n=map(int,input().split()) + +if d==0: + print(n if n<=100 else n+1) +else: + print(100**d * n if n<=100 else 100**d * (n+1))" +p03250,s707386192,Accepted,"l = list(map(int, input().split())) +l.sort(reverse = True) +print(int(str(l[0]) + str(l[1])) + l[2])" +p03254,s944867328,Wrong Answer,"A,B=list(map(int,input().split())) +C=list(map(int,input().split())) +C.sort() +ans = 0 +for i in C: + if B >= i: + ans+=1 + B-=i + else: + print(ans) + exit() +print(ans)" +p02866,s159178794,Accepted,"N,D=open(0) +*D,=map(int,D.split()) +c=[0]*-~max(D) +for i in D:c[i]+=1 +a=D[0]<1==c[0] +for i,j in zip(c,c[1:]):a*=i**j +print(a%998244353) +" +p03814,s142009476,Accepted,"s=str(input()) +for i in range(len(s)): + if s[i]==""A"": + a=i + break +t=s[::-1] +for j in range(len(s)): + if t[j]==""Z"": + b=j + break + +print(len(s)-a-b)" +p02972,s027778472,Wrong Answer,"n = int(input()) +l = list(map(int,input().split())) +k = [0 for i in range(n)] +t = [] +for i in range(n-1,-1,-1): + a = l[i] + if a!=k[i]: + t.append(i+1) + for j in range(i,int((i+1)**0.5-1),-1): + if (i+1)%(j+1)==0: + k[j] += 1 + k[(i+1)//(j+1)-1] += 1 + k[j] %= 2 + k[(i+1)//(j+1)-1] %= 2 +if len(t)==0: + print(0) +else: + print(len(t)) + print(*t) +" +p03385,s920652865,Accepted,"s = input() +s = sorted(s) + +if s == ['a', 'b', 'c']: + print('Yes') +else: + print('No')" +p02790,s941504620,Accepted,"a, b = input().split() + +out_1 = int(a*int(b)) +out_2 = int(b*int(a)) + +print(max(out_1, out_2)) +" +p03556,s846903042,Wrong Answer,"N = int(input()) + +for i in range(N): + if i**2>N: + break + +print((i-1)**2)" +p02694,s697020512,Wrong Answer,"import math + +x = int(input()) +saving = 100 +ans = 0 + +while saving <= x: + saving = math.floor(saving * 1.01) + ans += 1 + +print(ans)" +p02727,s997124695,Accepted,"x, y, a, b, c = map(int, input().split()) +p = sorted(map(int, input().split()), reverse=True)[:x] +q = sorted(map(int, input().split()), reverse=True)[:y] +r = list(map(int, input().split())) +ls = sorted(p+q+r, reverse=True)[:x+y] +print(sum(ls)) +" +p03543,s337756921,Wrong Answer,"import sys +n = input() +for i in n: + if n.count(i) >= 3: + print('Yes') + sys.exit() +print('No') +" +p03435,s491985186,Wrong Answer,"A = list(map(int,input().split())) +B = list(map(int,input().split())) +C = list(map(int,input().split())) +if (sum(A)+sum(B)+sum(C))//3 == A[0]+B[1]+C[2] == A[2]+B[1]+C[0]: + print('Yes') +else: + print('No')" +p02594,s488945624,Accepted,"X=int(input()) +if X>=30: print('Yes') +else: print('No')" +p03943,s762400132,Accepted,"A, B, C = map(int, input().split()) +S = sorted([A,B,C]) + +if S[2] == S[0] + S[1]: + print(""Yes"") +else: + print(""No"") +" +p02911,s791126198,Accepted,"n,k,q = map(int,input().split()) +start = [k-q]*n +answerlist = [int(input()) for _ in range(q)] +for i in tuple(answerlist): + start[i-1] = start[i-1]+1 +for i in range(n): + if start[i]<=0: + print(""No"") + else: + print(""Yes"") + +" +p02554,s932571354,Wrong Answer,"N = int(input()) +# (0.9)確定以外のAnの場合の数 * [(0.9), (9,0)]の2通り * [(0,9),(9,0)]の場合の数 +ans = (10 ** (N - 2) * 2 * (N - 1)) % (10 ** 9 + 7) +print(ans)" +p02598,s191976250,Accepted,"N, K = map(int, input().split()) +A = [int(i) for i in input().split()] + +def f(length, ls): + cur = 0 + for a in ls: + if a%length == 0: + cur += a//length - 1 + else: + cur += a//length + if cur <= K: + return True + else: + return False + +ok, ng = max(A), 0 +while abs(ok - ng) > 1: + z = (ok+ng)//2 + if f(z, A) == True: + ok = z + else: + ng = z +print(ok)" +p02939,s430208179,Accepted,"s = input() +ans = 0 +c = '' +b = '' +for i in list(s): + c += i + if c != b: + ans += 1 + b = c + c = '' +print(ans) " +p03105,s299516370,Accepted,"a,b,c = map(int,input().split()) +can = b//a + +if(cn: + x=count-n + del ans[x-1] + break + +for i in range(len(ans)): + print(ans[i])" +p02678,s438976801,Accepted,"N, M = map(int, input().split()) +L = [[] for _ in range(N+1)] +for _ in range(M): + a, b = map(int, input().split()) + L[a].append(b) + L[b].append(a) + +ans = [0 for _ in range(N+1)] +now = [1] +next = [] + +while len(now): + for x in now: + for y in L[x]: + if (ans[y] == 0) and (y not in now): + ans[y] = x + next.append(y) + now = next.copy() + next = [] + +print(""Yes"") +for x in range(2, N+1): + print(ans[x])" +p03659,s857065492,Accepted,"import itertools +n = int(input()) +a = list(map(int, input().split())) + +n_acc = itertools.accumulate(a) +#r_acc = itertools.accumulate(a[::-1]) +# 1, 3, 6, 10, 15 ,21 +# 1 vs 20 +# 3 vs +#print(n_acc, r_acc) + + +sigma = sum(a) +ans = 10 ** 16 + +for i, val in enumerate(n_acc): + if (i == len(a) - 1): + break + + rest = sigma - val + ans = min(abs(val - rest), ans) + + +print(ans) +" +p03086,s474343756,Accepted,"s = input() +l = len(s) +ans = 0 +for i in range(l): + loc = 0 + idx = i + while s[idx] in [""A"",""C"",""G"",""T""] and idx=l: + break + ans = max(ans,loc) +print(ans)" +p02778,s511241574,Wrong Answer,"s=input() + +print('x' for _ in range(len(s)))" +p03481,s678211717,Accepted,"#!python3 + +# input +X, Y = list(map(int, input().split())) + + +def main(): + ans = 0 + x = X + while x <= Y: + ans += 1 + x *= 2 + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03127,s211123137,Wrong Answer,"n=int(input()) +a=[int(x) for x in input().split()] +mi=min(a) +ans_l=[] +for i in a: + if i==mi: + ans_l.append(i) + else: + ans_l.append(i%mi) + +odd=0 +even=0 +for i in ans_l: + if i%2==0: + even+=1 + else: + odd+=1 + +if odd==0 and 0<=even: + print(min(a)) +else: + print(1)" +p02833,s675882201,Wrong Answer,"def main(): + n = int(input()) + if n%2==1: + print(0) + return + md = 10 + cnt = 0 + while n>md: + cnt += n//md + md = md*5 + print(cnt) + +if __name__ == ""__main__"": + main() +" +p03672,s543231508,Wrong Answer,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(10 ** 7) + +s = input().strip() + +if len(s) == 2: + print('') + sys.exit(0) + +for i in range(1, len(s) // 2): + split_index = (len(s) - i * 2) // 2 + if s[:split_index] == s[split_index:len(s) - i * 2]: + print(len(s) - i * 2) +" +p03286,s756805791,Accepted,"N = int(input()) + +ans_rev = """" if N else ""0"" +while N: + if N % 2 == 1: + ans_rev += '1' + N -= 1 + else: + ans_rev += '0' + N //= (-2) + +print(ans_rev[::-1])" +p02607,s289727231,Accepted,"a = int(input()) +b = list(map(int, input().split())) +count = 0 + +for i in range(a): + if (i + 1) % 2 != 0: + if b[i] % 2 != 0: + count += 1 + +print(count)" +p02707,s298153549,Wrong Answer,"import bisect +N = int(input()) +A = [int(x) for x in input().split()] +index = 0 +for i in range(1, N+1): + now = bisect.bisect_right(A, i) + print(now - index) + index = now +" +p03474,s338726275,Accepted,"a, b = map(int, input().split()) +s = input() +t = s[:a] + s[-b:] +flg = s[a] == ""-"" and t.isdecimal() +print([""No"", ""Yes""][flg])" +p03095,s967237899,Accepted,"#AGC031 A Colorful Subsequence +# Answer +N = int(input()) +S = input() +alpha = [0]*26 +mod = 10**9+7 + +for n in S: + num = ord(n)-97 + alpha[num] += 1 + +ans = 1 +for i in range(26): + ans *= (alpha[i]+1) + +ans -= 1 +ans %= mod +print(ans)" +p03161,s537097695,Wrong Answer,"N, K = map(int, input().split()) +places = list(map(int, input().split())) + +dp_table = [99999999] * (N+1) + +# 初期化 +dp_table[0] = 0 +dp_table[1] = abs(places[1] - places[0]) + +for i in range(2, N): + for j in range(1, K+1): + cost = dp_table[i-j] + abs(places[i] - places[i-j]) + dp_table[i] = dp_table[i] if cost > dp_table[i] else cost + +print(dp_table)" +p03043,s373670153,Accepted,"# 初期入力 +import math +from math import ceil +import sys +input = sys.stdin.readline +N,K = (int(x) for x in input().split()) + +num_prob =1/N +ans =0 +for i in range(1,N+1): + + if K <=i: + ans =(ans + num_prob) + else: + x =ceil(math.log2(K/i)) + ans += num_prob *(0.5**x) #サイコロの確立と表が出続ける確率 +print(ans)" +p03821,s091489244,Wrong Answer,"n = int(input()) +ab = [map(int, input().split()) for _ in range(n)] +a, b = [list(i) for i in zip(*ab)] + +a.reverse() +b.reverse() +ans = 0 +num = 0 +ruisekiwa = 0 + +for j in range(n): + a[j] += ruisekiwa + syou = a[j]//b[j] + if a[j] == 0: + num = 0 + elif b[j] == 1: + num = 0 + else: + num = b[j]*(syou+1) - a[j] + ruisekiwa += num + ans += num + +print(ans)" +p03469,s540959082,Wrong Answer,"S = input() + +# Pythonでは S[3]='8' のような操作は許されないので間接的な方法を用いる +print('2018/01/' + S[-2])" +p03821,s235271991,Accepted,"n = int(input()) +ab = [] +for _ in range(n): + ab.append(list(map(int,input().split()))) + +cnt = 0 +for i in range(n-1,-1,-1): + a,b = ab[i][0],ab[i][1] + num = a + cnt + if num % b == 0: + continue + else: + amari = num % b + cnt += b-amari + +print(cnt)" +p02548,s100619985,Accepted,"N = int(input()) +ans = 0 + +for i in range(1,N): + for j in range(1,N): + if i*j= 22: + print('busu') +else: + print('win')" +p02747,s026606218,Wrong Answer,"import sys +s = list(input()) +c = len(s) +if c%2 == 1: + print(""No"") + sys.exit() +else: + for i in range(c//2): + if not s[2*i] == ""h"" and s[2*i+1] == ""i"": + print(""No"") + sys.exit +print(""Yes"")" +p02951,s914884655,Accepted,"A,B,C = map(int, input().split()) + +x = A - B + +if C <= x: + res = 0 +else: + res = C - x + +print(res)" +p02572,s376917121,Accepted,"#!/usr/bin/env python3 + + +def solve(N, A): + MOD = 10**9 + 7 + total = sum(A) + ans = 0 + + for i in range(N - 1): + total -= A[i] + ans += A[i] * total + ans %= MOD + + return ans + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + + ans = solve(N, A) + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03861,s852625399,Accepted,"a,b,x = map(int,input().split()) +if a%x!=0: + temp = a%x + a += x-temp +if a>b: + print(0) +elif a==b: + print(1) +else: + temp = (b-a)//x + print(temp+1)" +p03160,s866200384,Accepted,"def getval(): + n = int(input()) + h = list(map(int,input().split())) + return n,h + +def main(n,h): + dp = [0,abs(h[1]-h[0])] + for i in range(1,n-1): + x = dp[-1]+abs(h[i+1]-h[i]) + y = dp[-2]+abs(h[i+1]-h[i-1]) + dp.append(min(x,y)) + print(dp[-1]) + +if __name__==""__main__"": + n,h = getval() + main(n,h)" +p03854,s691331834,Accepted,"#!/usr/bin/env python3 + +vocab = set(['dream', 'dreamer', 'erase', 'eraser']) + +def parse(s): + stack = [0] + while stack: + i = stack.pop() + if i == len(s): + return True + for w in vocab: + if s[i:].startswith(w): + stack.append(i + len(w)) + return False + +s = input() +if parse(s): + print('YES') +else: + print('NO')" +p03030,s422111344,Accepted,"n = int(input()) + +id = 0 +res = [] +for i in range(n): + id += 1 + s, p = map(str, input().split()) + res.append([s, -1 * int(p), id]) + +res = sorted(res, key=lambda x: (x[0], x[1])) + +for i in res: + print(i[2]) +" +p02819,s311990578,Wrong Answer,"import math + + +def is_prime(n): + for i in range(2, math.ceil(math.sqrt(n)) + 1): + if n % i == 0: + return False + return True + + +X = int(input()) + +while not is_prime(X): + X += 1 + +print(X)" +p03327,s164001104,Accepted,"n = int(input()) +if 1 <= n and n <= 999: + print('ABC') +else: + print('ABD')" +p03861,s483350723,Accepted,"a, b, x = map(int, input().split()) + +print(b//x - (a-1)//x)" +p02773,s519485008,Accepted,"from collections import Counter +a = [] +for i in range(int(input())): + a.append(input()) +a = Counter(a) +m = a.most_common()[0][1] +for i, j in sorted(a.most_common()): + if j ==m: print(i) +" +p03611,s085509914,Wrong Answer,"import collections +N = int(input()) +a = list(map(int, input().split())) +if N == 1: + print(1) + exit() +c = collections.Counter(a) +c_key = list(c.keys()) +c_value = list(c.values()) +res = 0 +for i in range(1,len(c)-1): + temp = c_value[i] + if int(c_key[i])-int(c_key[i-1]) == 1: + temp += c_value[i-1] + if int(c_key[i+1])-int(c_key[i]) == 1: + temp += c_value[i+1] + if temp > res: + res = temp +print(res)" +p02713,s671730349,Accepted,"import math + +K = int(input()) + +def sol(K): + res = 0 + for i in range(1, K+1): + for j in range(1, K+1): + t = math.gcd(i, j) + for k in range(1, K+1): + res += math.gcd(k, t) + + return res + +print(sol(K))" +p03127,s840233834,Accepted,"def gcd(x, y): + if x < y: + x, y = y, x + if y == 0: + return x + return gcd(x % y, y) + + +n = int(input()) +a = list(map(int, input().split())) +ans = 0 +for x in a: + ans = gcd(ans, x) +print(ans) +" +p02723,s440507158,Accepted,"n = input() +if n[2]==n[3] and n[4]==n[5]: + print(""Yes"") +else: + print(""No"")" +p02859,s059010489,Accepted,"r = int(input()) +print(r ** 2)" +p03434,s502381993,Accepted,"N = int(input()) +list_a = list(map(int,input().split())) +list_a.sort(reverse=True) +alice = 0; bob = 0 +for i in range(len(list_a)): + if i % 2 == 0: + alice += list_a[i] + else: + bob += list_a[i] +print(alice-bob)" +p03352,s685151336,Accepted,"k = [] +for i in range(1,40): + for j in range(2,30): + if i**j <= 1000: + k.append(i**j) +L = set(k) +P = list(L) +P.sort() +X = int(input()) +ans = 0 +if X == 1000: + print(1000) +else: + for i in range(len(P)): + if X mx: + mx = 10-ai%10 +print(s-mx)" +p02899,s787153160,Accepted,"N = int(input()) +A =[int(x) for x in input().split()] +ans = [0]*N + +for i in range(N): + ans[A[i]-1] = i+1 + +print(*ans)" +p02753,s071098423,Wrong Answer,"s = input() +a = int(s.count(""A"")) +b = int(s.count(""B"")) + +if a or b == 3: + print(""No"") + +else: + print(""Yes"")" +p03219,s259688926,Accepted,"x, y = map(int, (input().split())) +print(int(x + y / 2)) +" +p02789,s912110268,Accepted,"# 2020/01/19 +# AtCoder Beginner Contest 152 - A + +# Input +c, d = map(int,input().split()) + +# Calc +if c == d: + ans = ""Yes"" +else: + ans = ""No"" + +# Output +print(ans) +" +p03657,s175506134,Accepted,"a,b = map(int,input().split()) +if a%3==0 or b%3==0 or (a+b)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p03986,s919334837,Accepted,"string = input() + +length = len(string) +sindex = 0 +for i in range(0, length): + if string[i] == ""S"": + sindex = i + break + +s_count = 0 + +for i in range(sindex, len(string)): + if string[i] == ""S"": s_count += 1 + if string[i] == ""T"" and s_count > 0: + s_count -= 1 + length -= 2 + +print(length)" +p03524,s632736369,Accepted,"s=input() +a=s.count(""a"") +b=s.count(""b"") +c=s.count(""c"") +if max(a,b,c)-min(a,b,c)<=1: + print(""YES"") +else: + print(""NO"") +" +p03095,s532997991,Wrong Answer,"import collections +N = int(input()) +S = input() +A = collections.Counter(S) +B = list(""qwertyuiopasdfghjklzxcvbnm"") +C = [] +for i in B: + C.append(A[i]) +D = [i+1 for i in C if i != 0] +ans = 1 +for i in range(len(D)): + ans *= D[i] +print(ans-1)" +p02702,s085149006,Accepted,"S = input()[::-1] +digits = 1 +Sum, ans = 0, 0 +l = [0] * 2019 +l[0] = 1 + +for c in S: + Sum += int(c) * digits % 2019 + Sum %= 2019 + l[Sum] += 1 + digits = digits * 10 % 2019 + +for i in range(len(l)): + ans += l[i] * (l[i] - 1) // 2 + +print(ans)" +p03385,s970048074,Accepted,"print(""Yes"" if len(set(input())) == 3 else ""No"")" +p03435,s109421326,Accepted,"c = [ [0,0,0] for _ in range(3)] +for i in range(3): + c[i] = list(map(int, input().split())) +for a0 in range(101): + b0 = c[0][0] - a0 + b1 = c[0][1] - a0 + b2 = c[0][2] - a0 + if (((c[1][0]-b0) == (c[1][1]-b1) == (c[1][2]-b2)) and + ((c[2][0]-b0) == (c[2][1]-b1) == (c[2][2]-b2))): + print(""Yes"") + break +else: + print(""No"") + +" +p02801,s056669300,Wrong Answer,"let = input() +li = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] +for i in range(24): + if li[i] == let: + print(li[i+1]) + break" +p03059,s268446689,Accepted,"A, B, T = map(int, input().split()) +ans = 0 +while T-A >= 0: + T-= A + ans += B +print(ans)" +p02766,s844462153,Wrong Answer,"N, K = map(int, input().split()) +T = 0 + +while T != 0: + N = N // K + T += 1 + +print(T)" +p02823,s190085101,Accepted,"import sys +input = sys.stdin.readline + +# A - Table Tennis Training +def move_left(): + return A + (B-A-1)//2 + + +def move_right(): + return N - B + 1 + (B-A-1)//2 + + +N, A, B = map(int, input().split()) + +if (B-A) % 2 == 0: + print(int((B-A)//2)) +else: + l = move_left() + r = move_right() + print(min(l, r))" +p02624,s868379227,Accepted,"# (1,2,3,4,5..,N) + (1,2,3,4,...,N/2) * 2 + (1,2,...,N/3) * 3 + ...+(1,) * N +# 累積和を使うことでO(1)でそれぞれの計算をする.N回ループをするので,合計O(N)の計算量で終了する + +N = int(input()) + +S=[0]*(N+1) +for i in range(1,N+1): + S[i] = S[i-1] + i + +ans = 0 +for i in range(1,N+1): + ind = int(N/i) + ans += S[ind] * i + +print(ans) + +" +p03673,s625251233,Accepted,"n = int(input()) +As = list(map(int, input().split())) + +if n%2 == 0: + inds = list(range(n-1,0,-2)) + list(range(0,n,2)) +else: + inds = list(range(n-1,-1,-2)) + list(range(1,n,2)) + +Bs = [As[i] for i in inds] +print(*Bs)" +p03548,s782977292,Wrong Answer,"a,b,c=map(int, input().split()) +print((a-b-2*c)//2+1)" +p03951,s188989889,Wrong Answer,"N = int(input()) +s = input() +t = input() +if s==t: + print(N) + exit() +s = s[::-1] +cnt = 0 +for c1, c2 in zip(s,t): + if c1 != c2: + break + cnt += 1 + +print(N*2-cnt) + +" +p02755,s898343159,Accepted,"import math +A,B = map(int,input().split()) + +ans = [] +for ans in range(1,1251): + if math.floor(ans*0.08) == A and math.floor(ans*0.1) == B: + print(ans) + exit() + +print(-1)" +p02820,s831990625,Wrong Answer,"N,K=map(int,input().split()) + +r,s,p = map(int,input().split()) + +T=list(input()) +T=''.join(list(reversed(T))) + + +d={} +for j in range(N): + if T[j]=='r': + d[j]=p + elif T[j]=='s': + d[j]=r + else: + d[j]=s + +for i in range(N): + if i-K in d: + if d[i]==d[i-K]: + d[i]=0 + +score=0 + +for _,val in d.items(): + score+=val + +print(score)" +p02801,s947317460,Wrong Answer,"C = input() + +next = ord('C') + 1 +print(chr(next))" +p02772,s075548977,Accepted,"N = int(input()) +data = list(map(int,input().split())) +sw1 = 0 +sw2 = 0 +for i in range(0,len(data)): + if data[i] % 2 == 0: + sw1 += 1 + if data[i] % 3 == 0 or data[i] % 5 == 0: + sw2 += 1 + +if sw1 >= 0 and sw1 == sw2: + print(""APPROVED"") +else: + print(""DENIED"")" +p03351,s067588882,Accepted,"a, b, c, d = map(int, input().split()) + +#a a: + print('No') +else: + print('Yes') +" +p02909,s328575167,Wrong Answer,"S = input( '今日の天気は?' ) + +if S == 'Sunny': + answer = 'Cloudy' +elif S == 'Cloudy': + answer = 'Rainy' +elif S == 'Rainy': + answer = 'Sunny' +else: + answer = '入力間違い【Sunny】【Cloudy】【Rainy】を入力' + +print('明日の天気は',answer)" +p03037,s630412394,Accepted,"N, M = map(int, input().split()) +MIN = 0 +MAX = 110000 + +for i in range(M): + L, R = map(int, input().split()) + MIN = max(MIN, L) + MAX = min(MAX, R) + #print(MIN, MAX) + +ans = MAX-MIN+1 if MAX >= MIN else 0 +print(ans)" +p02843,s861633401,Wrong Answer,"def solve(): + X = int(input()) + p = X / 100 + q = X % 100 + if 0 <= q <= 5 * p: + print(1) + else: + print(0) + +if __name__ == ""__main__"": + solve()" +p02879,s519282504,Accepted,"A, B = map(int, input().split()) +print(A * B if A <= 9 and B <= 9 else -1)" +p02924,s004942284,Wrong Answer,"a = int(input()) +print(int((a)*(a-1)/2))" +p03329,s599702369,Accepted,"n = int(input()) + +res = 100000 +for i6 in range(0, n+1, 6): + c6, c9 = 0, 0 + i9 = n - i6 + while (i6 > 0): + c6 = c6 + (i6%6) + i6 = i6 // 6 + while (i9 > 0): + c9 = c9 + (i9%9) + i9 = i9 // 9 + + if c6 + c9 < res: + res = c6 + c9 + +print(res)" +p02814,s988427133,Accepted,"import sys +sys.setrecursionlimit(10**5) +def GCM(a, b): + a, b = max(a,b), min(a, b) + r = a % b + if r == 0: + return b + else: + return GCM(b, r) + +def LCD(a, b): + g = GCM(a, b) + return (a//g)*b + +N, M = map(int, input().split()) +A = list(map(int, input().split())) +X = A[0]//2 +for a in A[1:]: + b = a//2 + newX = LCD(X, a//2) + if (newX // b)%2 == 0: + print(0) + sys.exit(0) + else: + X = newX +X_2 = X*2 +print(M//X-M//X_2)" +p03076,s218898924,Wrong Answer,"l=[int(input()) for i in range(5)] +mod=sorted([10-n%10 for n in l]) +c=mod.count(10) +print(sum(l)+sum(mod)-mod[4-c]-10*c)" +p02548,s444561056,Accepted,"n = int(input()) + +res = 0 +for a in range(1, n): + max_b = int((n-1)/a) + res += max_b + +print(res)" +p04044,s006775050,Accepted,"N, L = map(int, input().split()) +S = [str(input()) for i in range(N)] + +S = sorted(S) + + +print(''.join(S))" +p02761,s632737820,Wrong Answer,"n, m = list(map(int, input().split())) +ss = [] +cs = [] +for i in range(m): + s, c = list(map(int, input().split())) + ss.append(s) + cs.append(str(c)) + +ans = [""_""] * n + +for s, c in zip(ss, cs): + # print(f""ans={ans}: s={s}, c={c}"") + if ans[s-1] == ""_"" or ans[s-1] == c: + ans[s-1] = c + else: + print(""-1"") + exit() + +if ans[0] == ""0"": + print(""-1"") + exit() + +if ans[0] == ""_"": + ans[0] = ""1"" + +print("""".join(ans).replace(""_"", ""0"")) +" +p03327,s626992036,Accepted,"n = int(input()) +if n<=999: print('ABC') +else: print('ABD')" +p03665,s530647835,Accepted,"n, p = map(int, input().split()) +a = list(map(int, input().split())) + +count = 0 +for i in a: + if i%2 == 0: + count += 1 +if count == n: + if p == 1: + print(0) + else: + print(2**n) +else: + print(2**(n-1)) + + +" +p02578,s286172833,Accepted,"import bisect,collections,copy,itertools,math,string +import sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip.split()) +def main(): + n = I() + a = LI() + bemax = a[0] + ans = 0 + for i in a[1:]: + if i > bemax: + bemax = i + elif i < bemax: + ans += bemax - i + print(ans) +main()" +p04011,s021460565,Accepted,"N = int(input()) +K = int(input()) +X = int(input()) +Y = int(input()) +if N<=K: + print(N*X) +else: + print((K*X)+(N-K)*Y)" +p02760,s274693447,Accepted,"al = [list(map(int, input().split())) for i in range(3)] +al = sum(al, []) +n = int(input()) +bl = [int(input()) for i in range(n)] +check = [0 for i in range(9)] + +for b in bl: + if b in al: + check[al.index(b)] = 1 + +if [1,1,1] in [check[:3], check[3:6], check[6:], check[0:7:3], check[1:8:3], check[2:9:3], check[0:9:4], check[2:8:2]]: + print(""Yes"") +else: + print(""No"") +" +p03657,s848052852,Wrong Answer,"print([""Impossible"", ""Possible""][eval(input().replace("" "",""*""))%3==0])" +p02935,s326662712,Wrong Answer,"import sys +import os + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + N = int(sys.stdin.buffer.readline().rstrip()) + V = list(map(int, sys.stdin.buffer.readline().split())) + V.sort(reverse=True) + + ret = 0 + for n in range(N-1): + ret = (V[n] + V[n+1]) / 2 + + print(ret) + + +if __name__ == '__main__': + main() +" +p03407,s169812740,Wrong Answer,"import sys +input = sys.stdin.readline +a,b,c=map(int, input().split()) +if (a+b)>c: + print('Yes') +else: + print('No')" +p02696,s997360138,Accepted,"a,b,n = map(int, input().split()) +# ans = [] +if(b-1<=n): + i = b-1 +else: + i = n +# for i in range(0, n): +ans = (a*i)//b - a*(i//b) +print(ans)" +p03419,s133268081,Accepted,"import sys +input = sys.stdin.readline + +n, m = map(int, input().split()) +if n == 1 or m == 1: + if n == m == 1: + ans = 1 + else: + ans = max(n - 2, m - 2) +else: + ans = (n - 2) * (m - 2) +print(ans) +" +p03814,s655580612,Accepted,"s = input() +print(s.rfind(""Z"") - s.find(""A"") + 1) +" +p03319,s543728215,Accepted,"N,K=map(int,input().split(' ')) +ans = 0 +while N > 0: + ans += 1 + N -=K + if N > 0: + N+=1 +print(ans)" +p02622,s471216444,Wrong Answer,"s1 = input() +s2 = input() + +for i in range(len(s1)): + count = len(s1) + if s1[i] == s2[i]: + count -= 1 + +print(count)" +p04005,s943983702,Accepted,"A,B,C = map(int,input().split()) +if A % 2 == 1 and B % 2 == 1 and C % 2 == 1: + print(min(A*B,B*C,C*A)) +else: + print(0)" +p03062,s052374732,Accepted,"N = int(input()) +A = list(map(int, input().split())) +INF = 10**9 + +dp0 = [0] +dp1 = [-INF-1] + +for i, x in enumerate(A): + dp0.append( max(dp0[i] + x, dp1[i] - x) ) + dp1.append( max(dp0[i] - x, dp1[i] + x) ) + +print(dp0[-1]) +" +p02706,s889497886,Accepted,"N,M = map(int, input().split()) +A = list(map(int, input().split())) +print(max(N-sum(A),-1))" +p03103,s512463489,Accepted,"N, M = map(int, input().split()) +AB = [0] * N +for i in range(N): + AB[i] = list(map(int, input().split())) +AB.sort(key=lambda AB: AB[0]) + +cnt = 0 +ans = 0 +for i in range(N): + cnt += AB[i][1] + ans += AB[i][0] * AB[i][1] + if cnt > M: + ans -= (cnt - M) * AB[i][0] + break +print(ans)" +p03345,s191754897,Wrong Answer,"a, b, c, k = map(int, input().split()) + +flag = True +for i in range(10**18): + if k == 0: + break + if a == b and b == c: + break + A = a + B = b + C = c + a = B + C + b = A + C + c = A + B + if i == k - 1: + break + if a > 10**19: + flag = False + break +if flag: + print(a - b) +else: + print('Unfair') +" +p02911,s094195210,Wrong Answer,"N, K, Q = map(int,input().split()) +a = [] +for i in range(Q): + A = int(input()) + a.append(A) +if K > Q: + for i in range(N): + print('Yes') +for i in range(1,N + 1): + if Q - K + 1 <= a.count(i): + print('Yes') + else: + print('No')" +p02633,s785487951,Wrong Answer,"def default(): + t=int(input()) + print(min(360//t,306//(180-t))) +if(__name__==""__main__""): + default() +" +p03274,s817404449,Accepted,"N, K = map(int, input().split()) +X = list(map(int, input().split())) +ret = 10 ** 9 +for i in range(N-K+1): + width = X[i+K-1] - X[i] + mi = min(abs(X[i+K-1]), abs(X[i])) + ret = min(ret, width+mi) + +print(ret) +" +p03289,s569811896,Wrong Answer,"def main(): + S = input() + + if S[0] == 'A': + if S[2]=='C' or S[3]=='C': + S = S[1]+S[4:] + if S.islower(): + print('AC') + return + print('WA') + +if __name__ == '__main__': + main() +" +p02897,s156825240,Accepted,"N=int(input()) +result=0 +for i in range(0,N+1): + if i%2 != 0: + result+=1 + else: + result+=0 +print(float(result/N))" +p02645,s684231936,Accepted,"s=input() +ans="""" +for i in range(3): + ans+=s[i] +print(ans)" +p02880,s079376704,Accepted,"list=[] +for i in range(1,10): + for j in range(1,10): + list.append(i*j) + +if int(input()) in list: + print(""Yes"") +else: + print(""No"") + " +p02911,s417981298,Wrong Answer,"import collections + +N,K,Q = map(int,input().split()) +A = [int(input()) for i in range(Q)] +c = collections.Counter(A) + +if (K - Q) > 0: + for _ in range(N): + print('Yes') +else: + l = [] + for i,v in dict(c).items(): + if v >(Q - K): + l.append(i-1) + for j in range(N): + if j in l: + print('Yes') + l.pop() + else: + print('No')" +p03673,s308723996,Accepted,"from collections import deque + +n = int(input()) +A = list(map(int,input().split())) +que = deque() + +for i in range(n): + if i % 2 == 0: + que.appendleft(A[i]) + else: + que.append(A[i]) +else: + if n % 2 == 0: + que.reverse() + print(*que)" +p02657,s846541521,Accepted,"print(eval(input().replace("" "",""*"")))" +p04011,s022273235,Wrong Answer,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +print(k * x + (n - k) * y)" +p03696,s984903512,Accepted,"N = int(input()) +S = input().strip() + +ans = """" + +l = 0 +r = 0 + +for i in range(N): + if S[i] == ""("": + l += 1 + ans += ""("" + else: + r += 1 + if l >= r: + ans += "")"" + else: + ans = ""("" + ans + "")"" + l += 1 + +while l < r: + ans = ""("" + ans + l += 1 +while l > r: + ans += "")"" + r += 1 + +print(ans) +" +p03632,s624454113,Wrong Answer,"A,B,C,D = map(int,input().rstrip().split("" "")) +print(min(B,D) - max(A,C)) +" +p02973,s603595300,Accepted,"import sys +import bisect + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) + +N = ir() +INF = 10 ** 10 +dp = [INF] * N +# マイナスの値にしてLongest Increasing Sequence +for _ in range(N): + a = 10 ** 9 - ir() + i = bisect.bisect_right(dp, a) + dp[i] = a + +index = bisect.bisect_left(dp, INF) +print(index) +# 04" +p03698,s248671228,Accepted,"s = input() +if len(s) == len(set(s)): + print(""yes"") +else: + print(""no"")" +p02600,s588042885,Wrong Answer,"X = int(input()) + +if X >=1800 and X <1999: + print(1) +elif X >=1600 and X <=1799: + print(2) +elif X >=1400 and X<=1599: + print(3) +elif X >=1200 and X<=1399: + print(4) +elif X >= 1000 and X <=1099: + print(5) +elif X >= 800 and X <= 999: + print(6) +elif X >= 600 and X <= 799: + print(7) +elif X >= 400 and X <= 599: + print(8)" +p03380,s312934519,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +nmax = max(a) +target = nmax/2 + +cur = a[0] if a[0] != nmax else a[1] +curdiff = abs(cur-target) + +for i in range(n): + if a[i] == nmax: + continue + + diff = abs(a[i]-target) + + if diff < curdiff: + curdiff = diff + cur = a[i] + +print(nmax, cur)" +p02910,s393081897,Accepted,"s=list(input()) +flag=True +for i in range(1,len(s)+1): + v=s[i-1] + if i%2==0: + if v==""L"" or v==""U"" or v==""D"": + pass + else: + flag=False + break + else: + if v==""R"" or v==""U"" or v==""D"": + pass + else: + flag=False + break +if flag: + print(""Yes"") +else: + print(""No"") +" +p03011,s793214940,Accepted,"p = list(map(int, input().split())) +print(sum(p) - max(p))" +p03220,s802024896,Accepted,"N=int(input()) +T,A=map(int,input().split()) +H=list(map(int,input().split())) +c=100000 +ans=0 +for i in range(N): + if c>abs(T-H[i]*0.006-A): + c=abs(T-H[i]*0.006-A) + ans=i+1 +print(ans)" +p02881,s101713391,Accepted,"#C +N = int(input()) + +inf = float(""inf"") +MIN = inf + +for i in range(1,10**6+1): + if N%i == 0: + MIN = min(MIN,(i-1) + (N//i - 1)) + +print(MIN) + +" +p03145,s432572962,Wrong Answer,"A,B,C=map(int,input().split()) +print(A*B/2)" +p03030,s832024473,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10**8) +INF = float('inf') +MOD = 10**9+7 + + +def main(): + N = int(readline()) + A = [] + for i in range(N): + s, p = input().split() + p = int(p) + A.append((s, -p, i+1)) + A.sort() + for s, p, i in A: + print(i) + +if __name__ == '__main__': + main()" +p02623,s799895310,Accepted,"N,M,K = map(int,input().split("" "")) +A = list(map(int,input().split("" ""))) +B = list(map(int,input().split("" ""))) + +time_A = [0]*(N+1) +time_B = [0]*(M+1) + +for i in range(N): + time_A[i+1] = time_A[i] + A[i] +for j in range(M): + time_B[j+1] = time_B[j] + B[j] + +ans = 0 +l = M + +for k in range(N+1): + if time_A[k] > K: + break + while time_A[k] + time_B[l] > K: + l -= 1 + ans = max(ans,k+l) + +print(ans)" +p03435,s488527325,Accepted,"c = [[int(i) for i in input().split()] for j in range(3)] +f = True +a, b = c[0][0] - c[0][1], c[0][1] - c[0][2] +for i in range(1, 3): + if not(c[i][0] - c[i][1] == a and c[i][1] - c[i][2] == b): + f = False +a, b = c[0][0] - c[1][0], c[1][0] - c[2][0] +for i in range(1, 3): + if not(c[0][i] - c[1][i] == a and c[1][i] - c[2][i] == b): + f = False +print(""Yes"" if f else ""No"")" +p02707,s771981142,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +ans = [0] * n + +for i in a: + ans[i - 1] += 1 + +for j in ans: + print(j)" +p03645,s194701317,Accepted,"def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) +def ism():return map(str,input().split()) +def isl():return list(map(str,input().split())) +n,m = iim() +cand = [] +check = [] +for i in range(m): + a,b = iim() + if a == 1: + cand.append(b) + if b == n: + check.append(a) + +cand = set(cand) +flag=False +for i in check: + if i in cand: + flag = True + +print('POSSIBLE' if flag else 'IMPOSSIBLE')" +p02765,s365242084,Accepted,"N, R = map(int, input().split()) + +print(R + 100 * max(0, 10 - N)) +" +p02624,s075702794,Accepted,"import sys +from collections import deque +def input(): return sys.stdin.readline().strip() +mod = 10**9+7 + +def main(): + N = int(input()) + ans = 0 + for n in range(1, N + 1): + k = N // n + ans += n * k * (k + 1) // 2 + print(ans) + +if __name__ == ""__main__"": + main() +" +p03632,s032981905,Accepted,"A, B, C, D = map(int, input().split()) +t = min(B, D) - max(A, C) +print(t if t > 0 else 0)" +p03524,s022085379,Wrong Answer,"S = input() +C = [S.count('a'), S.count('b'), S.count('c')] +if len(set(list(S))) == 3 and max(C) - min(C) < 2: + print('YES') +else: + print('NO')" +p02578,s702917054,Wrong Answer,"n=int(input()) +k=map(int,input().split()) +p=sorted(k) +print(p[-1]-p[0])" +p03986,s777233575,Wrong Answer,"x = list(input()) +box = [] + +for i in range(len(x)): + if x[i] == ""S"": box.append(x[i]) + else: + if len(box) == 0 or box[-1] == ""S"": + box.append(x[i]) + else: box.pop(-1) +print(len(box))" +p02957,s896944662,Accepted,"a, b = map(int, input().split()) +if (a+b)%2 == 0: + print((a+b)//2) +else: + print('IMPOSSIBLE')" +p02683,s133250431,Accepted,"n,m,x = (int(x) for x in input().split()) + +la=[] +for i in range(n): + la.append(list(map(int, input().split()))) + +y = 0 +for i in range(2 ** n): + lb = [0]*(m+1) + for j in range(n): + if ((i >> j) & 1): + lb = [x + y for (x, y) in zip(lb, la[j][:])] + frg=1 + for h in range(m): + if lb[h+1]0 else -1)" +p02760,s095245131,Accepted,"a=open(0).read().split();print('YNeos'[all(t-set(map(a.index,a[10:]))for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2])" +p02699,s094612525,Accepted,"S, W = [int(_) for _ in input().split()] +if W >= S: + print('unsafe') +else: + print('safe')" +p03160,s297575259,Accepted,"n = int(input()) +h = list(map(int, input().split())) +dp =[] + +for i in range(n): + if i == 0: + dp.append(0) + elif i == 1: + dp.append(abs(h[1]-h[0])) + else: + dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1])) + +print('{}'.format(dp[n-1]))" +p03160,s060071492,Wrong Answer,"n=int(input()) +dp=[100000]*n +h=list(map(int,input().split())) +dp[0]=0 +for i in range(n): + for j in range(i+1,i+3): + if j= 3: + s -= 3 + cnt += 1 + if s > 0: + ans += comb(s+cnt, cnt, exact=True)%MOD + else : + ans += 1 + print(ans) + +" +p02778,s500108168,Wrong Answer,"S = int(len(input())) + +cnt = ""*"" +length = 0 +a = ""*"" + +while S != length: + cnt = cnt + a + length = len(cnt) + +print(cnt)" +p03062,s383569441,Wrong Answer,"import sys + +N = int(input()) +A = list(map(int, input().split())) + + +ans = 0 +for a in A: + ans += abs(a) + +c = 0 +m = A[0] +for a in A: + if a < 0: + c += 1 + elif a == 0: + print(ans) + sys.exit() + + if abs(a) < m: + m = abs(a) + +if c % 2 == 0: + print(ans) +else: + print(ans - 2 * m) +" +p02982,s821810336,Wrong Answer,"n,d = map(int, input().split()) +x = [list(map(int, input().split())) for _ in range(n)] + +cnt=0 +for i in range(n): + for j in range(i+1,n): + sum=0 + for k in range(d): + sum += (x[i][k]-x[j][k])**2 + route = sum**0.5 + if route.is_integer: + cnt += 1 + +print(cnt)" +p04005,s866977287,Accepted,"A = sorted(list(map(int,input().split()))) +print(A[0]*A[1]*(A[2]-(A[2]//2)*2))" +p02594,s658244291,Wrong Answer,"k = int(input()) +seven = 7 +count = 0 + +while True: + if k % 2 == 0: + count = -1 + break + + elif seven % k == 0: + count += 1 + break + else: + count += 1 + seven = (seven * 10 + 7) % k + +print(count)" +p02912,s877263192,Accepted,"import heapq + +N, M = map(int, input().split()) +A = [-x for x in map(int, input().split())] + +heapq.heapify(A) +for i in range(M): + tmp = -heapq.heappop(A) + tmp = tmp // 2 + heapq.heappush(A, -tmp) + # print(A) +print(-sum(A)) + +" +p02603,s907504149,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +lis = [0]*n +for i in range(n-1): + if a[i] > a[i+1]: + lis[i] = -1 +b = a[::-1] +for i in range(n-1): + if b[i] > b[i+1]: + lis[i] = 1 +lis[-1] = -1 +m = 1000 +k = 0 +for i in range(n): + if lis[i] == 1: + k += m//a[i] + m = m%a[i] + elif lis[i] == -1: + m += k*a[i] + k = 0 + +print(m) +" +p02602,s655454641,Accepted,"[N, K] = [int(i) for i in input().split()] +point_list = [int(i) for i in input().split()] + +for i in range(N): + if i >= K: + if point_list[i-K] < point_list[i]: + print(""Yes"") + else: + print(""No"") +" +p03289,s683553470,Wrong Answer,"# -*- coding: utf-8 -*- +"""""" +Created on Wed May 13 16:16:15 2020 + +@author: shinba +"""""" +import sys + +s = list(input()) + +if s[0] != ""A"": + print(""WA"") + sys.exit() +else: + s = s[1:] + +t = s[1:len(s)-1] + +if t.count(""C"") != 1: + print(""WA"") + sys.exit() +else: + t.remove(""C"") + +t.append(s[-1]) + +if """".join(t) == """".join(t).lower(): + print(""AC"") +else: + print(""WA"") +" +p03262,s332208776,Wrong Answer,"from fractions import gcd +N, X = map(int, input().split()) +x = list(map(int, input().split())) +if(N == 1): print(x[0]) +ans = abs(X - x[0]) +for i in range(1, len(x)): + ans = gcd(abs(x[i] - x[i - 1]), ans) +print(ans)" +p02681,s080962029,Wrong Answer,"s = input() +t = input() + +t = t.rstrip(t[len(t)-1]) + +if(s == t): + print(""yes"") +else: + print(""no"") +" +p03680,s673727135,Accepted,"# import bisect +# import copy +# import fractions +# import math +# import numpy as np +# from collections import Counter, deque +# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product + +def resolve(): + N=int(input()) + + A=[int(input()) for i in range(N)] + num=0 + cnt=0 + + for i in range(N): + if A[num]==2: + print(cnt+1) + break + num=A[num]-1 + cnt+=1 + + if i==N-1: + print(-1) + +resolve()" +p03962,s195982324,Accepted,"s=input().split(' ') +print(len(set(s)))" +p03680,s170817911,Accepted,"N = int(input()) +A = [0] + [int(input()) for _ in range(N)] + +light = 1 +goal = 2 +for i in range(1, 10**6): + light = A[light] + if goal == light: + print(i) + exit() +print(-1) +" +p03815,s327017594,Accepted,"N=int(input()) +c=(N+10)//11 +print(2*c-((N+10)%11<6))" +p02687,s857121706,Accepted,"s = input() + +if s==""ABC"": + print(""ARC"") +else: + print(""ABC"") +" +p02700,s435172433,Wrong Answer," +A, B, C, D = [int(x) for x in input().split()] + +if A + B >= C + D: + print('Yes') +else: + print('No')" +p03293,s767575429,Wrong Answer,"S=input() +T=input() + +for i in range(100): + if S[-1-i:-1:-1]+S[0:100-i] ==T: + print(""Yes"") + break +else: + print(""No"")" +p03324,s418087944,Accepted,"d,n=map(int, input().split()) +if n==100:n=101 +s=(100**d)*n +print(s)" +p03071,s611036181,Wrong Answer,"a, b = map(int, input().split()) +print(2*max(a, b)-1)" +p02767,s820511408,Accepted,"n=int(input()) +x=list(map(int, input().split())) +a=min(x);b=max(x)+1 +ans=[] +for i in range(a,b): + res=0 + for j in range(n): + res+= (i-x[j])**2 + ans+=[res] +print(min(ans))" +p03109,s982331104,Wrong Answer," +x=list(map(int,input().split(""/""))) + + +if x[0]<2019: + print(""HEISEI"") +elif x[0]==2019 and x[1]<=4: + print(""HEISEI"") + +elif x[1]>4 and x[0]==2019: + print(""TBD"") +else: + print(""TBD"") " +p03695,s453454261,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = [0]*8 +leng = 0 + +for i in range(N): + now = A[i]//400 + if now < 8: + ans[now] = 1 + else: + leng += 1 + +mi = sum(ans) if sum(ans) > 0 else 1 +print(mi, sum(ans) + leng) +" +p03210,s191250579,Wrong Answer,"x = input() + +if x in ""753"": + print(""Yes"") +else: + print(""No"") +" +p03645,s535370616,Wrong Answer,"import sys +from collections import defaultdict +from collections import deque + +n, m = map(int, input().split()) + +graph = defaultdict(list) + +for _ in range(m): + a, b = map(lambda x: int(x), input().split()) + graph[a].append(b) + graph[b].append(a) + +q = deque([1]) +cnt = 0 + +while q and cnt <= 2: + node = q.popleft() + after = graph[node] + + for a in after: + if a == n: + print(""POSSIBLE"") + sys.exit() + q.append(a) + cnt += 1 +print(""IMPOSSIBLE"")" +p02832,s904742631,Wrong Answer,"n = int(input()) +a = [int(x) for x in input().split()] + +place = [] +isfail = False +if 1 not in a: + isfail = True +if n == 1 and a[0] == 1: + place.append(1) +elif n == 1 and a[0] != 1: + isfail = True + +for x in range(1, n): + try: + if x in a: + place.append(a.index(x)) + a = a[a.index(x):] + else: + break + except: + isfail = True + break + +if isfail: + print(""-1"") +else: + print(n - len(place))" +p03795,s913189413,Accepted,"N = int(input()) + +y = N // 15 +x = N * 800 + +if y >= 1: + print( x - (y * 200)) +else: + print(x)" +p02897,s039751630,Wrong Answer,"n= int(input()) +if n%2==0:print(n/2) +elif n==1:print(1) +else:print((n//2 +1)/n)" +p02983,s745666541,Accepted,"L,R=list(map(int, input().split())) +M=2019 +if R-L==1: + print(((R%M)*(L%M))%M) + exit() +if L//M!=R//M: + print(0) + exit() +L=L%M +R=R%M +ans=M +for i in range(L,R+1): + for j in range(i+1,R+1): + ans=min(ans,(i*j)%M) +print(ans) +" +p03657,s895584721,Accepted,"a,b=map(int,input().split()) +if a%3==0 or b%3==0 or (a+b)%3==0: + ans=""Possible"" +else: + ans=""Impossible"" +print(ans)" +p02570,s705177504,Accepted,"D,T,S = map(int,input().split()) + +if D <= T * S: + print(""Yes"") +else: + print(""No"") +" +p03486,s495450590,Wrong Answer,"s = sorted(input()) +t = sorted(input(), reverse=True) +alf = 'abcdefghijklmnopqrstuvwxyz' +r = 'No' +if len(s)y: + break + ans+=1 +print(ans) +" +p03699,s787676398,Accepted,"n=int(input()) +l=[int(input())for _ in range(n)] +l.sort() +ans=sum(l) +if ans%10!=0: + print(ans) + exit() +for s in l: + if (ans-s)%10!=0: + print(ans-s) + exit() +print(0) +" +p03998,s559688725,Accepted,"S=[input() for i in range(3)] + +flag=1 +i=0 + +while flag==1: + t=S[i][0] + if t=='a': + ni=0 + elif t=='b': + ni=1 + elif t=='c': + ni=2 + + S[i]=S[i][1:] + #print(i,S[i]) + if S[ni]=='': + print('A' if ni==0 else 'B' if ni==1 else 'C') + flag=0 + else: + i=ni" +p03284,s145248252,Accepted,"N, K = map(int, input().split()) +if N%K == 0: + print(0) +else: + print(1)" +p02775,s277541660,Accepted,"import sys +input = sys.stdin.readline + +N = [int(x) for x in input().rstrip()][::-1] + [0] +L = len(N) + +dp = [[10 ** 18, 10 ** 18] for _ in range(L + 1)] +dp[0] = [0, 0] +dp[1] = [N[0], 10 - N[0]] + +for i in range(2, L + 1): + n = N[i - 1] + dp[i][0] = min(dp[i - 1][0] + n, dp[i - 1][1] + (n + 1)) + dp[i][1] = min(dp[i - 1][0] + (10 - n), dp[i - 1][1] + (10 - (n + 1))) + +print(dp[-1][0]) +" +p02601,s913789267,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) +cnt = 0 +ans = False +while True: + if cnt > K: + break + + if B > A and C > B: + ans = True + break + + if B <= A: + B *= 2 + cnt += 1 + continue + + if C <= B: + C *= 2 + cnt += 1 + +if ans: + print('Yes') +else: + print('No')" +p02753,s621902886,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +s = set(input()) + +if len(s)==1: + print('No') +else: + print('Yes') +" +p02584,s482594952,Accepted,"x, k, d = map(int, input().split()) +x = abs(x) + +if x >= k*d: + ans = x - k*d +elif k&1: + ans = min((x-d)%(2*d), 2*d - (x-d)%(2*d) ) +else: + ans = min(x%(2*d), 2*d - x%(2*d)) + +print(ans)" +p03779,s658680757,Wrong Answer,"#ABC056 + +x = int(input()) + +for i in range(10 ** 4): + if i * (i - 1) // 2 < x <= i * (i + 1) // 2: + print(i) + break" +p02712,s427703482,Accepted,"N = int(input()) + +sum = 0 +for i in range(1, N+1): + if i % 3 != 0 and i % 5 != 0: + sum += i +print(sum)" +p02608,s014093046,Wrong Answer,"import sys +import math +import statistics +import itertools +from collections import deque +N=int(input()) + +ans_lis =[0]*10000000 + + +nn=math.sqrt(N) +n=int(nn) +#per_lis=itertools.permutations(list(range(1,4))) +for i in range(1,n+1): + for j in range(1,n+1): + for k in range(1,n+1): + tmp=0 + tmp=i**2+j**2+k**2+i*j+j*k+k*i + ans_lis[tmp-1]+=1 +for g in range(n): + print(ans_lis[g])" +p02696,s860487827,Wrong Answer,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +def f(x, a, b): + return ((a*x)//b) - (a*(x//b)) + +def main(): + a, b, n = map(int, readline().split()) + print(min(f(n, a, b), f(b-1, a, b))) +if __name__ == '__main__': + main() +" +p02577,s427547535,Accepted,"n = list(map(int,input())) +if sum(n)%9==0: + print('Yes') +else: + print('No') +" +p02912,s522121139,Wrong Answer,"N,M=map(int,input().split()) +*A,=map(int,input().split()) +A=sorted(A)[::-1] + +i=0 +while M: + A[i]//=2 + M-=1 + if A[i] 0 else ""No"")" +p02795,s527220184,Accepted,"from math import ceil +H = int(input()) +W = int(input()) +N = int(input()) + +print(ceil(N/(max(H, W)))) +" +p02790,s751602448,Wrong Answer,"a,b=(int(x) for x in input().split()) + +if a>b: + for i in range(b): + print(a,end='') +else: + for i in range(a): + print(b,end='') + +print()" +p04033,s921689246,Accepted,"a,b = map(int,input().split()) + +if a > 0: + print(""Positive"") +elif (a <= 0 and b >= 0): + print(""Zero"") +else: + if (b - a) % 2 == 0: + print(""Negative"") + else: + print(""Positive"")" +p02795,s658113305,Wrong Answer,"h = int(input()) +w = int(input()) +n = int(input()) +a = max(h, w) +if n % a == 0: + print(n//a) +else: + print((n//1 + 1))" +p02621,s560740043,Wrong Answer,"a = int(input()) +print(a+a**a+a**a*a)" +p02818,s565130216,Accepted,"a, b, k = map(int, input().split()) +if k <= a: + print(a-k, b) +elif k - a <= b: + print(0, b-(k-a)) +else: + print(0, 0)" +p02983,s758836743,Accepted,"L,R=map(int,input().split()) + +if R(l*r)%2019: + ans=(l*r)%2019 + if ans==0: + break +print(ans)" +p02629,s333169505,Accepted,"def main(): + N = int(input()) - 1 + digit = 1 + while N >= 26 ** digit: + N -= 26 ** digit + digit += 1 + buf = [] + a = ord(""a"") + for i in range(digit): + buf.append(chr(a + (N % 26))) + N //= 26 + ans = """".join(buf[::-1]) + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03998,s231460818,Accepted,"#! /usr/bin/env python3 + +from fractions import gcd +# from math import gcd +from collections import Counter, deque, defaultdict +from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge +from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort +from itertools import accumulate, product, permutations, combinations, combinations_with_replacement + +A = input() +B = input() +C = input() + +ABC = {""a"":deque(A), ""b"":deque(B), ""c"":deque(C)} +ABC_H = {""a"":""A"", ""b"":""B"", ""c"":""C""} + +ind = A[0] +while True: + + if len(ABC[ind]) == 0: + break + ind = ABC[ind].popleft() + +print(ABC_H[ind]) +" +p02595,s185012880,Accepted,"#200802B +import math +N, D = map(int, input().split()) + +count = 0 +for i in range(N): + X, Y = map(int, input().split()) + Dxy = math.sqrt(X**2 + Y**2) + if Dxy <= D: + count += 1 +print(count)" +p02860,s804343346,Accepted,"input() +s=input() +half=int(len(s)/2) +print(""Yes"" if s[:half]==s[half:] else ""No"")" +p02819,s775074594,Wrong Answer,"x = int(input()) + +while True: + if x % 2 == 0: + x += 1 + continue + i = 2 + while i * i <= x: + if x % i == 0: + break + i += 1 + else: + print(x) + exit() + x += 1 +" +p02768,s856519551,Accepted,"import sys +input = sys.stdin.readline +ins = lambda: input().strip() +inn = lambda: int(input()) +inl = lambda: list(map(int, input().split())) +mod = 10**9 + 7 + +n, a, b = inl() + +def comb(n, k): + p, q = 1, 1 + for i in range(1, k+1): + p = p * (n-i+1) % mod + q = q * i % mod + return p * pow(q, mod-2, mod) % mod + +sum_comb = pow(2, n, mod) - 1 +sum_comb -= comb(n, a) +sum_comb -= comb(n, b) + +print(sum_comb % mod) +" +p02963,s627997508,Accepted,"import math + +s = int(input()) + +rot = int(math.sqrt(s) // 1) +if s == rot**2: + print(""0 0 "" + str(rot) + "" 0 0 "" + str(rot)) + exit() + +rot += 1 +ans = (rot**2) - s +print(""0 0 "" + str(rot) + "" 1 "" + str(ans) + "" "" + str(rot)) +" +p02924,s911049557,Accepted,"N = int(input()) +print(N*(N-1)//2)" +p02994,s021231057,Accepted,"n, l = map(int, input().split()) + +p = [0]*n +for i in range(n): + p[i] = l + (i + 1) - 1 + +s = p[0] +for i in p: + if abs(i) < abs(s): + s = i + +print(sum(p) - s)" +p03698,s220980019,Accepted,"import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +s = input().strip() +a = set() +for i in s: + if i in a: + print('no') + sys.exit() + a.add(i) +print('yes') +" +p02899,s156538752,Accepted,"N = int(input()) +A = list(map(int, input().split())) +y = sorted([(i+1, A[i]) for i in range(N)], key=lambda x: x[1]) +print("" "".join(map(str, [z[0] for z in y]))) +" +p04034,s361624671,Accepted,"N, M = map(int, input().split()) + +l = [0] * (N + 1) +l[1] = 1 +c = [1] * (N + 1) + +for _ in range(M): + x, y = map(int, input().split()) + if l[x] == 1: + l[y] = 1 + if c[x] == 1: + l[x] = 0 + c[x] -= 1 + c[y] += 1 + +print(sum(l)) +" +p03434,s608774089,Wrong Answer,"n = int(input()) +a = input().split() + +a = list(map(int, a)) + +alice_n = a[::2] +bob_n = a[1::2] + +print(sum(alice_n) - sum(bob_n))" +p03493,s466944138,Accepted,"din =input() +out = 0 +for ind in range(len(din)): + out = out + int(din[ind]) +print(out)" +p03360,s680475044,Wrong Answer,"a, b, c = map(int, input().split()) +k = int(input()) + +m = max(a, b, c) +print(sum([a, b, c])-m+m*2*k) +" +p02601,s914806954,Accepted,"a, b, c = map(int, input().split()) +k = int(input()) + +for cnt in range(k): + if a < b and b < c: + break + elif a >= b: + b = int(b * 2) + continue + elif b >= c: + c = int(c * 2) + continue + +if a < b < c: + print('Yes') +else: + print('No') +" +p02711,s948773896,Accepted,"print('Yes' if '7' in input() else 'No') +" +p02880,s899593568,Wrong Answer,"N=int(input()) + +flag=0 +for i in range(1,10): + for j in range(1,10): + if N==i*j: + print('Yes') + flag=1 + break + +if flag==0: + print('No')" +p02766,s647010371,Accepted,"from math import log10 +n,k=map(int,input().split()) +m=int(log10(n)/log10(k)) +print(m+1)" +p02618,s081713563,Wrong Answer,"import numpy as np + +a = np.arange(365) + +np.random.shuffle(a) + +print(*a, sep='\n')" +p02959,s127672522,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +count = 0 +last = 0#前のBの余力 +for i in range(N): + at = min(A[i] - last, B[i]) + if at < 0: + at = 0 + if at == 0: + count += A[i] + else: + count += at + last + last = B[i] - at + +if A[-1]-last > 0: + count += A[-1]-last +else: + count += A[-1] +print(count)" +p03860,s704290082,Wrong Answer,print(input().split()[1][0]) +p02811,s916055551,Wrong Answer,"k, x = map(int, input().split()) +if 500*k >= x: + print(""Yes"") +else: + print(""NO"")" +p02552,s915472580,Wrong Answer,"x = int(input()) +if x == 1: + print(1) +else: + print(0)" +p02697,s764294146,Accepted,"n,m=map(int,input().split()) +l=[] +if n%2==0: + i=1 + while i=x: + r=m + else: + l=m + + print(r) + +if __name__==""__main__"": + main()" +p04029,s957251808,Accepted,"N=int(input()) +s=0 +for i in range(0,N+1): + s=s+i +print(s)" +p02570,s978507113,Accepted,"d, t, s = map(int, input().split()) + +time = d / s +ans = ""Yes"" + +if time > t: + ans = ""No"" + +print(ans)" +p02760,s252778657,Wrong Answer,"A=[] +A+=list(map(int, input().split())) +A+=list(map(int, input().split())) +A+=list(map(int, input().split())) +N=int(input()) + +b=[] +for _ in range(N): + b.append(int(input())) + +find=set() +for num in b: + if num in A: + find.add(A.index(num)) +BINGO=[{0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 4, 8}, {2, 4, 6}] +for tri in BINGO: + if tri < find: + print('Yes') + break +else: + print('No')" +p03760,s805200504,Accepted,"import itertools +a=[i for i in input()] +b=[i for i in input()] +l=list(itertools.zip_longest(a,b,fillvalue=0)) +ll=[] +for i in l: + if i[0]!=0: + ll.append(i[0]) + if i[1]!=0: + ll.append(i[1]) +print("""".join(ll)) + + " +p04034,s046029578,Accepted,"(N, M), *AB = [map(int, s.split()) for s in open(0)] +cnt = [1] * N +possibly_red = [False] * N +possibly_red[0] = True +for a, b in AB: + a -= 1 + b -= 1 + cnt[a] -= 1 + cnt[b] += 1 + if possibly_red[a]: + possibly_red[b] = True + if cnt[a] == 0: + possibly_red[a] = False +print(sum(possibly_red)) +" +p03487,s424681711,Accepted,"from collections import Counter + +n = int(input()) +A = list(map(int, input().split())) +c = Counter(A) +print(sum(v - k if k <= v else v for k, v in c.items())) +" +p02582,s709871829,Accepted,"s = input() + +if s == 'RSR': + print(1) + exit() + +ans = 0 + +for i in s: + if i == 'R': + ans += 1 + +print(ans) +" +p02888,s299351579,Accepted,"import itertools + +n = int(input()) +A = list(map(int,input().split())) +A.sort() + +def binary_search(l,r,v): + while r >= l: + h = (l+r) // 2 + if A[h] < v: + l = h+1 + else: + r = h-1 + return r + +ans = 0 +for i in range(n-2): + for j in range(i+1,n-1): + a = binary_search(j,n-1,A[i]+A[j]) + ans += a-j + +print(ans)" +p02772,s058293964,Accepted,"n_num = int(input()) +nums = map(int, input().split()) + +for num in nums: + if num % 2 == 0: + if num % 3 != 0 and num % 5 != 0: + print('DENIED') + break +else: + print('APPROVED') +" +p02695,s360179027,Wrong Answer,"import itertools + +n, m, q = map(int, input().split()) +abcd = [] +a_pre = [] + + +for i in range(q): + abcd.append(list(map(int, input().split()))) + +lis = [i for i in range(1,m+1)] +for pair in itertools.combinations(lis, n): + a_pre.append(list(pair)) + +sum = 0 +for i in range(len(a_pre)): + sum_pre = 0 + for j in range(len(abcd)): + if (a_pre[i][abcd[j][1] - 1] - a_pre[i][abcd[j][0] - 1]) == abcd[j][2]: + sum_pre += abcd[j][3] + if sum_pre > sum: + sum = sum_pre + +print(sum)" +p03145,s639078666,Accepted,"ab, bc, ca = map(int, input().split()) +print(ab * bc // 2)" +p03281,s356858391,Accepted,"N = int(input()) +count = 0 +if 105 <= N <= 106: + count = 1 +elif N < 105: + count = 0 +else: + count = 1 + for i in range(107, N + 1, 2): + prime_count = 0 + for j in range(1, int(i ** (1/2)) + 1): + if i % j == 0: + prime_count += 1 + if i / j != j: + prime_count += 1 + if prime_count == 8: + count += 1 +print(count)" +p02726,s662716742,Accepted,"N, X, Y = map(int, input().split()) +from itertools import combinations +cmb = combinations(range(1, N+1), 2) +k = [0] * (N-1) +for i, j in cmb: + distance = min(j-i, abs(X-i) + abs(Y-j) + 1) + k[distance-1] += 1 +for i in k: + print(i)" +p02711,s658029874,Accepted,"n = list(input()) + +if '7' in n: + print('Yes') +else: + print('No')" +p03328,s883458650,Accepted,"a,b = map(int, input().split()) + +M = sum(range(b-a)) + +print(M - a)" +p02988,s922136008,Accepted,"import sys +sys.setrecursionlimit(10**6) + +n = int(input()) +p = list(map(int, input().split())) + +ans = 0 + +for i in range(1, n-1): + if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]: + ans += 1 + +print(ans)" +p03352,s780095055,Accepted,"import math +X = int(input()) +maxv = [1] + +for i in range(1,32): + for j in range(2,11): + if i**j > X: + if j != 2: + maxv.append(i**(j-1)) + break + +print(max(maxv))" +p02628,s154143563,Wrong Answer,"N,K = map(int,input().split()) +P = list(map(int,input().split())) + +res = 10**16 +for i in range(N-K+1): + res = min(res, sum(P[i:i+K])) + +print(res)" +p02801,s016822351,Wrong Answer,"a = ord(input())+1 +print(a) +" +p02897,s418162025,Accepted,"n=int(input()) +print(((n+1)//2)/n)" +p02548,s501632109,Accepted,"def num_divisors_table(n): + table = [0] * (n + 1) + + for i in range(1,n+1): + for j in range(i,n+1,i): + table[j] += 1 + return table +def resolve(): + n = int(input()) + print(sum(num_divisors_table((n)-1))) +resolve()" +p02747,s242715385,Wrong Answer,"S = input() + +if S.count('h') == S.count('i') and S.count('i') == S.count('hi'): + print('Yes') +else: + print('No') +" +p03131,s486663348,Wrong Answer,"K,A,B=map(int,input().split()) +bis=1 +if A>=B-1: + bis=K+1 +else: + if K-(A-1)%2==0: + bis=A+(B-A)*(K-(A-1))/2 + else: + bis=A+(B-A)*((K-(A-1))//2)+1 +print(bis)" +p02612,s887326730,Accepted,"n = int(input()) +if 0<= n <=1000: + print(1000- n) +elif 1000< n <=2000: + print(2000- n) +elif 2000< n <=3000: + print(3000- n) +elif 3000< n <=4000: + print(4000- n) +elif 4000< n <=5000: + print(5000- n) +elif 5000< n <=6000: + print(6000- n) +elif 6000< n <=7000: + print(7000- n) +elif 7000< n <=8000: + print(8000- n) +elif 8000< n <=9000: + print(9000- n) +elif 1000< n <=10000: + print(10000- n)" +p04005,s708061826,Accepted,"A, B, C = map(int, input().split()) + +if A%2 == 0 or B%2 == 0 or C%2 == 0: + print(0) +else: + print(min(A*B, A*C, B*C))" +p03827,s851691783,Accepted,"n = int(input()) +s = input() +ans = 0 +tmp = [0] +for ss in s: + if ss == ""I"": + ans += 1 + tmp.append(ans) + else: + ans -= 1 + tmp.append(ans) +print(max(tmp))" +p03136,s931794781,Accepted,"N=int(input()) +AA=list(map(int,input().split())) +Lmax=0 +for i in range(N): + Lmax = max(Lmax,AA[i]) +print(""Yes"" if Lmax<(sum(AA)-Lmax) else ""No"")" +p02646,s758378617,Accepted,"A,V=map(int,input().split()) +B,W=map(int,input().split()) +T=int(input()) + +if A 0: + print(0, b-(k-a)) + else: + print(0, 0) +else: + print(a-k, b)" +p02793,s531353827,Accepted,"import sys +import fractions + +sys.setrecursionlimit(10000000) +input=sys.stdin.readline + +n = int(input()) +a = list(map(int,input().split())) + +def gcd(a, b): + return a if b == 0 else gcd(b, a%b) + +def lcm(a, b): + return a // fractions.gcd(a, b) * b + +mod = 10**9+7 + +x=a[0] + +for i in a[1:]: + x=lcm(x,i) +ans=0 +for i in range(n): + ans+= x//a[i] + +print(ans%mod) +" +p03524,s684955282,Accepted," +def myAnswer(S:str)-> str: + #len(S)が2の時種類数が1以外ならOK + dic = {""a"":0,""b"":0,""c"":0} + for s in S: + dic[s]+= 1 + # print(dic) + dic2 = sorted(dic.values(),reverse = True) + sub = dic2[0] - dic2[1] + dic2[1] - dic2[2] + # print(dic2) + if(sub >=2): + return ""NO"" + else: + return ""YES"" +def modelAnswer(): + return +def main(): + S = (input()) + print(myAnswer(S)) +if __name__ == '__main__': + main() + + +" +p02797,s584065626,Accepted,"n, k, s = map(int, input().split()) + +if s == 10**9: + for _ in range(k): + print(s, end="" "") + for j in range(n-k): + print(10**9-1, end="" "") +else: + for _ in range(k): + print(s, end="" "") + for j in range(n-k): + print(10**9, end="" "") +" +p02742,s525686676,Accepted,"h, w = map(int,input().split()) +if h == 1 or w == 1: + print(1) + exit() +else: + print((h * w + 1) // 2)" +p03073,s223734604,Accepted,"s = input() +s_length = len(s) + +keep = '01' * 100000 +keep_1 = keep[:s_length] +keep_2 = keep[1:s_length + 1] + + +ans_1 = 0 +ans_2 = 0 +for i in range(s_length): + if s[i] != keep_1[i]: + ans_1 += 1 + else: + ans_2 += 1 +print(min(ans_1, ans_2)) +" +p03962,s574444335,Accepted,"a,b,c = sorted(list(map(int,input().split()))) +if a == c: + print(""1"") +elif a == b or b == c: + print(""2"") +else: + print(""3"") + +" +p03145,s030225336,Wrong Answer,"a, b, c = map(int, input().split(' ')) +print(a*b/2)" +p02596,s670804957,Accepted,"#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def main(): + K = int(input()) + + mod = 7 + ans = 1 + for i in range(K): + if mod % K == 0: + print(ans) + exit() + mod = (mod * 10 + 7) % K + ans += 1 + print(-1) + + +if __name__ == ""__main__"": + main() +" +p02909,s861948481,Accepted,"s = input() +if s == 'Sunny': + print('Cloudy') +elif s == 'Cloudy': + print('Rainy') +else: + print('Sunny')" +p03387,s935794056,Accepted,"data = sorted([int(i) for i in input().split()]) +print((data[2] * 2 - data[0] - data[1])//2) if data[0] % 2 == data[1] % 2 else print(((data[2] + 1) * 2 - data[0] - data[1] - 1)//2 + 1) +" +p03456,s153473777,Wrong Answer,"import math +ab = int(input().replace(' ', '')) +ab_sqrt = math.sqrt(ab) +print('Yes' if int(ab_sqrt ** 2) == ab else 'No')" +p02959,s292812715,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +ans = 0 +for i in range(N): + if A[i] >= B[i]: + ans += B[i] + else: + ans += A[i] + B[i] -= A[i] + if A[i + 1] >= B[i]: + ans += B[i] + A[i + 1] -= B[i] + else: + ans += A[i + 1] +print(ans) +" +p03555,s218346332,Wrong Answer,"a = list(input()) +b = list(input()) + + +if a == list(reversed(b)): + print(""Yes"") +else: + print(""No"")" +p02707,s419703018,Wrong Answer,"count = int(input()) + +data = list(map(int,input().split())) + +total = 0 +for i in range(count): + a = data.count(i + 1) + total += a + print(a) + if total == count - 1: + print(""0\n"" * (count - i)) + break" +p02801,s985142495,Accepted,"c = input() +nextc = chr(ord(c) + 1) +print(nextc) +" +p03041,s259798853,Accepted,"d={'A':'a','B':'b','C':'c'} +N,K=map(int,input().split()) +S=input() +print(S[:K-1]+d[S[K-1]]+S[K:])" +p02578,s011223033,Accepted,"if __name__ == '__main__': + + n = int(input()) + + A = list(map(int,input().split())) + + top = A[0] + ans = 0 + for i in range(n-1): + if top > A[i+1]: + ans += top - A[i+1] + else: + top = A[i+1] + print(ans)" +p02578,s979972434,Accepted,"N = int (input ()) +A = [int (x) for x in input().split()] +X = A[0] +P = 0 +for i in range (N-1): + if A[i+1] < X: + P += X-A[i+1] + elif A[i+1] > X: + X = A[i+1] +print (P)" +p02823,s689735105,Wrong Answer,"n, a, b = map(int, input().split()) +result = 0 +if (b - a)%2 == 1: + temp1 = b - 1 + temp2 = n - a + if temp1 < temp2: + result = temp1 + else: + result = temp2 +else: + result = (b - a) // 2 +print(result) +" +p02690,s520449123,Accepted,"x = int(input()) +for i in range(-1000, 1000): + for j in range(-1000, 1000): + if i**5 - j**5 == x: + print(str(i) + "" "" + str(j)) + exit()" +p02742,s383919653,Accepted,"#!/usr/bin/env python3 + +import math +from decimal import * + +def main(): + h,w = map(int, input().split()) + if h == 1: + print(1) + exit() + elif w ==1: + print(1) + exit() + else: + print(math.ceil(h*w/2)) + +if __name__ == '__main__': + main()" +p03474,s463392532,Accepted,"a,b = map(int,input().split()) +s = list(input()) +print(""Yes"" if s.count(""-"")==1 and s[a]==""-"" else ""No"")" +p02554,s555207949,Accepted,"N = int(input()) +A = 1 +B = 2 +C = 1 +mod = 10**9+7 +for i in range(N): + A *= 10 + A %= mod + B *= 9 + B %= mod + C *= 8 + C %= mod +ans = (A-B+C)%mod +print(ans)" +p03773,s177650660,Accepted,"a,b=map(int,input().split()) +print((a+b)%24)" +p02817,s152119099,Accepted,"s, t = input().split() + +print(t + s)" +p03293,s368974044,Accepted,print('Yes' if input() in input() * 2 else 'No') +p03472,s747376132,Wrong Answer,"from math import ceil +N,H=map(int,input().split()) +AB=[list(map(int,input().split())) for i in range(N)] +sw=max(AB[i][0] for i in range(N)) +cnt=0 +dam=0 +for i in range(N): + if AB[i][1]>=sw: + cnt+=1 + dam+=AB[i][1] + if(dam>=H): + print(cnt) + exit() +cnt+=ceil((H-dam)/sw) +print(cnt)" +p02759,s179233195,Accepted,"n = int(input()) +print(-((-n)//2))" +p03611,s584132084,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +ans = 0 +for i in range(min(a), max(a)): + tmp = a.count(i) + a.count(i-1) + a.count(i+1) + if ans < tmp: + ans = tmp +if n > 1: + print(ans) +else: + print(1)" +p02790,s203900989,Wrong Answer,"a, b = input().split() +list = [a*int(b), b*int(a)] +sorted(list) +print(list[0]) +" +p02678,s082824065,Accepted,"from collections import deque + +n,m = map(int,input().split()) +tree = [[] for _ in range(n)] + +for i in range(m): + a,b = map(int, input().split()) + tree[a-1].append(b-1) + tree[b-1].append(a-1) + +depth = [-1] * n +prev = [-1] * n + +q = deque([0]) +depth[0] = 0 + +while len(q) > 0: + pos = q.popleft() + for i in tree[pos]: + if depth[i] == -1: + depth[i] = depth[pos] + 1 + prev[i] = pos + q.append(i) + +print('Yes') +for i in range(1,n): + ans = prev[i] + 1 + print(ans)" +p02640,s469398750,Accepted,"import sys + +def II(): return int(input()) +def MI(): return map(int,input().split()) +def LI(): return list(map(int,input().split())) +def TI(): return tuple(map(int,input().split())) +def RN(N): return [input().strip() for i in range(N)] + + +def main(): + X, Y = MI() + + + if (Y%2 == 0) and (2*X<=Y) and (Y <= 4*X): + print(""Yes"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main()" +p03494,s861680416,Wrong Answer,"n = int(input()) +l = list(map(int, input().split())) + +def hoge(x): + for i in range(10): + if x % 2 == 0: + x = x//2 + else: + break + return i + +print(min([hoge(x) for x in l]))" +p02603,s554936681,Accepted,"N, *A = map(int, open(0).read().split()) + +s = 0 +m = 1000 +for i in range(N): + m += s * A[i] + s = 0 + if i+1 < N and A[i] < A[i+1]: + s = m // A[i] + m -= s * A[i] + +print(m)" +p02743,s031178433,Wrong Answer,"from collections import * +from itertools import * +from bisect import * +from heapq import * +import copy +import math +from fractions import gcd +import sys +#input = sys.stdin.readline + + +#N=int(input()) + +#A=list(map(int,input().split())) +#XY=[list(map(int,input().split())) for i in range(N)] + +a,b,c=map(int,input().split()) +X=gcd(gcd(a,b),c) +c//=X +a//=X +b//=X +if c**.5-a**.5-b**.5>0.1: + print(""Yes"") +else: + print(""No"") +" +p04030,s947825865,Accepted,"S = input() +ans = [] +for s in S: + if s == 'B' and ans: + ans.pop() + elif s != 'B': + ans.append(s) + +print(''.join(ans))" +p02601,s397215694,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) + +n = 0 + +while A >= B : + B *= 2 + n += 1 + +while B >= C : + C *= 2 + n += 1 + +if n <= K : + print(""Yes"") +else : + print(""No"")" +p02768,s211778576,Accepted,"from functools import reduce +# input +dev = pow(10, 9) + 7 +n, a, b = map( int, input().split() ) + +# calc +def nCr( n, r ): + x = reduce( lambda a, b: a*b%dev, range(n, n-r, -1) ) + y = reduce( lambda a, b: a*b%dev, range(1, r+1, 1) ) + # mod gyakugen + y = pow( y, dev-2, dev) + return x * y % dev +ans = pow(2, n, dev) - 1 - nCr(n,a) - nCr(n,b) +ans %= dev + +# out +print(ans)" +p02835,s875881555,Accepted,"# coding: utf-8 +# Your code here! + +A1, A2, A3 = map(int, input().split()) + +if A1 + A2 + A3 <= 21 : + print('win') +else : + print('bust')" +p03250,s073572585,Accepted,"import sys +import math +import numpy as np +import copy + +def main(): + a, b, c = map(int, input().split()) + x = sorted([a, b, c]) + print(10*x[2]+x[1]+x[0]) + + return 0 + +if __name__ == '__main__': + sys.exit(main())" +p03069,s021854653,Wrong Answer,"n=int(input()) +s=input() + +i=0 +for ss in s: + if ss==""#"": + break + i+=1 + +s=s[i:] +if s=="""": + print(0) + exit() + + +while s[-1]==""#"": + s=s[:-1] + if s=="""": + print(0) + exit() + +print(min(s.count("".""),s.count(""#""))) + + +" +p02748,s131545315,Wrong Answer,"#B - Nice Shopping +A,B,M = map(int,input().split()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +X = [] +Y = [] +C = [] +for i in range(M): + x,y,c = map(int,input().split()) + X.append(x) + Y.append(y) + C.append(c) + +#割引券を使う場合 +best_M_idx = C.index(max(C)) +pay_M = a[X[best_M_idx]-1] + b[Y[best_M_idx]-1]-max(C) +#使わない場合 +D = [i + j for i,j in zip(a,b)] +pay = min(D) +print(min(pay,pay_M))" +p03852,s091559604,Wrong Answer,"n = input() +List = ['aiueo'] +if 'n' in List: + print('vowel') +else: + print('consonant') +" +p02784,s541231288,Accepted,"H, N = map(int, input().split()) +A = list(map(int, input().split())) + +if sum(A)>=H: + print('Yes') +else: + print('No')" +p02793,s300933475,Accepted,"from fractions import gcd +from functools import reduce +def lcm(x, y): + return (x * y) // gcd(x, y) +def ll(numbers): + return reduce(lcm, numbers, 1) +def modinv(a): + return pow(a,m-2,m) +n=int(input()) +a=list(map(int,input().split())) +l=ll(a) +x=0 +m=10**9+7 +lm=l%m +for i in range(n): + x+=(lm*modinv(a[i]))%m + x=x%m +print(x)" +p02623,s904640539,Accepted,"import bisect + +n, m, k = map(int, input().split()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +ra = [0] * (n + 1) +rb = [0] * (m + 1) +for i in range(n): + ra[i + 1] = a[i] + ra[i] + +for j in range(m): + rb[j + 1] = b[j] + rb[j] + +ans = 0 +for i in range(n + 1): + zan = k - ra[i] + if zan < 0: + break + rbi = bisect.bisect_right(rb, zan) - 1 + if rbi < 0: + rbi = 0 + ans = max(ans, i + rbi) +print(ans) +" +p03331,s106256400,Accepted,"n=input() +if int(n)%10==0: + print(10) +else: + print(sum(map(int,list(n))))" +p03042,s864958000,Accepted,"s=str(input()) +a=s[:2] +b=s[-2:] +m=['01','02','03','04','05','06','07','08','09','10','11','12'] +if a not in m and b in m: + print('YYMM') +elif a in m and b not in m: + print('MMYY') +elif a in m and b in m: + print('AMBIGUOUS') +else: + print('NA') + " +p02766,s786564600,Wrong Answer,"# -*- coding: utf-8 -*- +import math + +n, k = map(int, input().split()) +result = math.log(n, k) +print(math.ceil(result))" +p03146,s334047554,Wrong Answer,"s = int(input()) + +def f(n): + if n%2 == 0: + return n/2 + else: + return 3*n+1 + +memo = {i: 0 for i in range(1, 999999)} + +a = s +i = 1 + +while(True): + if memo[f(a)]: + i += 1 + break + + a = f(a) + memo[a] = 1 + i += 1 + +print(i)" +p03774,s360118216,Wrong Answer,"n, m = map(int, input().split()) + +abl = [] +for _ in range(n): + ab = list(map(int, input().split())) + abl.append(ab) + +cdl = [] +for _ in range(m): + cd = list(map(int, input().split())) + cdl.append(cd) + +ansl = [0 for _ in range(n)] +for i, ab in enumerate(abl): + ans = 10**8 + for j, cd in enumerate(cdl): + if abs(ab[0]-cd[0]) + abs(ab[1]-cd[1]) < ans: + ansl[i] = j + ans = abs(ab[0]-cd[0]) + abs(ab[1]-cd[1]) + +for ans in ansl: + print(ans+1) +" +p03328,s277897952,Accepted,"a,b=map(int,input().split()) +temp=b-a +k=0 +for i in range(temp): + k=k+i +print(k-a)" +p02705,s086487281,Wrong Answer,"import math +a = int(input()) +b = a*math.pi +print(b)" +p02570,s683925731,Accepted,"d = 0 +t = 0 +s = 0 + +d, t, s = map(int, input().split()) +if s*t >= d: + print(""Yes"") +else: + print(""No"")" +p02785,s069575719,Accepted,"N, K = map(int, input().split()) +H = list(map(int, input().split())) +H.sort(reverse=True) +ans = 0 + +for i in range(N): + if i + 1 <= K: + continue + ans = ans + H[i] + +print(ans) +" +p02996,s066112654,Accepted,"n = int(input()) +ab = [list(map(int, input().split())) for _ in range(n)] +ab.sort(key = lambda x:x[1]) + +c = sum([i for i,j in ab]) +abmax = max([j for i,j in ab]) + +ab.reverse() +ans = ""Yes"" +x = c + 0 +for i,j in ab: + if not x <= j: + ans = ""No"" + break + x -= i + +print(ans)" +p02777,s805437649,Accepted,"S,T = input().split() +A,B = map(int,input().split()) +U = input() +if S == U: + print(A-1,B) +else: + print(A,B-1) + " +p03795,s868311815,Accepted,"n = int(input()) +print(800*n - n//15 * 200)" +p02697,s900893925,Accepted,"n, m = map(int, input().split()) +i = 0 +c = 0 +while (i + 1) + i < (n - i - (i + 1)) and c < m: + print(i + 1, n - i) + c += 1 + i += 1 +a = n // 2 + n % 2 +for i in range(m - c): + print(a - i - 1, a + i + 1)" +p02696,s238095460,Wrong Answer,"a, b, n = map(int, input().split()) +n = n - 1 +print(int((a * n) / b) - a * int(n / b))" +p02607,s617862091,Accepted,"n = int(input()) +l = list(map(int, input().split())) +ans = 0 +for i in range(n): + if i % 2 == 0 and l[i] % 2 == 1: + ans += 1 +print(ans)" +p02881,s224049619,Accepted,"n = int(input()) +save = 1 +for i in range(int(n**(1/2)), 1, -1): + if n % i == 0: + save = i + break +print(int(save+n/save - 2)) +" +p02582,s981309091,Accepted,"#!/usr/bin/env python3 +s = input() +if s == ""RRR"": + print(3) +elif s== ""RRS"" or s==""SRR"": + print(2) +elif s == ""SSS"": + print(0) +else: + print(1) +" +p03998,s023416354,Accepted,"lis=[] +ll=[""a"",""b"",""c""] +for i in range(3): + lis.append(list(input())) +turn=0 +while 1: + if lis[turn]==[]: + print(ll[turn].upper()) + break + turn=ll.index(lis[turn].pop(0)) +" +p02629,s516386469,Accepted,"N=int(input()) +ans="""" +while N>0: + tmp=(N-1)%26 + ans=chr(int(tmp)+97)+ans + N=int((N-tmp)/26) +print(ans)" +p02995,s169677190,Wrong Answer,"import fractions + +a,b,c,d = map(int, input().split("" "")) +gcd = fractions.gcd(c, d) +lcm = c * d / gcd +bwari = b - ((int)(b/c) + (int)(b/d) - (int)(b/(lcm))) +awari = (a - 1)- ((int)((a-1)/c) + (int)((a-1)/d) - (int)((a-1)/(lcm))) +print(bwari - awari)" +p03095,s893428849,Accepted,"#!/usr/bin/env python3 +from collections import* +MOD = 10**9+7 +input();i = 1 +for c in Counter(input()).values():i *= c+1 +print(~-i % MOD)" +p02842,s983396068,Accepted,"import math + +n = int(input()) +X = math.ceil(n / 1.08) + +if math.floor(X * 1.08) == n: + print(X) +else: + print("":("")" +p02911,s201366997,Accepted,"N,K,Q = map(int,input().split()) +points = [0]*N + +for i in range(Q): + anchor = (int(input()))-1 + points[anchor] += 1 + +for i in range(N): + if K - (Q - points[i]) >0: + print(""Yes"") + else: + print(""No"")" +p02783,s770302134,Wrong Answer,"H, A = map(int, input().split()) + +print(H // A + 1)" +p03338,s443016300,Accepted,"import collections +n=int(input()) +s=input() +ans=0 +for i in range(1,n-1): + l=list(set(s[:i]) & set(s[i:])) + c = collections.Counter(l) + ans=max(ans,len(c.keys())) +print(ans)" +p02570,s352982700,Accepted,"D,T,S=map(int,input().split()) +if D/S<=T: + print(""Yes"") +else: + print(""No"")" +p03434,s248350390,Wrong Answer,"n=int(input()) +a = list(map(int,input().split()))[:n] +a.sort(reverse=True) + +A=B=I=0 +for i in a: + if I %2:B+=i + else:A+=i + I+=1 + +print(a) +# other +# print(sum(a[::2]) - sum(a[1::2])) +" +p04019,s739473956,Accepted,"s=input() +print('No' if 'N' in s and 'S' not in s or 'S' in s and 'N' not in s or 'W' in s and 'E' not in s or 'E' in s and 'W' not in s else 'Yes')" +p02970,s495846658,Accepted,"# B - Golden Apple + +n, d = map(int, input().split()) +print((n+2*d)//(2*d+1))" +p03210,s995491411,Accepted,"x = input() + +if x in ""753"": + print(""YES"") +else: + print(""NO"")" +p02963,s348417731,Accepted,"from math import* +def fact_p(n): + m=n + i=2 + a=0 + while n>1: + if i>m**.5: + a=n + break + while n%i==0: + n//=i + a=i + i+=1 + return a +n=int(input()) +x2=y1=ceil(n**.5+.5) if ceil(n**.5+.5)<=10**9 else 10**9 +x1=fact_p(x2*y1-n) +y2=(x2*y1-n)//x1 if x1 else 0 +print(0,0,x1,y1,x2,y2)" +p02765,s301275890,Accepted,"N, R = map(int, input().split()) +if N >= 10: + print(R) +else: + print((R + 100 * (10 - N))) +" +p02719,s288797285,Wrong Answer,"n, k = list(map(int, input().split())) +x = n % k +print(min(x, x-k))" +p04033,s747684486,Accepted,"a,b = map(int,input().split()) + +if a <= 0 and b >= 0: + print(""Zero"") +elif a > 0: + print(""Positive"") +else: + l = b-a+1 + if l%2 == 0: + print(""Positive"") + else: + print(""Negative"")" +p04012,s131308266,Accepted,"word = input() +wset = set(word) +a = 'Yes' +for w in wset: + if word.count(w) % 2 != 0: + a = 'No' +print(a)" +p02582,s684961054,Accepted,"print(max(map(len,input().split(""S""))))" +p03289,s653541262,Accepted,"s=input() + +n = len(s) + +countC = 0 + +alf = [chr(ord('a') + i) for i in range(26)] + +for i in range(n): + #print(i) + if i == 0 and s[i] != 'A': + print('WA') + exit() + elif i == 0 and s[i] == 'A': + continue + elif s[i] == 'C' and 1 < i and i < n-1: + countC += 1 + elif s[i] in alf: + continue + else: + print('WA') + exit() + +if countC == 1: + print('AC') +else: + print('WA')" +p03481,s173134779,Wrong Answer,"from math import log2 + +X,Y = [int(i) for i in input().split()] + +print(int(log2(Y/X))+1) +" +p03797,s477643756,Wrong Answer,"n,m = map(int,input().split()) +if m < 2*n: + print(n//2) +else: + m -= 2*n + print(n+(m//4))" +p03261,s854616396,Wrong Answer,"N = int(input()) +out = ""Yes"" +S = input() +L = [] + +L.append(S) +for i in range(N-1): + T = input() + if T in L: + out = ""No"" + if T[0]!=S[-1]: + out = ""No"" + S = T +print(out) +" +p04005,s524352727,Accepted,"A, B, C = map(int, input().split()) +if (A * B * C) % 2 == 0: + ans = 0 + print(ans) +else: + ans = float('inf') + V = A*B*C + AB = A*B + BC = B*C + CA = C*A + ans = min(ans, abs((A//2)*BC - ((A//2) + 1)*BC)) + ans = min(ans, abs((B//2)*CA - ((B//2) + 1)*CA)) + ans = min(ans, abs((C//2)*AB - ((C//2) + 1)*AB)) + print(ans) +" +p04029,s254868498,Accepted,"n = int(input()) +print((1+n)*n//2)" +p03472,s665617732,Accepted,"N, H = map(int, input().split()) +A = [0]*N +B = [0]*N +for i in range(N): + A[i],B[i] = map(int, input().split()) + +a = max(A) +B.sort() +cnt = 0 +for b in B[::-1]: + if b>a: + H -= b + cnt += 1 + if H<=0: + break +if H>0: + cnt += (H+a-1)//a + + +print(cnt)" +p02792,s108174432,Accepted,"N = int(input()) +C = {(i,j):0 for i in range(1,10) for j in range(1,10)} +num = list(range(1,10)) +for k in range(1,N+1): + k = str(k) + i = int(k[0]) + j = int(k[-1]) + if i in num and j in num: + C[(i,j)] += 1 +cnt = 0 +for i in range(1,10): + for j in range(1,10): + cnt += C[(i,j)]*C[(j,i)] +print(cnt)" +p02848,s050920174,Accepted,"N = int(input()) +S = input() +ans = """" +for s in S: + ans += chr((ord(s) + N-65)%26 + 65) +print(ans)" +p02640,s313861176,Accepted,"x, y = map(int, input().split()) + +for t in range(0, 101): + c = x - t + if t*4+c*2 == y and c >= 0: + print('Yes') + exit() + +print('No')" +p03323,s735231564,Wrong Answer,"a, b = [int(i) for i in input().split()] + +print(""Yay!"" if a <= b <= 8 else "":("") +" +p02971,s585131513,Accepted,"n=int(input()) +a=[int(input()) for _ in range(n)] +s=sorted(a) +maxi=max(a) +maxi2=s[-2] +for i in a: + if i == maxi: + print(maxi2) + else: + print(maxi)" +p03548,s631680556,Accepted,"import sys +import itertools +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +import math +import collections + +x,y,z = map(int,input().split()) +x-= 2*z +ans = x//(y+z) +if x%(y+z)>=y: + ans += 1 +print(ans)" +p02646,s703387715,Accepted," +def main(): + A, V = map(int,input().split(' ')) + B, W = map(int,input().split(' ')) + T = int(input()) + + if A > B: + if A-(V*T) <= B-(W*T): + print('YES') + else: + print('NO') + else: + if A+V*T >= B+W*T: + print('YES') + else: + print('NO') + + + +if __name__ == ""__main__"": + main() +" +p03219,s997171480,Accepted,"a,b=map(int,input().split()) +print(a+b//2)" +p03043,s866112274,Accepted,"N, K = map(int, input().split()) + +ans = 0 +cnt = 0 + +for n in range(1, N+1): + c = 0 + while True: + total = n * 2 ** c + if total >= K: + ans += 0.5 ** c / N + break + c += 1 + +print(ans) +" +p02817,s622658312,Accepted,"a,b = input().split() +print(b+a) +" +p02862,s139359611,Accepted,"def nCr(n, r, mod): + x, y = 1, 1 + for r_ in range(1, r+1): + x = x*(n+1-r_)%mod + y = y*r_%mod + return x*pow(y, mod-2, mod)%mod + +x, y = map(int, input().split()) +mod = 10**9+7 +if (x+y)%3 or 2*x n: + print(-1) +else: + print(n - s) +" +p02948,s912811141,Accepted,"import heapq + +N, M = map(int, input().split()) +work = [[] for _ in range(M)] +for _ in range(N): + a, b = map(int, input().split()) + if a <= M: + work[a-1].append(b) +ans = 0 +q = [] +heapq.heapify(q) +for i in range(M): + for x in work[i]: + heapq.heappush(q, -x) + if q != []: + ans += heapq.heappop(q)*(-1) +print (ans)" +p02777,s850708123,Accepted,"ST = input().split() +S = ST[0] +T = ST[1] + +AB = input().split() +A = int(AB[0]) +B = int(AB[1]) + +U = input() + +if S == U: + print(A-1,B) +else: + print(A,B-1)" +p03617,s720676018,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) * 4 +A = [Q, min(2 * Q, H), min(4 * Q, 2 * H, S), min(8 * Q, 4 * H, 2 * S, D)] +ans = (N // 8) * A[3] + ((N % 8) // 4) * A[2] + ((N % 4) // 2) * A[1] + (N % 2) * A[0] +print(ans)" +p02748,s925170775,Wrong Answer,"A, B, M = [int(i) for i in input().split("" "")] + +a = [int(i) for i in input().split("" "")] +b = [int(i) for i in input().split("" "")] +C = [] + +for i in range(M): + c = [int(i) for i in input().split("" "")] + C.append(c) + +print(a) + +m = 1000000 + +for i in a: + for j in b: + cost = i + j + if m >= cost: + m = cost + +for c in C: + cost = a[c[0] - 1] + b[c[1] - 1] - c[2] + if m >= cost: + m = cost + +print(m)" +p02630,s536123075,Accepted,"N = int(input()) +A = [int(x) for x in input().split()] + +cnt = [0 for _ in range(10**5 + 5)] +for a in A: + cnt[a] += 1 + +ans = sum(A) + +Q = int(input()) + +for _ in range(Q): + B, C = map(int, input().split()) + + ans -= B * cnt[B] + ans += C * cnt[B] + + cnt[C] += cnt[B] + cnt[B] = 0 + + print(ans) +" +p03544,s892335801,Accepted,"#47 +N = int(input()) +l0,l1 = 2,1 +l2 = l1 +for i in range(N-1): + l2 = l0 + l1 + l0 = l1 + l1 = l2 + +print(l1)" +p02801,s095547895,Wrong Answer,"N = input() + +M = ord('N')+1 + +J = chr(M) + +print(J) +" +p02595,s182135047,Wrong Answer,"N,D=list(map(int,input().split())) +count=0 +for i in range(N): + x,y=list(map(int,input().split())) + if((x**2 + y**2)<=D): + count+=1 +print(count) +" +p02630,s010279445,Wrong Answer,"ni = lambda: int(input()) +nm = lambda: map(int, input().split()) +nl = lambda: list(map(int, input().split())) + +n=ni() +a=nl() +nums = [0]*10**6 +for i in range(n): + nums[a[i]]+=1 +q=ni() +ans=0 +for i in range(len(nums)): + ans+=nums[i]*i + +for i in range(q): + b,c=nm() + ans-=nums[b]*b + ans+=nums[c]*c + nums[c]+=nums[b] + nums[b]=0 + print(ans) +" +p03438,s597076961,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +sa=sum(a) +sb=sum(b) +if sblen(e): + ans+=o[len(o)-1] +print(ans)" +p03720,s015259667,Accepted,"n,m = map(int,input().split()) +path = [[] for _ in range(n)] +for _ in range(m): + a,b = map(int,input().split()) + path[a-1].append(b-1) + path[b-1].append(a-1) +for p in path: + print(len(p))" +p02612,s332303570,Wrong Answer,"N = int(input()) +print(1000-N%1000)" +p03624,s939784842,Accepted,"s = input() +da = 'abcdefghijklmnopqrstuvwxyz' +flag = True +for i in da: + for j in s: + if j == i: + flag = False + if flag: + print(i) + flag = False + break + else: + flag = True +if flag: + print('None') +" +p02555,s317659277,Accepted,"def resolve(): + base = 10**9+7 + S = int(input()) + dp = [0] * (S+1) + dp[0] = 1 + + for i in range(1, S+1): + for u in range(i-2): + dp[i] += dp[u] + dp[i] %= base + # print(dp) + print(dp[S]%base) + +if __name__ == ""__main__"": + resolve() +" +p04012,s919556868,Accepted,"w = input() +L = list(w) + +cnt = 0 +for i in L: + if L.count(i) % 2 == 1: + cnt += 1 + break +print('Yes' if cnt == 0 else 'No')" +p02761,s781528522,Accepted,"n, m = map(int, input().split()) +lis = [list(map(int, input().split())) for _ in range(m)] +ans = -1 +if n == 1: + i = 0 +else: + i = 10**(n-1) +while (ans == -1) & (i < 10**n): + s = 0 + for j in lis: + if str(i)[j[0]-1] == str(j[1]): + s += 1 + else: + s += 0 + if s == m: + ans = i + else: + i += 1 +print(ans)" +p02819,s138066362,Wrong Answer,"import math +x = int(input().split()[0]) +def get_sieve_of_eratosthenes(n): + prime = [] + limit = math.sqrt(n) + data = [i + 1 for i in range(1, n)] + while True: + p = data[0] + if limit <= p: + return prime + data + prime.append(p) + data = [e for e in data if e % p != 0] + +data = get_sieve_of_eratosthenes(2*x+100) +for i in data: + if i > x: + print(i) + break + + " +p03377,s500779329,Accepted," +a, b, x = map(int, input().split()) + +print(""NO"" if a > x or a + b < x else ""YES"")" +p03665,s253460887,Accepted,"N, P = map(int, input().split()) +A = list(map(int, input().split())) +B = [a % 2 for a in A] +count_0 = B.count(0) +count_1 = B.count(1) + +if count_1 == 0: + if P == 0: + ans = 2 ** N + else: + ans = 0 +else: + ans = 2 ** (N - 1) +print(ans) +" +p02731,s412562315,Accepted,"L=float(input()) + +print('{:.08f}'.format((L/3)**3))" +p02789,s425020226,Wrong Answer,"N, M = list(map(int, input().split())) +if N == M: + print(""yes"") +else: + print(""no"") +" +p02712,s439629450,Accepted,"a = int(input()) + +ans = 0 +for i in range(a+1): + if i % 3 != 0 and i % 5 != 0: + ans += i + +print(ans) +" +p03017,s378075895,Wrong Answer,"N,A,B,C,D = map(int,input().split()) +S = input() + +goal = max(C,D) +if '##' in S[A-1:goal]: + print(""No"") + exit() + +ok = True +# 追い越す必要がある +if D < C: + # 間に3マスあきがない or (.D.)でない + if not ('...' in S[B-1:D]): + ok = False + +# 必要がない場合は問題ない + +if ok: + print(""Yes"") +else: + print(""No"") + +" +p03705,s632382505,Wrong Answer,"N,A,B=map(int,input().split()) + +nin=A*(N-1)+B +nax=A+B*(N-1) + +if N==1 or A>B: + print(0) + exit() +print(nax-nin+1)" +p03852,s742883910,Accepted,"c = str(input()) +print(""vowel"" if c in ""aiueo"" else ""consonant"")" +p03962,s272640645,Wrong Answer,"x, y, z = map(int, input().split()) +count = 1 +if x != y: + count += 1 +if x != z: + count += 1 +print(count) +" +p02873,s279676853,Accepted,"S = input() +n = len(S) + 1 +num = [0] * n +for i in range(n-1): + if S[i] == '<': + num[i + 1] = max(num[i] + 1, num[i + 1]) +for i in range(n - 2, -1, -1): + if S[i] == '>': + num[i] = max(num[i + 1] + 1, num[i]) +print(sum(num))" +p02847,s524877683,Wrong Answer,"#!/usr/bion/env python3 + +S = input() + +ans = 0 + +if S == ""SUN"": + ans = 6 +if S == ""MON"": + ans = 5 +if S == ""TUE"": + ans = 4 +if S == ""WED"": + ans = 3 +if S == ""FRI"": + ans = 2 +if S == ""SAT"": + ans = 1 + + +print(ans) +" +p02801,s739071700,Accepted,"import string +C = input() + +al = string.ascii_lowercase +for i in range(len(al)): + if al[i] == C: + print(al[i+1]) + break" +p02948,s196226766,Accepted,"import heapq +n,m=map(int,input().split()) +w=[[] for i in range(m)] +for i in range(n): + a,b=map(int,input().split()) + a-=1 + if a>=m: + continue + w[a].append(-b) + +h=[] +c=0 +for i in range(m): + for j in w[i]: + heapq.heappush(h,j) + try: + c+=heapq.heappop(h) + except: + pass +print(-c)" +p02996,s003159938,Wrong Answer,"N=int(input()) +A=[] +B=[] +for i in range (N): + A.append(list(map(int,input().split()))) +for i in range (N): + B.append(A[i][1]) +C=sorted(A,key=lambda A: A[1]) +tmp=0 +count=0 +for i in range (N): + tmp+=C[i][0] + if tmp<=C[i][1]: + count+=1 + else: + print(""No"") +if count==N: + print(""Yes"")" +p03759,s470222990,Wrong Answer,"a,b,c = map(int,input().split()) + +if a-b == c-b: + print('YES') +else: + print('NO')" +p02718,s068779877,Accepted,"import math +N, M = map(int, input().split()) +A = list(map(int, input().split())) +c = 0 +t = math.ceil(sum(A)/(4*M)) + +for i in A: + if i >= t: + c += 1 +if c >= M: + print(""Yes"") +else: + print(""No"")" +p03433,s278341891,Accepted,"n,a=map(int,open(0)) +print('YNeos'[n%500>a::2])" +p02708,s087290476,Wrong Answer,"N,K = map(int, input().split()) +ans = 0 +for i in range(K,N+1): + ans += (N*i - i**2 + i +1)%(10**9 +7) +print(ans%(10**9 +7)) +" +p03417,s252881464,Accepted,"n, m = map(int, input().split()) + +ans = 0 +if n > m: + n, m = m, n +if n==1: + if m==1: + ans = 1 + else: + ans = m-2 +else: + ans = (n-2)*(m-2) + +print(ans)" +p02657,s170443261,Accepted,"A, B = map(int, input().split()) +print(A*B)" +p02817,s224964747,Accepted,"s, t = input().split() +print(""{}{}"".format(t, s))" +p03251,s033824794,Wrong Answer,"n,m,X,Y = map(int,input().split()) +x = list(map(int,input().split())) +y = list(map(int,input().split())) + +xmax = max(x) +ymin = min(y) + +for i in range(xmax,ymin+1): + if X0 else 0)" +p03971,s182062030,Accepted,"n,a,b=map(int,input().split()) +s=input() +x=0 +y=0 +for i in range(n): + if s[i]==""a"": + if y=D: + print('Yes') +else: + print('No')" +p02972,s428911788,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +ans = [0 for _ in range(n)] +for i in reversed(range(n)): + tmp = 0 + for j in range((i+1)*2-1,n,i+1): + if ans[j] == 1: + tmp += 1 + if a[i] == 0 and tmp % 2 == 1: + ans[i] = 1 + elif a[i] == 1 and tmp % 2 == 0: + ans[i] = 1 + +c = 0 +l = [] +for i in range(n): + if ans[i] == 1: + l.append(i+1) + c += 1 +if c == 0: + print(0) +else: + l = [str(i) for i in l] + l = "" "".join(l) + print(c) + print(l) +" +p02832,s131737566,Accepted,"N = int(input()) +alist = list(map(int, input().split())) + +cnt = 1 +ans = 0 +for a in alist: + if a != cnt: + ans += 1 + else: + cnt += 1 + +if ans==N: + print(-1) +else: + print(ans) +" +p03607,s913476695,Accepted,"n = int(input()) +d = {} +for i in range(n): + a = int(input()) + d[a] = d.get(a, 0) + 1 + +c = 0 +for e in d.values(): + if e % 2 == 1: + c += 1 +print(c)" +p02897,s322067512,Wrong Answer,"N = int(input()) + +if N % 2 == 0: + print(""1"") +else: + a = N // 2 + 1 + print(a/N)" +p03639,s745611009,Accepted," +n = int(input()) + +a = list(map(int, input().split())) + +can4 = 0 +even = 0 +odd = 0 + +for i in a: + if i % 4 == 0: + can4 += 1 + elif i % 2 == 0: + even += 1 + else: + odd += 1 + +if even == 0 and odd == can4 + 1: + print(""Yes"") +elif odd > can4: + print(""No"") +else: + print(""Yes"")" +p02603,s427998443,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +dp = [0]*(n+1) +dp[0] = 1000 + +for i in range(1, n): + dp[i] = dp[i-1] + for j in range(i): + stock = dp[j]//a[j] + cost = dp[j]+(a[i]-a[j])*stock + dp[i] = max(dp[i], cost) +print(dp[n-1]) +" +p02923,s962411324,Accepted,"n = int(input()) +h = list(map(int, input().split())) +max_cnt, cnt = 0, 0 +for i in range(n - 1): + if h[i] >= h[i + 1]: + cnt += 1 + else: + cnt = 0 + max_cnt = max(max_cnt, cnt) +print(max_cnt)" +p02598,s442912454,Accepted,"n,k=map(int,input().split()) +a=list(map(int,input().split())) +l=0;r=10**10 +while r-l>1: + x=(l+r)//2 + ct=0 + for i in range(n): + ct+=(a[i]-1)//x + if ct<=k: + r=x + else: + l=x +print(r)" +p02911,s289735858,Accepted,"n, k, q = map(int, input().split()) +tokuten = [k-q]*n + +for i in range(q): + a = int(input()) + tokuten[a-1] += 1 + + +for i in range(n): + if tokuten[i] <= 0: + print(""No"") + else: + print(""Yes"")" +p02911,s064984619,Wrong Answer,"n,k,q = map(int,input().split()) +a = [] +for _ in range(q): + a.append(int(input())) +# +point_get = [0] * n +for i in range(q): + point_get[a[i]-1] += 1 +# +print(point_get) +for j in range(n): + if k - q + point_get[j] >= 1: + print('Yes') + else: + print('No') +" +p02727,s678434347,Accepted,"import sys +sys.setrecursionlimit(4100000) + +x,y,a,b,c = map(int,input().split()) +p = sorted(list(map(int,input().split()))) +q = sorted(list(map(int,input().split()))) +r = list(map(int,input().split())) +ans = 0 + +for k in range(1,x+1): + r.append(p[-k]) +for v in range(1,y+1): + r.append(q[-v]) + +rs = sorted(r) + +for i in range(1,x+y+1): + ans += rs[-i] +print(str(ans))" +p02765,s402174806,Accepted,"# -*- coding: utf-8 -*- +n, r = map(int, input().split()) +if n >= 10: + print(r) +else: + print(r+100*(10-n))" +p02946,s870271013,Wrong Answer,"K,X=map(int,input().split()) +nums=[i for i in range(-100,101) if X-(K-1)<= i <=X+(K-1)] + +ans=str("""") +for n in nums: + ans+=str(n)+"" "" +print(ans) +" +p02645,s573571327,Accepted,"s = input() +result = s[0:3] +print(result)" +p02742,s876804749,Accepted,"def resolve(): + from math import ceil + h, w = map(int, input().split()) + if h <= 1 or w <= 1: + print(1) + elif h * w % 2 == 0: + print(int(h * w / 2)) + else: + print(int(ceil(h * w / 2))) + + +resolve()" +p02725,s933708006,Accepted,"k, n = map(int, input().split()) +a = list(map(int, input().split())) + +mx = (k - a[n - 1]) + a[0] + +for i in range(n - 1): + sa = a[i + 1] - a[i] + if sa > mx: + mx = sa + +print(k - mx)" +p03345,s579019358,Accepted,"A, B, C, K = map(int, input().split()) +if K%2 == 0: + print(A-B) if abs(A-B)<=10**18 else print(""Unfair"") +else: + print(B-A) if abs(B-A)<=10**18 else print(""Unfair"")" +p02572,s672498669,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +z = 0 +for i in range(n): + z += a[i] + +y = (z % 1000000007)** 2 + +x = 0 +for j in range(n): + x += a[j] ** 2 + +p = ((y - x) / 2) % 1000000007 +print(int(p))" +p03351,s267795632,Wrong Answer,"a,b,c,d=map(int,input().split());print(""NYoe s""[((abs(b-a)<=d and abs(c-b)<=d) or (c-a)<=d)::2])" +p02570,s982662875,Accepted,"D,T,S = list(map(int,input().split())) + +if D / S <= T: + print('Yes') +else: + print('No')" +p03785,s066163386,Accepted,"def answer(n, c, k, ts): + ts.sort() + bus = 1 + _c = 1 + standard = ts[0] + for i in range(1, len(ts)): + if ts[i] <= standard+k and _c < c: + _c += 1 + else: + _c = 1 + standard = ts[i] + bus += 1 + return bus + +n, c, k = map(int, input().split()) +ts = [] +for _ in range(n): + ts.append(int(input())) +print(answer(n, c, k, ts))" +p02912,s761155184,Accepted,"import heapq + +n, m = map(int, input().split()) +s = list(map(lambda x: x* (-1), map(int, input().split()))) + +heapq.heapify(s) + +while m != 0: + num = heapq.heappop(s) + heapq.heappush(s, -1*num//2*-1) + m -= 1 + +print(-1 * sum(s)) + +" +p03043,s888199517,Wrong Answer,"N,K = map(int,input().split()) +ans = 0 +for i in range(1,N+1): + j = 0 + point = i + while point < K: + point *= 2 + j += 1 + ans += (1/N)*(0.5**j) +print(point)" +p02819,s730128786,Accepted,"X = int(input())-1 +result = False + +while not result: + result = True + X += 1 + for i in range(2,X//2+1): + if X % i == 0: + result = False + break +print(X)" +p02882,s211202685,Wrong Answer,"import math + +a, b, x = map(int, input().split()) + +if 2*x <= a*a*b: + y = 2 * x / (a * b) + print(math.degrees(math.atan(y/b))) +else: + y = 2 * x / (a * a) + print(math.degrees(math.atan(a/y))) +" +p02917,s248054183,Wrong Answer,"n=int(input()) +b=list(map(int,input().split())) +ans=0 +for i in range(n-2): + ans+=min(b[i],b[i]+1) +print(ans+b[0]+b[-1])" +p02732,s652098433,Accepted,"N=int(input()) +*A,=map(int,input().split()) +from collections import* +C=Counter(A) +S=sum(v*(v-1)//2 for v in C.values()) +for a in A: + print(S-C[a]+1)" +p02732,s354364679,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +num = [0] * n +cnt = 0 + +for i in a: + num[i - 1] += 1 + +for i in num: + cnt += i * (i - 1)//2 + +for i in range(n): + tmp = num[a[i]-1] + ans = cnt - ((tmp-(tmp-2)) * (tmp-1) // 2) + ans += ((tmp-2) * (tmp-1) // 2) + print(ans) +" +p02714,s978533994,Wrong Answer,"n=int(input()) +s=list(input()) +a=s.count(""R"") +b=s.count(""G"") +c=s.count(""B"") +print(a*b*c) +ans=0 +for i in range(n-2): + for j in range(i+1,n-1): + k=2*j-i + if n-1>=k and not(s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): + ans=ans+1 +print(a*b*c-ans) +" +p04033,s715657270,Wrong Answer,"A,B = map(int,input().split()) +if A == 0 or B == 0: + print(""Zero"") + exit() +if A * B < 0: + print(""Zero"") + exit() +if A > 0 and B > 0: + print(""Positive"") +else: + print(""Negative"")" +p03252,s587621708,Accepted,"s=input() +t=input() +n=len(s) +f=0 +a=[[] for i in range(26)] +for i in range(n): + + if len(a[ord(s[i])-97])==0: + a[ord(s[i])-97].append(t[i]) + else: + if a[ord(s[i])-97][0]!=t[i]: + f=1 +x=[a[i][0] for i in range(26) if len(a[i])==1] +if len(x)!=len(set(x)): + f=1 +print(""Yes"" if f==0 else ""No"") + + +" +p02732,s550494533,Wrong Answer,"from collections import Counter +N = int(input()) +A = list(map(int, input().split())) +B = Counter(A) + +tmp = 0 +for i in range(N): + tmp += B[i]*(B[i]-1)//2 + +for k in range(N): + print(tmp-B[A[k]]+1)" +p02730,s176217108,Accepted,"s=input() + +n = len(s) +count = 0 + +before = int((n-1)/2) +after = int((n+1)/2) + +if s[:before] != s[after:]: + count += 1 + +if count == 0: + print('Yes') +else: + print('No')" +p02777,s974898380,Wrong Answer,"a = input().split() +c, d = map(int, input().split()) +e = input() + +if (e == a): c -= 1 +else: d -= 1 + +print(""{}"" ""{}"" ""{}"".format(c,"" "",d)) +" +p03408,s362060678,Accepted,"from collections import defaultdict +d = defaultdict(int) +d[""D""]=0 + +n=int(input()) +for _ in range(n): + d[input()]+=1 + +n=int(input()) +for _ in range(n): + d[input()]-=1 + +print(max(d.values()))" +p03262,s045559442,Wrong Answer,"n,x = map(int,input().split()) +a = list(map(int,input().split())) +res,ans = [],0 +for i in range(n): + res.append(abs(a[i]-x)) +#print(min(res)) +res.sort() +ans = res[0] +cnt = 0 +if n > 1: + num = min((n-1),11) + for j in range(2,num): + cmp = a[0]%res[0]*j + for s in range(n): + if a[s]%res[0]*j != cmp: + break + else: + cnt += 1 + if cnt == n: + ans = res[0]*j +print(ans)" +p03061,s126954395,Accepted,"from fractions import gcd +n =int(input()) +a =list(map(int ,input().split())) + +b =[a[0]] +for i in range(1,n-1): + b.append(gcd(b[-1],a[i])) + +c =[a[-1]] +for i in range(n-2,0,-1): + c.append(gcd(c[-1], a[i])) + +MAX =0 +for i in range(n): + if i == 0: + MAX =max(MAX, c[-1]) + elif i ==n-1: + MAX =max(MAX, b[-1]) + else: + MAX =max(MAX, gcd(b[i-1], c[n-i-2])) +print(MAX)" +p02717,s210023805,Accepted,"Y, Z, X =map(int, input().split()) +print(X,Y,Z)" +p02917,s489472002,Wrong Answer,"n = int(input()) +B = list(map(int, input().split())) + +asum = B[-1] +before_b = B[0] +for i in range(1, n-1): + asum += min(B[i], before_b) + before_b = B[i] + +if n == 2: + asum += B[-1] + +print(asum) +" +p03478,s652886690,Accepted,"if __name__ == '__main__': + a = [int(i) for i in input().split()] + count = 0 + for i in range(1,a[0]+1): + s = str(i) + sumN = 0 + for j in s: + sumN += int(j) + + if a[1] <= sumN and a[2] >= sumN: + count+=i + print(count)" +p02641,s271077530,Accepted,"X, N = list(map(int, input().split())) +if N > 0: + P = list(map(int, input().split())) + l = X + h = X + while True: + if l not in P: + print(l) + break + if h not in P: + print(h) + break + l -= 1 + h += 1 +else: + input() + print(X)" +p03239,s255261224,Wrong Answer,"N, T = map(int, input().split()) +List = [] +List2 = [] +min = 1000 + +for i in range(N): + M, B = map(int, input().split()) + List.append([M,B]) + M, B = 0, 0 + +for k in range(N): + if int(List[k][1]) <= T: + List2.append(List[k]) + +for n in range(len(List2)): + if List2[n][0] <= min: + min = List[n][0] + +if min == 1001: + print('TLE') +else: + print(min)" +p02933,s605037853,Accepted,"a=int(input()) +s=input() +if a>=3200: + print(s) +else: + print(""red"")" +p02768,s130701126,Wrong Answer,"from functools import reduce +MOD = 10**9 + 7 + + +def cmb(N, A): + num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1)) + den = reduce(lambda x, y: x * y % MOD, range(1, A + 1)) + return num * pow(den, MOD - 2, MOD) % MOD + + +n, a, b = map(int, input().split()) +a %= MOD +b %= MOD + + +print((pow(2, n, MOD) - cmb(n, a) - cmb(n, b)) % MOD)" +p03994,s188225277,Accepted,"s = input() +k = int(input()) +n = len(s) + +S = list(s) + +import string +A = [chr(i) for i in range(ord(""a""), ord(""z"")+1)] +B = {} +for i in range(26): + B[A[i]] = i + +for i in range(n): + if S[i] != ""a"" and 26 - B[S[i]] <= k: + k -= 26 - B[S[i]] + S[i] = ""a"" + +# print(k) +if k > 0: + S[-1] = A[(B[S[-1]] + k) % 26] + +# print(S) + +print("""".join(S))" +p03449,s417418177,Accepted,"N = int(input()) +A1 = list(map(int,input().split())) +A2 = list(map(int,input().split())) + +wa1 = [0]*N +wa2 = [0]*N +wa1[0] = A1[0] +wa2[0] = A2[0] +ans = 0 + +for i in range(1,N): + wa1[i] = wa1[i-1]+A1[i] + wa2[i] = wa2[i-1]+A2[i] + +for i in range(N): + if i == 0: + tmp = wa1[i] + wa2[-1] + else: + tmp = wa1[i] + (wa2[-1]-wa2[i-1]) + ans = max(ans,tmp) + +print(ans)" +p03069,s440612766,Accepted,"n=int(input()) +s=list(input()) +b2=s.count(""#"") +w2=s.count(""."") +b1=0 +w1=0 +ans=w2 +for i in range(n): + if s[i]==""#"": + b1+=1 + b2-=1 + else: + w1+=1 + w2-=1 + ans=min(ans,b1+w2) +print(ans) +" +p03680,s270320935,Accepted,"N = int(input()) +a = [int(input()) for _ in range(N)] +log = set() +i = 0 +count = 1 +while a[i] != 2: + i = a[i] - 1 + if i in log: + print(-1) + break + else: + log.add(i) + count += 1 +else: + print(count)" +p03282,s541771468,Wrong Answer,"S = input() +K = int(input()) + +if len(S) == 1: + print(S) + exit() + +answer = S[1] +print(answer) +" +p02959,s707840944,Accepted,"from collections import deque + +N = int(input()) +Monsters = deque(map(int, input().split())) +Fighters = deque(map(int, input().split())) + +Knockouts = 0 +prev_ftr = 0 + +while len(Monsters) > 0: + mon = Monsters.popleft() + ko1 = min(mon, prev_ftr) + #print(mon, prev_ftr, ko1) + Knockouts += ko1 + mon -= ko1 + + if len(Fighters) > 0: + ftr = Fighters.popleft() + ko2 = min(mon, ftr) + #print(mon, ftr, ko2) + Knockouts += ko2 + mon -= ko2 + prev_ftr = ftr - ko2 + +print(Knockouts)" +p03220,s464423755,Accepted,"n = int(input()) +t,a = map(int, input().split()) +h = list(map(int, input().split())) +l = [] +for i in h: + l.append(abs(t-i*0.006 - a)) +print(l.index(min(l))+1)" +p03345,s082257580,Accepted,"A,B,C,K=map(int,input().split()) + +if K%2==0: + print(A-B) +else: + print(B-A)" +p02727,s526457400,Wrong Answer,"import sys +from collections import Counter +input = sys.stdin.readline + +X, Y, A, B, C = map(int, input().split()) +p = list(map(int, input().split())) +q = list(map(int, input().split())) +r = list(map(int, input().split())) + +p.sort() +q.sort() +r.sort() + +p = p[-X:] +q = q[-X:] + +p.extend(q) +p.extend(r) + +p.sort() + +print(sum(p[-(X+Y):]))" +p02761,s762311081,Accepted,"n,m = map(int,input().split()) +s = [0] * m +c = [0] * m +def ret(): + print(0) + return +for i in range(m): + s[i],c[i] = map(int,input().split()) + +def ret1(): + for i in range(0 if n == 1 else 10**(n-1),10**n): + flag = 1 + for j in range(m): + if i//(10**(n-s[j]))%10 != c[j]: + flag = 0 + if flag == 1: + print(i) + return + print(-1) + return + +if m == 1 and n == 1 and c[0] == 0: + ret() +else: + ret1() +" +p03665,s409220845,Accepted,"import sys +sys.setrecursionlimit(10 ** 5 + 10) +def input(): return sys.stdin.readline().strip() + +def resolve(): + + n,p=map(int,input().split()) + A=list(map(int,input().split())) + even=0 + odd=0 + for i in range(n): + if A[i]%2==0: + even+=1 + + odd=n-even + if odd==0: + print(2**n if p==0 else 0) + else: + print((2**even)*2**(odd-1)) + + + +resolve()" +p02639,s963901405,Accepted,"s = input().split() +for i in range(5): + if s[i] == ""0"": + print(i+1)" +p03075,s611888241,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) + +if max(a, b, c, d, e) - min(a, b, c, d, e) > k: + print(':(') +else: + print('Yay!') +" +p02873,s495367242,Wrong Answer,"s = input() +left = 0 +cou = 0 +l = [0 for i in range(len(s)+1)] +for i in range(len(s)): + s1 = s[i] + a1 = l[i] +# print(s1,l,cou) + if s1=='<': + l[i+1] = l[i]+1 + left = 0 + else: + l[i+1] = l[i]-1 + left += 1 + if l[i+1]>=0: + l[i+1] = 0 + left = 0 + else: + l[i+1] =0 + cou += left +print(cou+sum(l)) + " +p02860,s704378735,Accepted,"N=int(input()) +S=input() +if S[:N//2]==S[N//2:]: + print(""Yes"") +else: + print(""No"")" +p03061,s258729784,Accepted,"import math + +N = int(input()) +a = list(input().split()) +A = [int(a[i])for i in range(N)] + +L = [0 for i in range(N+1)] +R = [0 for i in range(N+1)] + +for i in range(N): + L[i+1] = math.gcd(L[i], A[i]) + R[N - (i+1)] = math.gcd(R[N - i], A[N - (i+1)]) + +print(max([math.gcd(L[i], R[i+1]) for i in range(N)]))" +p03281,s983614981,Accepted,"n = int(input()) + +ans = 0 + +for i in range(1,n+1): + yakusu = [] + for j in range(1,i+1): + if i % j == 0: + yakusu.append(i) + if i % 2 == 1 and len(yakusu) == 8: + ans +=1 +print(ans)" +p02951,s972823517,Accepted,"a,b,c = map(int,input().split()) + + +print(max((c - (a - b)),0))" +p02970,s291456346,Wrong Answer,"N, D = [int(i) for i in input().split()] +n = N // D +print((n - (n // 2))) +" +p04043,s009290741,Accepted,"a, b, c = input().split() + +flag = bool + +if a == '5' and b =='7' and c=='5': + flag = True +if a =='7' and b=='5' and c == '5': + flag = True +if a =='5' and b=='5' and c == '7': + flag = True + +if flag == True: + print('YES') +else: + print('NO')" +p02615,s622479297,Accepted,"N = int(input()) +*A, = map(int, input().split()) +aa = A + A +aa.sort(reverse=True) +ans = 0 +for i in range(1, N): + ans += aa[i] +print(ans)" +p03627,s910268595,Wrong Answer,"from collections import defaultdict +N = int(input()) + +A = list(map(int, input().split())) +stick = defaultdict(int) + +for a in A: + stick[a] += 1 + +stick = {key: value for key, value in stick.items() if value >= 2} + + +if len(stick) >= 2: + len1 = max(stick.keys()) + stick.pop(len1) + len2 = max(stick.keys()) + print(len1 * len2) +else: + print(0)" +p02754,s048960647,Accepted,"N, A, B = map(int, input().split()) +tmp = N%(A+B) +if tmp>A: + tmp=A +ans = (N//(A+B))*A + tmp +print(ans)" +p02755,s265071560,Accepted,"def rounder(x): + flt = x - int(x) + if flt>=0.5: + return int(x)+1 + else: + return int(x) + +def main(): + a, b = map(int, input().split()) + A = list(range(rounder(a/0.08), rounder((a+1)/0.08))) + B = list(range(rounder(b/0.10), rounder((b+1)/0.10))) + r = -1 + + for i in range(len(B)): + if B[i] in A: + r = B[i] + break + print(r) + +main()" +p03481,s633843323,Accepted,"X, Y = map(int, input().split()) +ans = 1 +i = X +while i * 2 <= Y: + i *= 2 + ans += 1 +print(ans)" +p03469,s000690460,Accepted,"s = input() +replace_num = '8' +print(s[:3]+replace_num+s[4:])" +p02554,s671688123,Wrong Answer,"N = int(input()) +print((10**N - 9 ** N - 9**N + 8**N) % (10**9 - 7))" +p02582,s326669834,Accepted,"weatherS = input() +p = weatherS[0] == 'R' +q = weatherS[1] == 'R' +r = weatherS[2] == 'R' + +if p and q and r: + serial = 3 +elif (p and q) or (q and r): + serial = 2 +elif p or q or r: + serial = 1 +else: + serial = 0 + +print(serial)" +p02953,s238814090,Accepted,"n = int(input()) +h = list(map(int,input().split())) +ans = 'Yes' +temp = h[0] +for i in range(1,n): + if h[i]>temp: + h[i] -= 1 + elif temp>h[i]: + ans = 'No' + temp = h[i] +print(ans)" +p02572,s179016643,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +if N == 2: + print((A[0]*A[1])%(10**9+7)) +B = [0]*(N-1) +B[N-2] = A[N-1] + +for i in range (3, N+1): + B[N-i]=B[N-i+1]+A[N-i+1] + +count = 0 +for i in range (0, N-1): + count+=(A[i]*B[i]) + +print(count%(10**9+7))" +p02659,s397164824,Accepted,"a,b = map(str,input().split()) +b = b[0] + b[2:] +a,b = int(a),int(b) +print(a*b//100)" +p02791,s793715657,Wrong Answer,"n = int(input()) +p = list(map(int, input().split())) + +ans = 1 + +for i in range(1, n): + if p[i] <= p[i-1]: + ans += 1 + +print(ans)" +p02693,s868969678,Accepted,"import sys +n = int(input()) + +a, b = map(int, input().split()) + +for i in range(a, b+1): + if i % n == 0: + print(""OK"") + sys.exit() +print(""NG"")" +p03136,s421735190,Wrong Answer,"import sys + +INPUT = lambda: sys.stdin.readline().rstrip() +INT = lambda: int(INPUT()) +LIST = lambda: list(map(int, INPUT().split())) + +sys.setrecursionlimit(10 ** 9) + + +def main(): + N = INT() + L = LIST() + + one = L[0] + others = 0 + for i in range(N-1): + if L[i] < L[i+1]: + one = L[i+1] + others += L[i] + else: + others += L[i+1] + + print(""Yes"" if one < others else ""No"") + + +if __name__ == '__main__': + main()" +p03730,s157722530,Accepted,"A,B,C = map(int,input().split()) + +sum = C +ans = 'NO' +cnt = 0 + +while cnt < A: + sum += B + if sum % A == 0: + print('YES') + exit() + cnt += 1 +print('NO')" +p02873,s057186252,Accepted,"s = input() + +cnt = [1] if s[0] == ""<"" else [0, 1] + +bc = s[0] + +for i in range(1, len(s)): + if s[i] == bc: + cnt[-1] += 1 + else: + cnt.append(1) + bc = s[i] + +if len(cnt) % 2 == 1: + cnt.append(0) + + +ans = 0 + +for i in range(0, len(cnt), 2): + ma = max(cnt[i], cnt[i + 1]) + mi = min(cnt[i], cnt[i + 1]) + ans += max(0, ma * (ma + 1) // 2) + ans += max(0, (mi - 1) * mi // 2) + +print(ans) +" +p03324,s919084298,Wrong Answer,"D, N = map(int, input().split()) +print(N * (100**D)) +" +p03632,s117052374,Wrong Answer,"A,B,C,D=map(int,input().split()) + +print(max((B-C)-A,0))" +p02596,s101651647,Accepted,"(K,) = [int(x) for x in input().split()] +ans = 0 +seven = 7 +for i in range(1000000): + if seven % K == 0: + print(i + 1) + break + seven = (10 * seven + 7) % K +else: + print(-1) +" +p03644,s957700947,Wrong Answer,"N=int(input()) +r = 0 +for i in range(6,0,-1): + k = 2**i + if N >= k: + r = k + break +print(r)" +p02838,s440532789,Accepted,"n = int(input()) +a = list(map(int,input().split())) +MOD = 10 ** 9 + 7 +digit = 60 +o=[0]*digit +z=[0]*digit + +for i in a: + for j in range(digit): + if (i >> j) & 1: + o[j] += 1 + else: + z[j] += 1 +ans = 0 +for j in range(digit): + ans += (o[j]*z[j]*pow(2,j,MOD)) +print(ans % MOD)" +p02912,s829147802,Wrong Answer,"from fractions import gcd +from math import ceil,sqrt +a, b = map(int, input().split()) + +g = gcd(a,b) + +s = set() +for i in range(2,ceil(sqrt(g))+1): + while g % i == 0: + g //= i + s.add(i) +if g != 1: + s.add(int(1e14)) +#print(g) +#print(s) +print(len(s)+1)" +p03339,s087726937,Accepted,"N=int(input()) +S=input() +A=[0]*N +A[0]=S[1:].count('E') +for i in range(1,N): + if S[i-1]=='W': + A[i]=A[i-1]+1 + else: + A[i]=A[i-1] + if S[i]=='E': + A[i]-=1 +print(min(A))" +p03730,s811700105,Wrong Answer,"a,b,c=map(int,input().split()) +print(""NO"" if (a%2==1 and c%2==0) or (a%2==0 and c%2==1) else ""YES"")" +p03645,s969691766,Accepted,"N, M = map(int, input().split()) + +s = set() +g = set() + +for _ in range(M): + A, B = map(int, input().split()) + if A == 1: + s.add(B) + if B == N: + g.add(A) + +if s & g: + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"") + +" +p02714,s962137639,Accepted,"n=int(input()) +s=input() +r,g,b=[],[],[] +for i in range(n): + if s[i]=='R': + r+=[i+1] + elif s[i]=='G': + g+=[i+1] + elif s[i]=='B': + b+=[i+1] + +ans=len(r)*len(g)*len(b) + +for i in range(n-2): + for dist in range(1,(n-i+1)//2): + if s[i]!=s[i+dist] and s[i]!=s[i+dist*2] and s[i+dist]!=s[i+dist*2]: + ans-=1 + + +print(ans)" +p02835,s488311799,Accepted,"x = [int(x) for x in input().split()] +if (sum(x)>21): + print('bust') +else: + print('win')" +p04044,s510963412,Accepted,"N,K = map(int,input().split()) +k = [] +ans = """" +for i in range(N): + S = input() + k.append(S) +k.sort() +for i in range(len(k)): + ans += k[i] +print(ans)" +p03804,s243300331,Accepted,"N, M = map(int, input().split()) +A = [input() for i in range(N)] +B = [input() for i in range(M)] +check = 0 + +for i in range(N - M + 1): + for j in range(N - M + 1): + bb = [] + for k in range(M): + bb.append(A[i + k][j:j+M]) + if bb == B: + check = 1 + +if check == 1: + print('Yes') +else: + print('No')" +p02556,s087194906,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10 ** 8) +INF = float('inf') +MOD = 10 ** 9 + 7 + + +def main(): + N = int(readline()) + # A:和、B:差 + A = [0] * N + B = [0] * N + for i in range(N): + x, y = map(int, readline().split()) + A[i] = x+y + B[i] = x-y + + ans = max(max(A)-min(A), max(B)-min(B)) + print(ans) + + +if __name__ == '__main__': + main() +" +p02554,s776525261,Wrong Answer,"n = int(input()) +mod = 10**9 + 7 +print(pow(10,n,mod) - 2*pow(9,n,mod) + pow(8,n,mod))" +p02602,s666894908,Accepted," + + +def m(): + N, K = map(int, input().split()) + A = list(map(int, input().split())) + for i in range(N-K): + left = A[i] + right = A[K+i] + if left < right: + print('Yes') + else: + print('No') + + +m()" +p03986,s089828057,Accepted,"S = input() +s_cnt =0 +t_cnt =0 + +for s in S: + if s == 'S': + s_cnt += 1 + if s == 'T': + t_cnt += 1 + if s_cnt >0: + t_cnt -= 1 + s_cnt -= 1 +print(t_cnt + s_cnt) +" +p03012,s991281651,Accepted,"n=int(input()) +a=[0]*n +a[:]=map(int,input().split()) +s=sum(a) +r=s +for ii in range(n): + q=s-2*sum(a[0:ii+1]) + if r>abs(q): + r=abs(q) +print(r)" +p03449,s322606907,Wrong Answer,"N = int(input()) +A = [list(map(int, input().split())) for i in range(2)] + +res = 0 +for i in range(N): + s = 0 + for j in range(i+1): + s += A[0][j] + print('j:', s) + for k in range(i, N): + s += A[1][k] + print('i:', s) + res = max(res, s) +print(res)" +p02786,s199249879,Accepted,"H = int(input()) +n = -1 +while H !=0 : + n +=1 + H = H//2 + +print(2**(n+1) - 1)" +p03327,s742968181,Accepted,"N=int(input()) +if N >=1000:print('ABD') +else:print('ABC')" +p02552,s372116246,Accepted,"n=int(input()) +print(1-n)" +p02951,s995807277,Accepted,"A, B, C = map(int, input().split()) +print(C-(A-B) if (A-B) < C else 0)" +p03161,s170498215,Accepted,"n,k = map(int,input().split()) +h = list(map(int,input().split())) + +dp = [float(""inf"")]*(n) + +dp[0] = 0 + +def chmin(a,b,index): + if a > b: + dp[index] = b + +for i in range(n-1): + for j in range(1,k+1): + chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]),i+j) + if i+j >= n-1: + break +print(dp[n-1])" +p02640,s433717853,Wrong Answer,"print(""YNeos""[eval(""2*""+input().replace("" "",""-""))%2 > 0::2])" +p02687,s084151069,Accepted,"s = input() + +if s == ""ABC"": + print(""ARC"") +else: + print(""ABC"")" +p03145,s196665785,Accepted,"a,b,c=map(int,input().split()) +print(int(a*b/2))" +p02982,s603520870,Accepted,"N,D = map(int,input().split()) + +a = [list(map(int,input().split())) for _ in range(N)] + +def isSquare(x): + f = 1 + while f * f <= x: + if f * f == x: + return True + else: + f += 1 + return False + +def calcSquareOfDistance(p1,p2,dimension): + s = 0 + for i in range(dimension): + s += (p1[i] - p2[i])**2 + return s + +def judge(p1,p2,dimension): + return isSquare(calcSquareOfDistance(p1,p2,dimension)) + +ans = 0 +for i in range(N-1): + for j in range(i+1,N): + if judge(a[i],a[j],D): + ans += 1 +print(ans)" +p03067,s990450931,Accepted,"a,b,c = map(int,input().split()) +if a < c < b or b < c < a: + print(""Yes"") +else: + print(""No"")" +p02996,s021802678,Wrong Answer,"N = int(input()) +C = {} + +for i in range(N): + a, b = map(int,input().split()) + C[b] = a + +time = 0 +D = sorted(C.items()) + +for i in range(len(D)): + time += D[i][1] + if time > D[i][0]: + print('No') + break +else: + print('Yes') +" +p02606,s800026921,Accepted,"L,R,d = map(int,input().split()) +cnt = 0 + +for i in range(L,R + 1): + if i % d == 0: + cnt += 1 + +print(cnt)" +p03481,s941642737,Wrong Answer,"x,y=map(int,input().split()) +n=1 +while 2**n<=y/x: + n+=1 +print(n)" +p02690,s620360113,Accepted,"x=int(input()) +a=[] +for i in range(220): + a.append(i**5) +for i in range(220): + y=a[i]-x + if y in a: + print(i,a.index(y)) + break + elif -y in a: + print(i,-a.index(-y)) + break" +p02924,s068678478,Accepted,"n=int(input()) +print(n*(n-1)//2)" +p03281,s207321924,Wrong Answer,"def divisor(n): + i = 1 + table = [] + while i * i <= n: + if n % i == 0: + table.append(i) + table.append(n//i) + i += 1 + table = list(set(table)) + return table + +N = int(input()) +total = 0 + +for n in range(1, N + 1, 2): + print(n) + if len(divisor(n)) == 8: + total += 1 + +print(total)" +p02548,s213187616,Accepted,"#約数の個数の和(1~N)約数そのものを求めないので「速い」 +def yakusu_num(N): + ans =0 + for i in range(1,N+1): + ans +=N//i #項数 + return ans + + +# 初期入力 +import sys +input = sys.stdin.readline #文字列では使わない + +N = int(input()) +ans =yakusu_num(N-1) + +print(ans)" +p02916,s722874269,Accepted,"def main(): + n = int(input()) + alis = list(map(int, input().split())) + blis = list(map(int, input().split())) + clis = list(map(int, input().split())) + ans = 0 + tmp = """" + for a in alis: + ans += blis[a-1] + if tmp == a-1: + ans += clis[a-2] + tmp = a + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02948,s815585039,Accepted,"from heapq import * +N,M=map(int,input().split()) +X=[[] for i in range(M)] +A,B=0,0 +for i in range(N): + A,B=map(int,input().split()) + if A>M: + continue + X[-A].append(B) +P=0 +Q=[] +heapify(Q) +for i in range(M-1,-1,-1): + for j in range(len(X[i])): + heappush(Q,-X[i][j]) + if len(Q): + P-=heappop(Q) +print(P)" +p03087,s137378462,Wrong Answer,"N, Q = map(int,input().split()) +S = input() +index = [] +for i in range(N-1): + if S[i] =='A' and S[i+1] == 'C': + index.append(i) + +for _ in range(Q): + l,r = map(int,input().split()) + bottom = -1 + top = -1 + if len(index) != 0: + for i in range(len(index)): + if l <= index[i]+1: + bottom = i + break + for j in range(len(index)): + if index[-(i+1)] < r-1: + top = len(index) -1 -j + break + Answer = 0 + if top >= bottom: + Answer = top - bottom + 1 + print(Answer) + + +" +p03345,s257481424,Wrong Answer,print('Unfair') +p02899,s165143647,Accepted,"N = int(input()) +p_num = list(map(int, input().split())) +ans_list = [0] * N + +for i in range(N): + ans_list[p_num[i] - 1] = i+1 + +for i in range(N): + print(ans_list[i])" +p02664,s528712179,Wrong Answer,"import sys +input = sys.stdin.readline + +s = input() +#print(s.replace(""?"", ""D"")) + + +ans = [] +for i in s: + if i == ""P"": + ans.append(""P"") + else: + ans.append(""D"") +print("""".join(ans)) +" +p02577,s968412687,Accepted,"n=input() +a=len(n) +b=0 +for i in range(a): + b=b+int(n[i]) +if b%9==0: + print(""Yes"") +else: + print(""No"") +" +p02646,s745555212,Wrong Answer,"A_V = input().split() +A = int(A_V[0]) +V = int(A_V[1]) +B_W = input().split() +B = int(B_W[0]) +W = int(B_W[1]) +T = int(input()) + +if W - V <= 0: + print('NO') +elif T < abs(B-A)/(W-V): + print('NO') +else: + print('YES')" +p02713,s731328025,Accepted,"import math +def resolve(): + K = int(input()) + temp = 0 + for i in range(1, K + 1, 1): + for j in range(1, K + 1, 1): + for k in range(1, K + 1, 1): + Result = math.gcd(i, j) + temp += math.gcd(Result, k) + print(temp) + + +resolve()" +p02802,s385726047,Accepted,"N,M = [int(i) for i in input().split()] +submissions = {str(i):[] for i in range(1,N+1)} +AC,WA = 0,0 +for i in range(M): + P,S = [j for j in input().split()] + submissions[P].append(S) +for i in submissions: + if 'AC' not in submissions[i]: + continue + for j in submissions[i]: + if j == 'AC': + AC+=1 + break + WA +=1 +print(AC,WA)" +p03127,s252245481,Accepted,"import fractions +N = int(input()) + +a = list(map(int, input().split())) +ans = a[0] +for i in range(1,N): + ans = fractions.gcd(ans, a[i]) +print(ans)" +p03077,s375987563,Accepted,"from math import ceil +n=int(input()) +A=[int(input()) for _ in range(5)] +print(ceil(n/min(A))+4)" +p03543,s446947197,Accepted,"S = input() + +if S[0] == S[1] == S[2]: + print(""Yes"") +elif S[1] == S[2] == S[3]: + print(""Yes"") +else: + print(""No"")" +p03862,s319759334,Accepted,"n,x=map(int,input().split()) +a=list(map(int,input().split())) +asum=sum(a) + +if a[0]>x: + a[0]=x + +for i in range(n-1): + if a[i]+a[i+1]>x: + a[i+1]=x-a[i] + +asum=asum-sum(a) +print(asum)" +p02832,s378198500,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = 0 +target = 1 +for i in range(n): + if a[i] == target: + target += 1 + else: + ans += 1 + +if target == 1: + print(-1) +else: + print(ans)" +p03494,s931051747,Wrong Answer,"_ = input() +input_list = input().split() +input_list = [int(num) for num in input_list] + +cnt = 0 +while int(sum(input_list) % 2) != 1: + input_list = [num // 2 for num in input_list] + cnt+=1 +print(cnt) +" +p02813,s097920283,Wrong Answer,"import itertools +n=int(input()) +l=list(itertools.permutations(range(1,n+1),n)) + +a=tuple(map(int,input().split())) +b=tuple(map(int,input().split())) +a_index=0 +b_index=0 + +for i in range(len(l)): + if l[i]==a: + a_index=i+1 + elif l[i]==b: + b_index=i+1 + else: + continue + +result=abs(a_index-b_index) +print(result)" +p02744,s082893349,Wrong Answer,"import sys + +N = int(sys.stdin.readline().strip()) +alpha = ""abcdefghij"" + +tmp = [""a""] * N +print("""".join(tmp)) +for i in range(1, N): + for j in range(0, N - i): + tmp[N-j-1] = alpha[i] + print("""".join(tmp))" +p02719,s310003951,Wrong Answer,"n,k = map(int,input().split()) +a = 10**19 +if n >= k: + a=n//k +b=n%k +c=abs(b-k) +l=[n,a,b,c] +print(min(l))" +p02583,s674064494,Accepted,"n = int(input()) +l = list(map(int,input().split())) +import itertools +ans = 0 +for i in itertools.combinations(l, 3): + if abs(i[0]-i[1])=m: + ans=M-m+1 +else: + ans=0 +print(ans)" +p03317,s553238193,Wrong Answer,"# coding: utf-8 + +N, K = map(int,input().split()) +A = list(map(int,input().split())) +for i in range(N): + if A[i] == 1: + cnt = i + break + +a = cnt + 1 +b = N - 1 - i + 1 +#print(a, b) +m1 = a // (K - 1) +n1 = a % (K - 1) + +m2 = b // (K - 1) +n2 = b % (K - 1) +ans = 0 +#print(m1, m2) +ans += m1 + m2 +if n1 > 1: + ans += 1 +if n2 > 1: + ans += 1 +if N <= K: + ans = 1 +if K == 2: + ans = 0 + ans += a - 1 + ans += N - 1 - cnt +print(ans)" +p03804,s979566002,Accepted,"N,M=list(map(int,input().split())) +l=[list(input()) for i in range(N)] +mini=[list(input()) for i in range(M)] +mini="""".join(sum(mini,[])) +for i in range(N-M+1): + for j in range(N-M+1): + let="""" + for k in range(i,M+i): + let+="""".join(l[k][j:j+M]) + if mini == let: + print(""Yes"") + exit() +print(""No"")" +p02835,s731490395,Wrong Answer,"a,b,c=map(int,input().split()) +print(""win"" if a+b+c==21 else ""bust"")" +p02658,s525812592,Accepted,"n=int(input()) + +a=list(map(int,input().split())) + +if 0 in a: + print(0) + exit() + +ans=1 +for aa in a: + ans*=aa + if ans>10**18: + print(-1) + exit() +print(ans) + " +p02602,s067262313,Accepted,"N,K=map(int,input().split()) +A=list(map(int,input().split())) +hyoutei=[0]*(N+1) +for i in range(K,N):#K+1-N + if A[i]/A[i-K]>1: + print(""Yes"") + else: + print(""No"") +" +p03696,s095591814,Wrong Answer,"import sys + +n = int(input()) +a = input() +s = list(a) + +right = 0 +left = 0 + +for i in s: + if s == ""("": + right+=1 + else: + left+=1 + +for _ in range(max(0,left - right)): + sys.stdout.write(""("") +sys.stdout.write(a) +for _ in range(max(0,right - left)): + sys.stdout.write("")"")" +p02718,s971092266,Accepted,"n, m = map(int, input().split()) +list_a = list(map(int, input().split())) + +list_sort = sorted(list_a, reverse = True) + +if list_sort[m-1] >= sum(list_sort)/(4*m): + print('Yes') +else: + print('No')" +p03493,s472891497,Accepted,"L = list(map(int,list(input()))) +print(sum(L))" +p03469,s477692117,Accepted,"s = str(input()) +ans = '2018' + s[4:] +print(ans)" +p02888,s737938655,Accepted,"import numpy as np +from numba import njit + +@njit +def f(A): + N = len(A) + cnt = 0 + for i in range(N): + for j in range(i + 1, N): + for k in range(j + 1, N): + cnt += (A[k] < A[i] + A[j]) + return cnt + +N = int(input()) +A = np.int32(input().split()) +A.sort() +print(f(A)) +" +p03328,s328792494,Accepted,"n=list(map(int, input().split())) +ans=0 +diff=n[1]-n[0] +for i in range(diff): + ans=i+ans +yuki=ans-n[0] +print(yuki)" +p02771,s944896668,Wrong Answer,"a,b,c = map(int, input().split()) + +if a==b or b==c or a==c: + print(""Yes"") +else: + print(""No"")" +p02963,s568469560,Accepted,"S = int(input()) +X1 = (S + 10**9 - 1) // 10**9 +X2 = X1 * 10**9 - S +print(X1, 1, X2, 10**9, '0 0')" +p02701,s140920125,Accepted,"n = int(input()) +s_list = [input() for i in range(n)] +print(len(list(set(s_list)))) +" +p03679,s515755749,Wrong Answer,"x,a,b = list(map(int,input().split())) +if b < a: + print(""delicious"") +elif a < b: + if b-a ary[i]: + kabu += money//ary[i] + money -= kabu*ary[i] + elif ary[i] > ary[i+1]: + money += kabu*ary[i] + kabu = 0 + +print(money+kabu*ary[n-1]) +" +p02959,s243126777,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +ans=0 +for i in range (N): + ans+=min(A[N-i],B[N-1-i]) + if B[N-i-1]>A[N-i]: + ans+=min(A[N-i-1],B[N-1-i]-A[N-i]) + A[N-i-1]-=min(A[N-i-1],B[N-1-i]-A[N-1]) + +print(ans)" +p03745,s641469959,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = 1 +mode = 0 +prev = A[0] + +for i in A: + check = i - prev + + if check == 0: + pass + elif check > 0: + if mode >= 0: + mode = check + else: + ans += 1 + mode = 0 + else: + # check < 0 + if mode <= 0: + mode = check + else: + ans += 1 + mode = 0 + + prev = i + +print(ans) +" +p02900,s486433954,Accepted,"def gcd(a, b): + while b: + a, b = b, a % b + return a + +def prime_decomposition(n): + i = 2 + table = [] + while i * i <= n: + while n % i == 0: + n //= i + table.append(i) + i += 1 + if n > 1: + table.append(n) + return table + +A, B = map(int, input().split()) +l = prime_decomposition(gcd(A, B)) + +print(len(set(l))+1)" +p03557,s019873085,Accepted,"N = int(input()) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) + +A.append(float(""INF"")) +AB = [0] * (N+1) +j = 0 +for i in range(N): + while A[j] < B[i]: + j += 1 + if j == N: + break + AB[i+1] = AB[i] + j + +ans = 0 +B.append(float(""INF"")) +j = 0 +for i in range(N): + while B[j] < C[i]: + j += 1 + if j == N: + break + ans += AB[j] + +print(ans)" +p02598,s320113397,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +l, r = 0, 10 ** 9 +while r - l > 1: + x = (l + r) // 2 + + cnt = 0 + for i in range(n): + if a[i] % x == 0: + cnt += a[i] // x - 1 + else: + cnt += a[i] // x + + if cnt <= k: + r = x + else: + l = x + +print(r) +" +p03077,s220442125,Wrong Answer,"n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +ans = n//min(a,b,c,d,e)+5 +print(ans) +" +p03035,s076345873,Accepted,"import math +import sys +input = sys.stdin.readline +a, b = map(int, input().split()) +if (a < 6): + cost = 0 +elif (a < 13): + cost = b // 2 +else: + cost = b +print(cost) + " +p03163,s063345086,Accepted,"n,w=map(int,input().split()) +dp=[0 for i in range(w+1)] +dp1=dp.copy() +for i in range(1,n+1): + + + + a,b=map(int,input().split()) + + for j in range(1,w+1): + dp1[j]=dp[j] + if(a<=j): + dp1[j]=max(dp1[j],dp[j-a]+b) + + dp=dp1.copy() +print(dp[w]) + + + +" +p02753,s685710768,Accepted,"S=list(input()) + +if len(set(S))==1: + print(""No"") +else: + print(""Yes"")" +p02817,s256447103,Accepted,"s, t = input().split() +print(t + s)" +p02900,s002495179,Accepted,"a,b = [int(x) for x in input().split()] + +def gcd(a,b): + while b: + a,b = b, a%b + return a + +d = gcd(a,b) +pf = {} +for i in range(2, int(d**0.5)+1): + while d%i == 0: + pf[i] = pf.get(i,0)+1 + d//=i +if d>1: + pf[d] = 1 +P = list(pf.keys()) +print(len(P)+1)" +p02608,s662360479,Accepted,"n = int(input()) +ans = [0 for _ in range(10050)] +for i in range(1, 105): + for j in range(1, 105): + for k in range(1, 105): + v = i * i + j * j + k * k + i * j + j * k + k * i + if v < 10050: + ans[v] += 1 + +for i in range(n): + print(ans[i + 1]) +" +p02924,s506926462,Wrong Answer,"N = int(input()) +print(int((N-1)*N/2))" +p03285,s785530300,Accepted,"n = int(input()) +f = False +c = [] +d = [] +for i in range(n//4+1): + c.append(i) + +for i in range(n//7+1): + d.append(i) + +for i in range(len(c)): + for j in range(len(d)): + if c[i]*4+d[j]*7 == n: + f = True + break + +if f: + print('Yes') +else: + print('No')" +p03962,s906245134,Accepted,"a=input().split("" "") +b=set(a) +print(len(b))" +p03274,s522717211,Accepted,"def main(): + INF = 10**18 + N,K = map(int,input().split()) + x = list(map(int,input().split())) + ans = INF + for i in range(K-1,N): + ans = min(ans,abs(x[i]-x[i-K+1])+min(abs(0-x[i]),abs(0-x[i-K+1]))) + print(ans) + +if __name__ == '__main__': + main()" +p04033,s488787810,Accepted,"a, b = map(int,input().split()) +num = (b-a)+1 +if a > 0: + print(""Positive"") +elif b < 0 and num%2==0: + print(""Positive"") +elif b < 0 and num%2!=0: + print(""Negative"") +elif a <= 0 and b >= 0: + print(""Zero"")" +p03281,s315804609,Accepted,"N = int(input()) +ans = 0 +for n in range(1, N+1): + if n%2 == 1: + count = 0 + for i in range(1, n+1): + if n%i == 0: + count += 1 + if count == 8: + ans += 1 + +print(ans)" +p03557,s463225780,Wrong Answer,"import bisect +n = int(input()) +a = sorted(list(map(int, input().split()))) +b = sorted(list(map(int, input().split()))) +c = sorted(list(map(int, input().split()))) + +ans = 0 +for i in b: + x = bisect.bisect_right(a,i) + y = bisect.bisect_left(c, i) + #print(x, y) + ans = ans+x*(n-y) + +print(ans)" +p03761,s822959231,Wrong Answer,"from collections import defaultdict +n = int(input()) +dic = defaultdict(lambda: 51) +memo = 'abcdefghijklmnopqrstuvwxwz' +for i in range(n): + s = input() + memo = set(s) & set(memo) + for m in memo: + dic[m] = min(dic[m], s.count(m)) +ans = '' +for m in sorted(memo): + ans += m*dic[m] +print(ans) +" +p02618,s895838244,Accepted,"D = int(input()) +C = list(map(int, input().split())) +S = [] +N = 26 +for d in range(D): + S += [list(map(int, input().split()))] +#print(C) +#print(S) +myans = [d%N for d in range(D)] +for d in range(D): + print(myans[d]+1)" +p03448,s934877706,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +cnt = 0 + +for h in range(0,c): + for i in range(0,b): + for j in range(0,a): + if (x == ((500 * j) + (100 * i) + (50 * h))): + cnt = cnt +1 + +print(cnt) +" +p03469,s847473856,Accepted,"#別解 + +s = input() + + +s_new = s[:3] + '8' + s[4:] + +print(s_new)" +p03861,s134854437,Accepted,"a, b, x = map(int, input().split()) + +if a%x != 0: + aa = a + (x - a % x) +else: aa = a + +ans = (b - aa) // x + 1 + +print(ans)" +p03852,s056183831,Accepted,"a = input() +t = ""aeiou"" + +if a in t: + print('vowel') +else: + print('consonant') +" +p03071,s136651653,Accepted,"val = list(map(int, input().split())) +val.sort() +cnt = 0 +for i in range(2): + cnt += val[1] + val[1] -= 1 + val.sort() +print(cnt)" +p02759,s927987229,Accepted,"N = int(input()) +if N%2 == 0: + print(N//2) +else: + print(N//2 + 1) + + +" +p02694,s961649189,Accepted,"X = int(input()) +n = 100 +i = 0 +while n < X: + n = int(n*1.01) + i += 1 +print(i)" +p02577,s906639121,Accepted,"N = input() + +sum = sum([int(i) for i in N]) +if sum % 9 == 0: + print('Yes') +else: + print('No') +" +p02780,s333923088,Accepted,"a = [int(i) for i in input().split()] +b = [(int(i)+1)/2 for i in input().split()] + +he = sum(b[:a[1]]) +maxer = he +for i in range(a[0] - a[1]): + he -= b[i] + he += b[i + a[1]] + maxer = max(he, maxer) + +print(maxer)" +p02725,s633991427,Accepted," + +if __name__ == ""__main__"": + K, N = map(int, input().split()) + A = list(map(int, input().split())) + # print(A) + A_dif = [] + for i in range(len(A)-1): + # print(A[i + 1]) + # print(A[i]) + A_dif.append(A[i + 1] - A[i]) + A_dif.append((abs(K - A[-1]) + A[0])) + # print(A_dif) + A_dif.sort(reverse=True) + ret = sum(A_dif[1:]) + print(ret) +" +p03760,s022090086,Wrong Answer,"import sys + +O = list(input()) +E = list(input()) +for o, e in zip(O, E): + sys.stdout.write(o + e) +if len(O) - len(E) == 1: + sys.stdout.write(E[-1]) +print() +" +p02773,s907173571,Accepted,"import collections + +N = int(input()) +S = list(input() for i in range(N)) +S.sort() + +common = collections.Counter(S).most_common() +N_common = common[0][1] + +candidates = [cand for cand in common if cand[1] == N_common] + +for i in sorted(candidates): + print(i[0])" +p02847,s110569494,Accepted,"w = [""SUN"", ""MON"", ""TUE"", ""WED"", ""THU"", ""FRI"", ""SAT""] + +s = input() + +print(6-w.index(s)+1)" +p02595,s912593478,Accepted,"LI = lambda: list(map(int, input().split())) + +N, D = LI() +XY = [LI() for _ in range(N)] + + +def main(): + ans = 0 + d2 = D ** 2 + for x, y in XY: + if x ** 2 + y ** 2 <= d2: + ans += 1 + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02730,s323953846,Wrong Answer,"s=list(input()) +n=len(s) +if s[::1] == s[::-1] and s[:((n-1)//2):1]==s[:((n-1)//2):-1] and s[((n+3)//2)-1:n:1]==s[((n+3)//2)-1:n:-1]: + print('Yes') +else: + print('No')" +p02583,s050645824,Accepted,"n, *l = map(int, open(0).read().split()) +ans = 0 +for i in range(n): + for j in range(i+1, n): + for k in range(j+1, n): + if(l[i]==l[j] or l[j]==l[k] or l[k]==l[i]): continue + if(l[i]+l[j]<=l[k] or l[j]+l[k]<=l[i] or l[k]+l[i]<=l[j]): continue + ans += 1 +print(ans)" +p02661,s992637804,Accepted,"N=int(input()) +L=[] +for i in range(N): + A, B=list(map(int,input().split())) + L.append((A,B)) +L1=sorted(L,key=lambda x: x[0]) +L2=sorted(L,key=lambda x: x[1]) +if N%2==1: + n=N//2 + print(L2[n][1] -L1[n][0]+1) +else: + n=N//2 + m=(L1[n-1][1]+L1[n][1])/2 + print(L2[n-1][1]+L2[n][1]-L1[n-1][0]-L1[n][0]+1)" +p03095,s356448311,Accepted,"from collections import Counter + +N = int(input()) +S = input() +SC = Counter(S) +mod = 10**9 + 7 +ans = 1 +for key, value in SC.items(): + ans *= (value+1) + ans %= mod +print(ans-1)" +p02760,s626519412,Wrong Answer,"l = [] +flag = 0 +for i in range(3): + for j in input().split(): + l.append(j) +n = int(input()) +for i in range(n): + a = input() + if a in l: + l[l.index(a)] = 0 +if l[0:3] == 0 or l[3:6] == 0 or l[6:9] == 0: + flag = 1 +if l[0::3] == 0 or l[1::3] == 0 or l[2::3] == 0: + flag = 1 +if l[0::4] == 0 or l[2::2] == 0: + flag = 1 +if flag: + print(""Yes"") +else: + print(""No"")" +p02982,s177922975,Accepted,"#!/usr/bin/env python +# coding: utf-8 + +# In[7]: + + +import math + + +# In[13]: + + +N,D = map(int, input().split()) +X = [] +for _ in range(N): + X.append(list(map(int, input().split()))) + + +# In[14]: + + +ans = 0 +for i in range(N-1): + for j in range(i+1,N): + dist = sum((X[i][k]-X[j][k])**2 for k in range(D)) + if math.sqrt(dist)%1 == 0: + ans += 1 +print(ans) + + +# In[ ]: + + + + +" +p02629,s521916603,Accepted,"n = int(input()) + +keta = 1 +for i in range(1, 18): + t = 26*(26**i-1)//25 + if n <= t: + break + else: + keta += 1 + +n -= 26*(26**(keta-1)-1)//25 +n -= 1 + +ans = """" +for i in range(keta): + t = 26**i + ans = chr(ord('a')+(n//t)%26)+ans +print(ans)" +p03720,s726654166,Wrong Answer,"from collections import Counter +N, M = map(int, input().split()) +R = [] +for i in range(M): + R += list(map(int, input().split())) +R = Counter(R) +for i in R.values(): + print(i)" +p02910,s251377856,Accepted,"# input +S = input() + +# check +fl = True +for i, s in enumerate(S): + if ( + ((i + 1) % 2 == 0 and s not in [""L"", ""U"", ""D""]) or + ((i + 1) % 2 == 1 and s not in [""R"", ""U"", ""D""]) + ): + fl = False + break + +if fl is True: + print(""Yes"") +else: + print(""No"") +" +p03672,s859598378,Wrong Answer,"S = [c for c in input()] +while len(S): + S.pop() + if len(S) % 2 == 0 and S[:len(S)//2] == S[len(S)//2:]: + print(len(S[:len(S)//2+1])) + exit() +" +p03698,s460841976,Accepted,"import sys +import math +import bisect + +def solve(s): + return len(s) == len(set(list(s))) + +def main(): + s = input() + if solve(s): + print('yes') + else: + print('no') + +if __name__ == ""__main__"": + main() +" +p03327,s308203817,Accepted,"n = int(input()) +if n <1000: + print(""ABC"") +else: + print(""ABD"")" +p03162,s923394828,Accepted,"# 問題C +import numpy as np +import warnings +warnings.filterwarnings('ignore') + +N = int(input()) +h = np.array([list(map(int, input().split())) for _ in range(N)]) + +h = h.reshape(N, 3) + +dp = np.array([[0] * h.shape[1]] * h.shape[0]) +dp[0, :] = h[0, :] +for i in range(1, N): + dp[i, 0] = max(dp[i-1, 1], dp[i-1, 2])+h[i, 0] + dp[i, 1] = max(dp[i-1, 0], dp[i-1, 2])+h[i, 1] + dp[i, 2] = max(dp[i-1, 0], dp[i-1, 1])+h[i, 2] + +print(max(dp[-1, ])) +" +p02973,s502862873,Accepted,"import bisect +from collections import deque +N = int(input()) +A = deque([]) +for i in range(N): + A.append(int(input())) + +dp = deque([]) +l = len(A) +for i,a in enumerate(A): + pos = bisect.bisect_left(dp, a)-1 + if pos<0: + dp.appendleft(a) + else: + dp[pos] = a + +print(len(dp))" +p04020,s743799254,Accepted,"def solve(): + N = int(input()) + A = [int(input()) for _ in range(N)] + ans = A[0]//2 + A[0] = A[0]%2 + for i in range(1,N): + ans += (A[i]+A[i-1])//2 + if (A[i]+A[i-1])//2>0: + A[i] = (A[i]+A[i-1])%2 + return ans +print(solve())" +p03695,s070959941,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +num = [0 for i in range(9)] +for i in a: + if i >= 3200: + num[8] += 1 + else: + num[i//400] += 1 + +zero = num[:8].count(0) +print(8-zero, end = ' ') +print(8-zero + num[8])" +p02645,s949735041,Wrong Answer,"S = input() #ここで標準入力 +print (type(S), S)" +p03815,s550901578,Accepted,"x = int(input()) +ans = (x//11) * 2 + +y = x % 11 + +if 6 < y: + ans += 2 +elif 1 <= y <= 6: + ans += 1 + +print(ans)" +p03038,s929098331,Wrong Answer,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +BC = [] +for i in range(M): + bc = list(map(int, input().split())) + BC.append(bc) +BC.sort(key = lambda x : x[1]) +irekae = [] +count = 0 +i = 0 +while count < N: + tmpb = BC[M-1-i][0] + tmpc = BC[M-1-i][1] + irekae += [tmpc for i in range(tmpb)] + count += tmpb + i += 1 + +ans = A + irekae +ans.sort(reverse = True) +print(sum(ans[:N]))" +p03284,s079597636,Accepted,"# | Its_Rashid | # +a , b = map(int , input().split()) +print(0 if a % b == 0 else 1)" +p03471,s597988493,Accepted,"N,Y = input().split() +N = int(N) +Y_k=int(Y)/1000 + +answer = [-1,-1,-1] +for i in range(N+1): + for j in range(N+1 - i): + k = N-i-j + if 10*i + 5*j + 1*k == Y_k: + answer = [i,j,k] + +print(answer[0],answer[1],answer[2]) +" +p02718,s813306606,Accepted,"def getInput(): + return [int(i) for i in input().rstrip().split(' ')] +N, M = getInput() +A = getInput() +_4M = sum(A) / (4*M) +A.sort(reverse=True) +cnt = 0 +for i in A: + if i >= _4M: + cnt += 1 +print('Yes') if cnt >= M else print('No')" +p02607,s947486128,Accepted,"N = int(input()) +a = [int(i) for i in input().split()] +ans = 0 +for i in range(N): + if (i%2==0) and (a[i]%2 == 1): + ans += 1 +print(ans)" +p02693,s450900686,Wrong Answer,"k=int(input()) +a,b=map(int,input().split()) + +for i in range(a,b+1): + if i%k==0: + print(""NG"") + break +else: + print(""OK"") +" +p02676,s470121796,Accepted,"K = int(input()) +S = input() + +if len(S) > K: + a = S[0:K] + '...' + print(a) +else: + print(S[0:K])" +p02835,s225448544,Accepted,"a_list = [int(x) for x in input().split()] +ans = ""bust"" if sum(a_list) >= 22 else ""win"" +print(ans)" +p02900,s936099831,Wrong Answer,"import fractions + +a, b = map(int, input().split()) + +x = fractions.gcd(a,b) +if x == 1: + print(1) + exit() +ans = [] + +i = 2 +y = int(x**0.5) +while True: + if x%i == 0: + x //= i + ans.append(i) + i = 2 + y = int(x**0.5) + elif i >= y: + ans.append(x) + break + else: + i += 1 + +print(len(set(ans))+1)" +p02747,s814433152,Accepted,"s = input() +if """".join(s.split(""hi"")) == """": + print(""Yes"") +else: + print(""No"")" +p02959,s937626556,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +ans = 0 +for i in range(n): + ans += (p:=min(a[i],b[i])) + ans += (q:=min(a[i+1],b[i]-p)) + a[i+1] -= q +print(ans)" +p02916,s690376016,Accepted,"n = int(input()) + +a_list = list(map(int, input().split())) +b_list = list(map(int, input().split())) +c_list = list(map(int, input().split())) + +ans = 0 +for i in range(n): + + ans += b_list[a_list[i]-1] + #print(b_list[a_list[i]-1]) + if i == 0: + continue + else: + if a_list[i] == a_list[i-1]+1: + #print(a_list[i-1]-1) + #print(c_list[a_list[i-1]-1]) + ans += c_list[a_list[i-1]-1] + +print(ans)" +p03131,s648148223,Wrong Answer,"k,a,b=map(int,input().split()) +if b N: + print(-1) +else: + print(cnt)" +p04045,s372164826,Accepted,"#!/usr/bin/env python3 +from collections import deque +N, K = map(int, input().split()) +D = list(map(int, input().split())) + +init = [str(i) for i in range(10) if i not in D and i != 0] +use = [str(i) for i in range(10) if i not in D] +q = deque(init) +ans = [] +while q: + num = q.pop() + if int(num) >= N: + ans.append(num) + continue + for u in use: + q.append(num + u) + +print(min(list(map(int, ans))))" +p03284,s156500894,Wrong Answer,"a,b=map(int,input().split()) +print(a%b)" +p02910,s705431338,Accepted,"S=input() + +ans='Yes' +for i in range(len(S)): + if (i%2==1) and (S[i] not in {'L','U','D'}):ans='No' + if (i%2==0) and (S[i] not in {'R','U','D'}):ans='No' +print(ans)" +p02556,s682857648,Accepted,"N = int(input()) +pulls = [] +minus = [] + +for _ in range(N): + x, y = map(int, input().split()) + pulls += [x+y] + minus += [x-y] + +pulls.sort() +minus.sort() +print(max(pulls[-1] - pulls[0], minus[-1] - minus[0]))" +p02658,s305460695,Accepted,"import sys + +N = int(input()) +A = list(map(int, input().split())) + +num = 1 + +if 0 in A: + print(0) + sys.exit() + +for i in range(N): + num *= A[i] + if num > (10 ** 18): + print(-1) + sys.exit() + +print(num)" +p03860,s850229122,Wrong Answer,"S = input() + +s = 'A'+S[9].upper() + 'C' +print(s)" +p03000,s177045875,Accepted,"n, x = map(int, input().split()) +l = list(map(int, input().split())) +d = 0 +e = 1 +for i in l: + d = d + i + if d <= x: + e += 1 +print(e) +" +p02765,s493969621,Accepted,"import bisect, collections, copy, heapq, itertools, math, string +import sys +def I(): return int(sys.stdin.readline().rstrip()) +def MI(): return map(int, sys.stdin.readline().rstrip().split()) +def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip().split()) + +from collections import defaultdict +import bisect +def main(): + N, R = MI() + if N >= 10: + print(R) + else: + print(R + 1000 - 100 * N) + +if __name__ == ""__main__"": + main() +" +p02725,s152266671,Accepted,"k,n = map(int,input().split()) +l= list(map(int,input().split())) +li = [] + +for i in range(n): + if i != n-1: + li.append(l[n-i-1]-l[n-i-2]) + else: + li.append(k-l[n-1]+l[0]) + +li.sort(reverse=True) +print(k-li[0])" +p03799,s104505686,Wrong Answer,"n,m=map(int,input().split()) +if 2*n>m: + print(n//2) +else: + print(n+(m-2*n)//4)" +p02658,s988812894,Accepted,"# -*- coding: utf-8 -*- +import math +n = int(input()) +a = list(map(int, input().split())) +a.sort() +q = 1 +f = 0 +for i in a: + q *= i + if q > 10**18: + f = 1 + break +if f == 1: + print(-1) +else: + print(q)" +p02787,s817874973,Accepted,"import numpy as np + +H,N = list(map(int, input().split())) +As = [] +Bs = [] +for _ in range(N): + a, b = list(map(int, input().split())) + As.append(a) + Bs.append(b) +As = np.array(As) +Bs = np.array(Bs) + +dp = np.full((H+1), np.inf) +dp[0] = 0 + +for c in range(1,H+1): + dp[c] = np.amin(dp[np.maximum(c - As, 0)] + Bs) + +print(int(dp[-1])) +" +p02911,s063582132,Wrong Answer,"N, K, Q = map(int, input().split()) +A = """" +for i in range(Q): + A += input() + +res = [] +for i in range(1, N + 1): + if K - Q + A.count(str(i)) > 0: + res.append(""Yes"") + else: + res.append(""No"") + +for r in res: + print(r)" +p03785,s500456529,Accepted,"n, c, k = map(int, input().split()) +T = sorted(int(input()) for _ in range(n)) + +counter = 1 +start = -1 +wating_num = 0 +for t in T: + if start < 0: + start = t + if t - start > k or wating_num + 1 > c: + counter += 1 + wating_num = 0 + start = t + wating_num += 1 +print(counter)" +p03012,s515778223,Accepted,"def main(): + n = int(input()) + wlist = list(map(int, input().split())) + min_diff = float('inf') + for i in range(1, n): + s1 = sum(wlist[:i]) + s2 = sum(wlist[i:]) + diff = abs(s1-s2) + if min_diff > diff: + min_diff = diff + print(min_diff) +main()" +p02639,s977264648,Accepted,"x=[int(_) for _ in input().split("" "")] + +for i in range(5): + if x[i] == 0: + ans = i+1 + +print(ans)" +p02924,s860283369,Accepted,"N = int(input()) +A = N*(N+1)//2-N +print(A)" +p03910,s228114209,Accepted," +if __name__ == '__main__': + N = int(input()) + for i in range(1, N+1): + sumn = i *(i+1)//2 + if(N <= sumn): + for j in range(1, i+1): + if j == sumn-N: + continue + print(j) + exit() + + +" +p03427,s661633720,Wrong Answer,"n = input() +for i in range(len(n)): + if n[-i-1] != ""9"": + if i == -len(n): print(int(n[0])+9*(len(n)-1)) + else: print(int(n[i])-1+9*(len(n)-1)) + break +else: print(9*len(n))" +p02647,s949354805,Accepted,"N,K=map(int, input().split()) +A=list(map(int, input().split())) + +def f(A): + D=[0]*(N+1) + for j in range(N): + mi=max(j-A[j],0) + ma=min(j+A[j],N-1) + D[mi]+=1 + D[ma+1]-=1 + for i in range(1,N): + D[i]+=D[i-1] + A=D[:-1] + return A + +for i in range(min(K,42)): + A=f(A) +print(*A)" +p02724,s183282092,Accepted,"n = int(input()) + +a = n//500 +b = (n - a * 500) //5 +ans = a * 1000 + b * 5 +print(ans)" +p03548,s312423263,Wrong Answer,"x,y,z = map(int,input().split()) + +ans = int(x/(y+z)) +if x%(y+z)-z >= 0: + ans -= 1 +print(ans)" +p04019,s280696161,Wrong Answer,"s = input().rstrip() + +if ('N' in s and 'S' in s) or ('W' in s and 'E' in s): + if ('N' in s and 'S' in s) or ('W' in s and 'E' in s): + print('Yes') + exit() + +print('No') +" +p02882,s687405533,Accepted,"import math +a,b,x = map(int,input().split()) +if x>=(a**2)*b/2: + y = 2*b-2*x/(a**2) + print(math.degrees(math.atan2(y,a))) +else: + y = 2*x/(a*b) + print(90-math.degrees(math.atan2(y,b)))" +p02700,s511050217,Accepted,"import math + +a, b, c, d = [float(n) for n in input().split()] + +if math.ceil(a/d) >= math.ceil(c/b): + print(""Yes"") +else: + print(""No"")" +p03035,s564561061,Accepted,"a, b = map(int, input().split()) +if a <= 5: + print(0) +elif a <= 12: + print(b//2) +else: + print(b) +" +p02994,s055248234,Wrong Answer,"import numpy as np +N,L = map(int,input().split()) +L_list=np.array(range(1,N+1))+L-1 +if (0 in L_list): + print(sum(L_list)) + exit() +if(N M: + continue + AtoB[A].append(B) + +# A が小さい順に増えていく +result = 0 +que = [] # ヒープ +for Bs in AtoB: + for B in Bs: + heappush(que, -B) # Python3 のヒープはデフォルトで小さい順 + if que: + result -= heappop(que) +print(result)" +p03284,s185899396,Accepted,"N ,K = map(int,input().split()) +if N%K == 0: + print(0) +else: + print(1)" +p02847,s060075124,Accepted,"days = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] +day = input() +# このdayが何番目かを出して7からひく +print(7 - days.index(day))" +p02578,s890936511,Wrong Answer,"n = int(input()) +As = list(map(int,input().split())) +sum = 0 +step =0 + +try: + for i in range(len(As)): + if As[i] < As[i + 1]: + step = As[i + 1] - As[i] + As[i] += step + sum += step +except IndexError: + pass + +print(sum)" +p03543,s149474869,Wrong Answer,"n=list(input()) +t=n[0] +cnt=0 +for i in range(1,len(n)-1): + if t==n[i]: + cnt+=1 +if cnt>=3: + print(""Yes"") +else: + print(""No"") +" +p02708,s699397790,Accepted,"N,K = map(int,input().split()) + + +sum = 0 +for k in range(K,N+2): + # sum(arr[0:0+k]), sum([l-,l]) + s1 = ((0 + k-1) * k) // 2 + s2 = (((N - k + 1) + N) * k) // 2 + sum = sum + (s2 - s1 + 1) + +print(sum % (1000000000 + 7))" +p03745,s335782947,Wrong Answer,"N = int(input()) +A = list(map(int, input().split("" ""))) + +list = [] +sim=0 +for i in range(N-1): + if A[i]A[i+1]: + list.append(0) + if A[i]==A[i+1]: + sim+=1 + +print(list) + +i = 0 +count = 0 + +while i (Asum + Bsum): + ans = Asum + Bsum +print(ans)" +p03162,s219339403,Wrong Answer,"N = int(input()) + +dp = [[0]*3 for _ in range(N+1)] + +for i in range(1, N): + a, b, c = map(int, input().split()) + dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a + dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b + dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c + +print(max(dp[N][0], dp[N][1], dp[N][2]))" +p03103,s864783976,Wrong Answer,"from bisect import bisect_left +from itertools import accumulate + +N, M = map(int, input().split()) +shop = [list(map(int, input().split())) for _ in range(N)] +shop.sort(key=lambda x: x[0]) + +money_sum = (list(accumulate([i[0] * i[1] for i in shop]))) +drink_sum = (list(accumulate([i[1] for i in shop]))) + +drink = 0 +money = 0 + +idx = bisect_left(drink_sum, M) + +drink = drink_sum[idx - 1] +money = money_sum[idx - 1] + +for _ in range(shop[idx][1]): + if drink == M: + break + else: + drink += 1 + money += shop[idx][0] + +print(money)" +p03359,s428239554,Wrong Answer,"def main(): + a, b = map(int, input().split()) + + print(min(a, b)) + + +if __name__ == ""__main__"": + main() +" +p02602,s380225951,Accepted,"n,k=map(int,input().split()) +a=list(map(int,input().split())) + +for i in range(n-k): + if a[k+i]>a[i]: + print(""Yes"") + else: + print(""No"") +" +p02572,s164401089,Wrong Answer,"N=int(input()) +A=list(map(int, input().split())) +MOD=7+10**9 +ans=0 +for i in range(len(A)-1): + for j in range(i+1,len(A)): + print(A[i],A[j]) + ai= A[i] % MOD + aj=A[j] % MOD + ans = ans +ai*aj % MOD +print(ans%MOD)" +p03672,s579687882,Accepted,"s = input() +while True: + s = s[:-1] + if s[0:len(s)//2] == s[len(s)//2:]: + print(len(s)) + exit()" +p03103,s871331449,Accepted,"N,M=map(int,input().split()) +A=[0]*N;p=0;q=M +for i in range(N): + a,b=map(int,input().split()) + A[i]=[b,a] + +A.sort(key=lambda x: x[1]) +#print(A) +i=0 +while q>0: + if q>=A[i][0]: + p=p+A[i][0]*A[i][1] + q=q-A[i][0] + i=i+1 + else: + p=p+q*A[i][1] + q=q-q + break +print(p)" +p02817,s081123049,Wrong Answer,"s,t = input().split() +print(t, end="" "") +print(s)" +p02972,s361228314,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +ans = [0] * N +index = [] +M = 0 +for i in range(N-1,-1,-1): + if sum(A[i:N:i+1]) % 2 == 0: + ans[i] = 0 + else: + ans[i] = 1 + index.append(i+1) + M += 1 +print(M,*index,sep='\n')" +p02802,s165990809,Accepted,"n, m = map(int, input().split()) +ac = {} +wa = {} +for _ in range(m): + p, s = input().split() + p = int(p) + if s == 'AC': + ac[p] = 1 + else: + if not ac.get(p, 0): + wa[p] = wa.get(p, 0) + 1 +pen = 0 +for p in ac: + pen += wa.get(p, 0) +print(len(ac), pen) +" +p03106,s882044364,Accepted,"# abc120_b.py +import fractions +from functools import reduce +def gcd(*numbers): + return reduce(fractions.gcd, numbers) +def gcd_list(numbers): + return reduce(fractions.gcd, numbers) + +A, B, K = map(int,input().split()) +cnt = 0 +_max = gcd(A,B) +while _max>=0: + if A%_max==0 and B%_max==0: + cnt += 1 + if cnt == K: + print(_max) + exit() + _max -=1 +" +p03759,s569573837,Accepted,"A, B, C = map(int, input().split()) +print(['NO', 'YES'][B - A == C - B])" +p04029,s020427797,Accepted,"def main(): + N = int(input()) + total = [i for i in range(1, N+1)] + print(sum(total)) + + +if __name__ == ""__main__"": + main()" +p02747,s503813337,Wrong Answer,"string = input() +flag = True + +num = len(string) +if num % 2 == 0: + for i in range(num // 2 - 1): + if string[2*i:2*(i+1)] != ""hi"": + flag = False + break +else: + flag = False + +if flag: + print(""Yes"") +else: + print(""No"")" +p03327,s986350062,Accepted,"def main(): + n = int(input()) + + if n <= 999: + print('ABC') + else: + print('ABD') + + +if __name__ == '__main__': + main() +" +p03469,s718777195,Accepted,"s = input() +x = s[:3] + ""8"" + s[4:] +print(x)" +p02753,s031800702,Accepted,"_string = input() + +if _string == ""AAA"" or _string == ""BBB"": + print(""No"") +else: + print(""Yes"")" +p02873,s616146218,Accepted,"s = input() +prev = s[0] +n = len(s) +cnt= 0 +L = [0]*(n+1) +R = [0]*(n+1) +for i in range(n): + if s[i] ==""<"": + cnt+=1 + else: + cnt=0 + L[i+1] = cnt +s= s[::-1] +for i in range(n): + if s[i] =="">"": + cnt+=1 + else: + cnt=0 + R[i+1] = cnt +ans = 0 +for i in range(n+1): + ans+=max(L[i],R[-i-1]) +print(ans) +" +p02835,s746046236,Wrong Answer,"a1,a2,a3=map(int,input().split()) +print('win' if a1+a2+a3<22 else 'Burst')" +p03796,s175570989,Wrong Answer,"n = int(input()) + +x = (10**9 + 7) + +for i in range(1,n+1): + n = n * i + + +if n < x: + print(n) + +elif n >=x : + print(n % x)" +p03962,s709222000,Accepted,"a,b,c=map(int,input().split()) +cnt=3 + +if a==b: + cnt-=1 + +if b==c: + cnt-=1 + +if c==a: + cnt-=1 + +if a==b==c: + cnt+=1 + +print(cnt)" +p03150,s019135203,Wrong Answer,"s=input() +key=""keyence"" +li=[] +for i in range(len(key)): + li.append([key[:i],key[i:]]) + +for i in li: + if i[0] in s and i[1] in s: + print(""YES"") + break +else: + print(""NO"")" +p03261,s387291432,Accepted,"import sys +N = int(input()) +W = [] +for i in range(N): + W.append(input()) +if len(set(W)) != len(W): + print(""No"") +else: + for i in range(len(W)-1): + if W[i][-1] != W[i+1][0]: + print(""No"") + sys.exit() + print(""Yes"") +" +p03555,s693297766,Accepted,"c1 = list(input()) +c2 = list(input()) +c1.reverse() +if c1 == c2: + print(""YES"") +else: + print(""NO"")" +p02628,s443427478,Accepted,"N,K=map(int,input().split()) +p=list(map(int,input().split())) +p.sort() +print(sum(p[:K]))" +p03986,s205053301,Accepted,"from collections import deque +X = input() + +scan = deque() + +for c in X: + # print(scan) + if c == 'S': + scan.append(c) + else: + if not scan or scan[-1] == 'T': + scan.append('T') + else: + scan.pop() +print(len(scan))" +p02630,s020653338,Accepted,"n = int(input()) +A = list(map(int, input().split())) +mydict = {} +total = 0 +for a in A: + mydict[a] = mydict[a] + 1 if a in mydict else 1 + total += a + +q = int(input()) +for i in range(0, q): + b, c = map(int, input().split()) + if b in mydict: + if not c in mydict: + mydict[c] = 0 + total += (c - b) * mydict[b] + mydict[c] += mydict[b] + mydict[b] = 0 + print(total)" +p02832,s963073777,Accepted,"n=int(input()) + +a=[int(x) for x in input().split()] + +i=0 +ans=0 +saigo=0 +k=1 +kosuu=n + +while i<=n-1: + if a[i]!=k: + ans+=1 + kosuu-=1 + else: + saigo=a[i] + k+=1 + i+=1 + +if kosuu==0: + print(-1) + exit() + +if kosuu==saigo: + print(ans) +else: + print(-1)" +p03633,s991353712,Accepted,"from fractions import gcd +a = 1 +n = int(input()) +for i in range (n): + h = int(input()) + a = a*h // gcd(a,h) +print(a) +" +p04005,s403644626,Wrong Answer,"a,b,c=map(int,input().split()) + +def block(a,b,c): + blocksum=a*b*c + if a%2==0 or b%2==0 or c%2==0: + print(0) + return + else: + if a!=1: + print(blocksum-2*(a//2)*b*c) +block(a,b,c)" +p02963,s060140937,Accepted,"S=int(input()) +if S == 10**18: + print(0,0,10**9,1,0,10**9) +else: + q,r = S//10**9, S%10**9 + print(0,0,10**9,1,10**9-r,q+1)" +p03448,s136088622,Accepted,"A = int(input()) +B = int(input()) +C = int(input()) +X = int(input()) +count = 0 +for i in range (A+1): + for j in range (B+1): + tmp = i*500 + j*100 + #print(tmp) + k = (X-tmp) / 50 + if k>=0 and k <= C: + count +=1 +print(count)" +p02918,s950056495,Accepted,"n,k=map(int,input().split()) +s=input() +un=0 +for i in range(1,len(s)): + if s[i-1]!=s[i]: + un+=1 +print((n-1)-max(0,un-2*k))" +p03251,s981076108,Accepted,"N, M, X, Y = map(int, input().split()) +x = sorted(map(int, input().split())) +y = sorted(map(int, input().split())) + +if x[-1] < y[0]: + if Y <= x[-1] or y[0] <= X: + print('War') + else: + print('No War') +else: + print('War')" +p03086,s304268882,Accepted,"S = input() + +ans = 0 +ans_lis = [0] + +for i in range(len(S)): + if S[i] in ""ACGT"": + ans = ans + 1 + if i == (len(S)-1): + ans_lis.append(ans) + else: + ans_lis.append(ans) + ans = 0 + +print(max(ans_lis))" +p02600,s211687857,Accepted,"x = int(input()) +p = 599 +for i in range(8): + + if x <= p: + print(8-i) + exit() + p += 200" +p03785,s623789844,Accepted,"from collections import deque + +n, c, k = map(int, input().split()) +t = [int(input()) for _ in range(n)] + +t.sort() + +q = deque(t) +cnt = 1 +ans = 1 +curr = q.popleft() + +while q: + tmp = q.popleft() + if tmp - curr <= k and cnt < c: + cnt += 1 + else: + ans += 1 + cnt = 1 + curr = tmp + +print(ans)" +p02972,s113593559,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +input_num = [0 for _ in range(n)] + +for i in range(n-1, -1, -1): + tmp = 0 + j = i+i+1 + while j < n: + tmp += input_num[j] + j += i+1 + + if tmp % 2 != a[i]: + input_num[i] = 1 + +print(sum((input_num))) +for i, j in enumerate(input_num): + if j: + print(i+1, end=' ')" +p02598,s295275771,Accepted,"N, K = map(int, input().split("" "")) +logs = list(map(int, input().split("" ""))) + +def cal( max_length ): + cut_count = 0 + for l in logs : + cut_count += (l//max_length -1) + if l % max_length != 0 : + cut_count += 1 + return cut_count <= K + +i = 1 +j = max(logs) +while i < j : + m = (i+j)//2 + if cal(m) : + j = m + else : + i = m+1 + +print(i) +" +p03821,s694896656,Accepted,"n=int(input()) +L=[list(map(int,input().split())) for _ in range(n)][::-1] +c=0 +for a,b in L: + a+=c + c+=(-a)%b +print(c)" +p02783,s566878838,Accepted,"import math +a,b=map(int,input().split()) + +print(math.ceil(a/b))" +p02814,s697895769,Accepted,"import numpy as np +from math import ceil + +n,m = map(int,input().split()) +a = list(map(int,input().split())) +a = [x//2 for x in a] +lcm = np.lcm.reduce(a) +ans = 0 + +for i in a: + if lcm // i % 2 == 0: + break +else: + ans = ceil((m//lcm)/2) + +print(ans)" +p02993,s324811740,Accepted,"s = input() +print('Bad' if any(s[i] == s[i + 1] for i in range(3)) else 'Good')" +p02606,s662776592,Accepted,"L,R,d=map(int,input().split()) +n=0 +for i in range(L,R+1): + if i%d==0: + n+=1 +print(n)" +p02726,s130281090,Wrong Answer,"from itertools import combinations +N,X,Y=(int(x) for x in input().split()) +result=[] +for i in combinations(range(1,N+1),2): + result.append(min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0])) +for i in range(1,N+1): + print(result.count(i))" +p02753,s134264688,Wrong Answer,"s = input() +if s is 'AAA' or s is 'BBB': + print('No') +else: + print('Yes')" +p03659,s142777051,Accepted,"N = int(input()) +A = list(map(int,input().split())) +x = sum(A) +y = 0 +z = [] + +for n in range(N-1): + y+=A[n] + z.append(abs(x-2*y)) + +print(min(z))" +p03380,s151516962,Accepted,"def getval(): + n = int(input()) + a = list(map(int,input().split())) + return n,a + +def main(n,a): + a.sort() + c = a[n-1] + R = c/2 + r = 0 + for i in a: + if abs(R-i)=2**i])) +ans = 0 +for i in range(m): + ans += b[i]*(n-b[i])*(2**i)%(10**9+7) +ans %= 10**9+7 +print(ans)" +p03478,s887859421,Wrong Answer,"N, A, B = map(int, input().split()) + +Num = 0 +for i in range(1, N+1): + List = [int(a) for a in list(str(i))] + if A <= sum(List) <= B: + Num += 1 + +print(Num) +" +p02621,s434811141,Accepted,"import sys +input = sys.stdin.readline + +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) + +def main(): + mod=10**9+7 + a=I() + print(a+a**2+a**3) + +main() +" +p03339,s259618683,Accepted,"n=int(input()) +s=list(input()) +w=s.count(""W"") +e=s.count(""E"") +x=[0 for i in range(n)] +for i in range(1,n): + if s[i-1]==""W"": + x[i]=x[i-1]+1 + else: + x[i]=x[i-1] +ans=n +for i in range(n): + z=2*x[i]+e-i + if s[i]==""E"": + z-=1 + ans=min(ans,z) +print(ans) +" +p03778,s965009318,Wrong Answer,"W,a,b=map(int,input().split()) +if b-(a+W)==0: + print(0) + exit() +print(b-(a+W))" +p03146,s506829112,Accepted,"s = int(input()) +def f(k): + if k % 2 ==0: + return k//2 + else: + return 3*k+1 + +ary1 = [None]*1000001 +ary1[1] = s + +for i in range(2,1000001): + fn = f(ary1[i-1]) + if fn in ary1: + print(i) + break + else: + ary1[i] = fn" +p02933,s915921385,Accepted,"n=int(input()) +s=input() + +if n<3200:print(""red"") +else:print(s)" +p03592,s652131481,Wrong Answer,"N, M, K = map(int, input().split()) + +for i in range(N): + for j in range(M): + if K == (N-i)*j + i*(M-j): + print('Yes') + exit() + +print('No')" +p02554,s039086167,Accepted,"n = int(input()) +m=int(1e9+7) +print((pow(10,n,m)+pow(8,n,m)-2*pow(9,n,m))%m)" +p03323,s031984198,Accepted,"a,b = map(int,input().split()) + +if a>8 or b>8: + print("":("") +else: + print(""Yay!"")" +p02743,s108853822,Accepted,"a,b,c = list(map(int,input().split())) + +if (c-a-b)<=0: + print(""No"") +else: + chk = (c-a-b)**2 - 4*a*b + if chk > 0: + print(""Yes"") + else: + print(""No"")" +p03385,s569646953,Accepted," +def main(): + s = input() + if 'a' in s and 'b' in s and 'c' in s: + print('Yes') + else: + print('No') + + +if __name__ == ""__main__"": + main() +" +p02658,s612378887,Wrong Answer,"import sys +A = list(map(int, input().split())) +A.sort(reverse=True) +if(A[-1] == 0): + print(0) +else: + p = 1 + for An in A: + p *= An + if p > 10 ** 18: + print(-1) + sys.exit() + print(p)" +p03804,s968824074,Accepted,"N, M = map(int, input().split()) +A = [input() for i in range(N)] +B = [input() for i in range(M)] + +ans = 'No' + + +def check(x, y): + for i in range(M): + for j in range(M): + if A[x + i][y + j] != B[i][j]: + return False + return True + + +for i in range(N - M + 1): + for j in range(N - M + 1): + if check(i, j): + ans = 'Yes' + +print(ans) +" +p03796,s220690653,Wrong Answer,"n = int(input()) +r = 1 +w = 10**9 + 7 +for i in range(1, n+1): + if r > w: + r = (r % w) * i + else: + r *= i + + +print(r)" +p03293,s290110247,Wrong Answer,"S=input() +T=input() +for i in range(1,len(S)): + if S[-i:]+S[:-i]==T: + print('Yes') + exit +print('No')" +p02784,s127727417,Accepted,"h, n = map(int, input().split()) +a = list(map(int, input().split())) +if h <= sum(a): + print('Yes') +else: + print('No') + " +p02584,s005591746,Accepted,"a = list(map(int, input().split())) +x = a[0] +k = a[1] +d = a[2] +x = abs(x) + +if abs(x) - k*d >= -d: + print(abs(abs(x) - k*d)) +else: + t = x // d + x = x - d*t + k = k - t + if k % 2 == 0: + print(x) + else: + print(abs(x-d))" +p03075,s976671669,Accepted,"ABCDEK = [int(input()) for _ in range(6)] +print(""Yay!"" if ABCDEK[-2]-ABCDEK[0] <= ABCDEK[-1] else "":("")" +p02700,s992237532,Accepted,"a,b,c,d=map(int,input().split()) +t=-(-c//b) +a=-(-a//d) +if t<=a: + print(""Yes"") +else: + print(""No"")" +p03087,s468831697,Accepted,"n,q = map(int,input().split()) +s = input() +lst = [0]*n +for i in range(n-1): + lst[i+1] = lst[i] + 1*(s[i:i+2] == ""AC"") +for i in range(q): + l,r = map(int,input().split()) + print(lst[r-1]-lst[l-1])" +p02989,s724215336,Accepted,"N = int(input()) +*d, = map(int, input().split()) +d.sort() +print(d[N//2]-d[N//2-1])" +p02554,s920081892,Wrong Answer,"N = int(input()) +print(pow(10,N,1000000007)-2*pow(9,N,1000000007)+pow(8,N,1000000007))" +p03239,s572719420,Accepted,"if __name__ == '__main__': + + n,t = map(int,input().split()) + + cost = 1001 + for i in range(n): + cn,tn = map(int,input().split()) + if tn <= t : + cost = min(cost,cn) + + if cost == 1001: + print(""TLE"") + else: + print(cost) +" +p03962,s398853826,Wrong Answer,"a, b, c = map(int, input().split()) +if a == b == c: + print(1) +elif a != b != c: + print(3) +else: + print(2)" +p03359,s269417627,Accepted,"a, b = map(int, input().split()) +if a>b: + print(a-1) +else: + print(a) +" +p03359,s645871444,Accepted,"#!/usr/bin/env python3 + +a, b = map(int, input().split()) + +if b < a: + print(a-1) +else: + print(a)" +p02665,s620685504,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) +ans = 0 + +if n == 0 and A[0] == 1: + print(1) + exit() +if n != 0 and A[0] != 1: + print(-1) + exit() + + +start = 1 +way = sum(A) + +for i in range(1,n+1): + start *= 2 + + if start < A[i]: + print(-1) + exit() + if start > way: + start = way + + ans += start + #print(start, start-A[i]) + start -= A[i] + way -= A[i] +#print() +print(ans+1) +" +p02732,s180869511,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +count = [0 for i in range(n+1)] +ans = 0 +for i in range(n): + count[a[i]] += 1 +for i in range(n): + ans += count[i]*(count[i]-1)//2 +for i in range(n): + num = count[a[i]] + + print(ans-(num*(num-1)//2)+(num-1)*(num-2)//2) +" +p03761,s941581244,Wrong Answer,"from collections import Counter + +n = int(input()) + +ans = Counter() +for _ in range(n): + s = Counter(list(input())) + + if not ans: + ans = s + else: + temp = Counter() + for key in set(ans) & set(s): + temp[key] = min(ans[key], s[key]) + + ans = temp + +word = '' +for key, value in sorted(ans.most_common()): + word += key * value + +print(word) +" +p03284,s455318087,Accepted,"N,K = map(int,input().split()) + +if N%K == 0: + print(""0"") +else: + print(""1"")" +p03208,s853171796,Wrong Answer,"n, k = map(int, input().split()) +h = sorted([int(input()) for _ in range(n)], reverse=True) + +m = float('inf') +for i in range(n-k+1): + m = min(m, h[i]-h[i-k]) + +print(m)" +p03785,s968252249,Accepted,"n, c, k = map(int, input().split()) + +lt = list() +for i in range(n): + lt.append(int(input())) +lt.sort() + +b = 1 #the number of buses +p = 0 #passengers +m = lt[0] + +for i in range(n): + if p < c and lt[i]-m <= k: + p += 1 + else: + p = 1 + b += 1 + m = lt[i] + +print(b)" +p03730,s006758434,Wrong Answer,"a,b,c=map(int,input().split()) +for i in range(b): + if (i*a)%b==c: + print('YES') + break +print('NO')" +p02727,s209109448,Accepted,"from sys import stdin +X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()] +P = [int(x) for x in stdin.readline().rstrip().split()] +Q = [int(x) for x in stdin.readline().rstrip().split()] +R = [int(x) for x in stdin.readline().rstrip().split()] + +P.sort(reverse=True) +Q.sort(reverse=True) + +res = P[:X] + Q[:Y] + R +res.sort(reverse=True) + +print(sum(res[:X+Y]))" +p02780,s841548541,Wrong Answer," +n,k = list(map(int,input().split())) +a = list(map(int,input().split())) +ans = 0 +for i in range(n): + x = a[i] + a[i] = (x*(x+1))/2/x +print(a) +for i in range(n-k+1): + print(i,a[i:i+k]) + ans = max(ans,sum(a[i:i+k])) +print(ans)" +p03745,s198278585,Accepted,"N=int(input()) +li = list(map(int,input().split())) + +x = """" +count = 1 + +for i in range(N - 1): + if li[i] == li[i + 1]: + continue + + if x == """": + if li[i] < li[i + 1]: + x = 'UP' + + if li[i] > li[i + 1]: + x = 'DOWN' + + else: + if x == 'UP' and li[i] > li[i + 1]: + x = """" + count += 1 + elif x == 'DOWN' and li[i] < li[i + 1]: + x = """" + count += 1 + +print(count)" +p03693,s021043904,Wrong Answer,"print(['No','Yes'][int(''.join(list(input().split()))[1:])%4==0])" +p03612,s657756613,Accepted,"n = int(input()) +ls = list(map(int, input().split())) + +ans = 0 + +for i in range(n): + if i != n - 1: + if ls[i] == i + 1: + ls[i], ls[i + 1] = ls[i + 1], ls[i] + ans += 1 + elif i == n - 1: + if ls[i] == i + 1: + ls[i], ls[i - 1] = ls[i - 1], ls[i] + ans += 1 + +print(ans)" +p02923,s026180623,Accepted,"#!/usr/bin/env python3 + +def solve(n,h): + ans = 0 + counter = 0 + memo = 0 + for i in range(n): + if h[i] <= memo: + counter += 1 + else: + counter = 0 + memo = h[i] + ans = max(ans,counter) + return ans + +def main(): + N = int(input()) + H = list(map(int,input().split())) + print(solve(N,H)) + +if __name__ == '__main__': + main() +" +p03910,s841980170,Accepted,"n = int(input()) +import math + +def getk(num): + return int((1+math.sqrt(8*num-7))/2) + +while(True): + k = getk(n) + print(k) + n-=k + if k == 1 or n<=0: + break" +p03289,s163600042,Accepted,"s = input() +n = len(s) +Ccnt = 0 +def end(): + print('WA') + exit(0) + return +for i in range(n): + if i == 0: + if s[i] != 'A':end() + else: + if s[i].isupper(): + if 2<=i=0 and b<=5*a: + print(""1"") +else: + print(""0"")" +p02829,s489003855,Accepted,"def main(): + a = int(input()) + b = int(input()) + + c = a * b + if c == 2: + print(3) + elif c==3: + print(2) + else: + print(1) + + + +if __name__ == ""__main__"": + main() +" +p02576,s824134367,Accepted,"N,X,T = map(int,input().split()) + +if N%X != 0: + print(((N//X)+1)*T) +else: + print(((N//X))*T)" +p03075,s911437022,Wrong Answer,"a,b,c,d,e,k=[int(input())for _ in range(6)] +if e-a >= k: + print(':(') +else: + print('Yay!') +" +p02797,s728440547,Wrong Answer,"N, K, S = [int(v) for v in input().split()] + +array = [] + + +if N == K: + for i in range(N): + array.append(str(S)) +else: + for i in range(K): + array.append(str(S)) + + if S == 1000000000: + while len(array) < N: + array.append(str(S+1)) + else: + while len(array) < N: + array.append(str(1)) + +print("" "".join(array))" +p03434,s845781643,Accepted,"n=int(input()) +a=sorted(list(map(int,input().split())),reverse=True) +print(sum(a[::2])-sum(a[1::2]))" +p03076,s009330947,Accepted,"arr=[int(input()) for i in range(5)] +brr=[] +result=0 + +for i in range(5): + if arr[i]%10!=0: + brr.append(arr[i]%10) + else: + brr.append(arr[i]) +ans=brr.index(min(brr)) + + + +for i in range(5): + if i==ans or arr[i]%10==0: + result+=arr[i] + else: + result+=arr[i]+10-arr[i]%10 + +print(result) +" +p03087,s578238414,Wrong Answer,"n,q = map(int,input().split()) +s = input() +lr=[list(map(int,input().split())) for i in range(q)] +l=[0]*n +r=[0]*n +lcnt=0 +rcnt=0 +for i in range(n-1): + if s[i]==""A"" and s[i+1] == ""C"": + # lcnt+=1 + rcnt+=1 + l[i+1]=1 + r[i+1]=rcnt +for i in lr: + print(max(0,r[i[1]-1]-r[i[0]-1]-l[i[0]-1]))" +p02696,s467515063,Accepted,"import math +a,b,n = map(int,input().split()) +if n < b-1: + x = n +else: + x = b-1 +ans = math.floor(a*x/b) - a * math.floor(x/b) +print(ans)" +p02802,s665526079,Wrong Answer,"#!/usr/bin/env python3 +def main(): + N, M = map(int, input().split()) + pS = [list(input().split()) for _ in range(M)] + + score = [0] * (N + 1) + ac = [0] * (N + 1) + for p, S in pS: + p = int(p) + if S == 'AC': + ac[p] = 1 + if ac[p]: + continue + score[p] += 1 + print(sum(ac), sum(score)) + # print(score) + + +if __name__ == '__main__': + main() +" +p02713,s292184532,Wrong Answer,"import math +from functools import reduce +from itertools import product +K=int(input()) +gcd=0. +for i in range(K): + for j in range(K): + a=math.gcd(i+1,j+1) + for k in range(K): + gcd+=math.gcd(a,k+1) +print(gcd) " +p03435,s819456664,Wrong Answer,"import numpy as np + +def takahashi_info(): + + A = [] + for i in range(3): + A += [int(j) for j in input().split()] + + + if sum(A) % 3 == 0: + print('Yes') + + else: + print('No') + +takahashi_info()" +p03379,s955473732,Wrong Answer,"n = int(input()) +x = list(map(int,input().split())) +y = x.copy() +y.sort() +a = y[n//2] +b = y[n//2-1] +for i in range(n): + if x[i] == a: + print(b) + else: + print(a) +" +p02882,s388882072,Accepted,"import math + +a, b, x = map(int, input().split()) +x /= a +if a * b >= x * 2: + c = x * 2 / b + print(math.degrees(math.atan2(b, c))) +else: + c = (a * b - x) * 2 / a + print(math.degrees(math.atan2(c, a)))" +p03262,s841579057,Accepted,"import math +from functools import reduce + +def gcd(ns): + return reduce(math.gcd, ns) + +N, X = map(int, input().split()) +L = list(map(int, input().split())) + +diff = [abs(x - X) for x in L] + +if len(diff) == 1: + print(diff[0]) +else: + print(gcd(diff)) +" +p03145,s780279613,Accepted,"a,b,_ = map(int,input().split()) +print(a * b //2)" +p03804,s543998230,Wrong Answer,"from itertools import product +n, m = list(map(int, input().split())) +A = [list(input()) for _ in range(n)] +B = [list(input()) for _ in range(m)] +for i, j in product(range(n - m + 1), range(n - m + 1)): + if all([A[i + k][j:j + m + 1] == B[k] for k in range(m)]): + print('Yes') + exit() +print('No')" +p02847,s030695912,Accepted,"def main(): + S = input() + weeks = list(reversed(['SUN','MON','TUE','WED','THU','FRI','SAT'])) + print(weeks.index(S)+1) + +if __name__ == ""__main__"": + main()" +p03150,s504852275,Wrong Answer,"import sys +input = sys.stdin.readline + +# B - KEYENCE String +def is_keyence_string(): + i = 0 + + for s in S: + if s == key[i]: + i += 1 + if i == len(key): + return True + + return False + + +S = input() +key = 'keyence' + +if is_keyence_string(): + print('YES') +else: + print('NO') +" +p02646,s775193733,Accepted,"a,v = map(int, input().split()) +b,w = map(int, input().split()) +t = int(input()) + +if v <= w: + print('NO') +elif ((a-b)/(v-w))**2 <=t**2: + print('YES') +else: + print('NO')" +p02836,s087319896,Accepted,"s=input() +ans=0 +for i in range(len(s)//2): + if s[i]!=s[len(s)-1-i]: + ans+=1 +print(ans) +" +p02696,s982730780,Accepted,"#!/usr/bin/env python +import math + +def main(): + a, b, n = map(int, input().split()) + + if n < b-1: + x = n + else: + x = b-1 + + ret = math.floor(a * x / b) + print(ret) + +if __name__ == '__main__': + main() +" +p03208,s773471749,Accepted,"n,k=map(int,input().split()) +h=[int(input()) for _ in range(n)] +h.sort() + +m=h[-1] +for i in range(n-k+1): + if m > h[i+k-1]-h[i]: + m=h[i+k-1]-h[i] +print(m) + " +p02789,s912900709,Accepted,"N, M = map(int, input().split()) +if N == M: + print(""Yes"") +else: + print(""No"")" +p02958,s829105342,Accepted,"import copy +import sys +N = int(input()) +H = list(map(int,input().split())) +C = 0 + +if sorted(H) == H: + print(""YES"") + sys.exit() + +for i in range(0,N-1): + for j in range(1,N): + L = copy.copy(H) + L[i],L[j] = L[j],L[i] + if L == sorted(H): + print(""YES"") + sys.exit() +print(""NO"")" +p02571,s138411847,Accepted,"s = input() +t = input() +c = 0 + +for i in range(len(s) - len(t) + 1): + c_1 = 0 + for j in range(len(t)): + if s[i + j] == t[j]: + c_1 += 1 + if c < c_1: + c = c_1 + +print(len(t) - c)" +p03827,s387699358,Accepted,"N = int(input()) +S = input() + +x = 0 +l = [0] +for i in range(N): + if S[i] == ""I"": + x += 1 + else: + x += -1 + l.append(x) +print(max(l))" +p03109,s122283763,Wrong Answer,"S = input() +if S[5:7] == ""12>=05"": + print(""TBD"") +else: + print(""Heisei"")" +p03696,s929745701,Accepted,"N = int(input()) +S = input() + +L, R = 0, 0 +cnt = 0 +for s in S: + if s == '(': + cnt += 1 + else: + if cnt > 0: + cnt -= 1 + else: + L += 1 + +R = cnt +print(L * '(' + S + R * ')')" +p03360,s000303369,Wrong Answer,"A =list(map(int,input().split())) +K =int(input()) + +A.sort(reverse = True) +#print(A) +#print(A[0]) + +x1 =0 + +for i in range(K): + x = A[0] * 2 + x1 = x1 + x +#print(x1) +print(x1 +A[1] +A[2]) + " +p03285,s300414643,Wrong Answer,"n = int(input()) +for i in range(n//4): + for j in range(n//7): + if 4*i + 7*j == 0: + print('Yes') + break + else: + break +else: + print('No') + + +" +p02801,s831694405,Accepted,"strlist = [""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] +print(strlist[strlist.index(input()) + 1])" +p03042,s063918884,Accepted,"S = input() +l, r = map(int, [S[:2], S[2:]]) + +if 1 <= l <= 12 and 1 <= r <= 12: + print(""AMBIGUOUS"") +elif 1 <= l <= 12 and (r == 0 or r > 12): + print(""MMYY"") +elif (l == 0 or l > 12) and 1 <= r <= 12: + print(""YYMM"") +else: + print(""NA"")" +p02970,s153068256,Wrong Answer,"import math +n,d=map(int,input().split()) +print(math.ceil(n/2/d))" +p03997,s354636735,Accepted,"#45 +a=int(input()) +b=int(input()) +h=int(input()) +if h%2==0: + print(int((a+b)*h/2))" +p03109,s889971362,Wrong Answer,"a = input() +if int(a[5]) == 1: + print('TBD') +else: + if int(a[6]) > 4: + print('TBD') + else: + print('heisei')" +p03385,s329059845,Accepted,"s=str(input()) +S=set(s) +if len(S)==3: + print('Yes') +else: + print('No')" +p02691,s129425672,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +from copy import deepcopy + +B = deepcopy(A) + +for i in range(N): + A[i] += i+1 + B[i] = (i+1)-B[i] + +from collections import Counter + +C = Counter(A) +D = Counter(B) + +E = list(C.keys()) + +ans = 0 +for i in E: + ans += C[i]*D[i] + +print(ans)" +p03456,s637953531,Accepted,"a,b = input().split() +A = int(a+b) + +flg = False +for i in range(1,1000): + if i*i == A: + flg = True + break + +if flg: + print(""Yes"") +else: + print(""No"")" +p02880,s136195264,Accepted,"n=int(input()) +count=0 +for i in range(1,10): + for j in range(1,10): + if i*j==n: + count=1 + break + else: + continue +print(""Yes""if count==1 else""No"")" +p02959,s402286610,Accepted,"n = int(input()) +a_list = list(map(int, input().split())) +b_list = list(map(int, input().split())) +ans = 0 +for i in range(n): + if a_list[i] + a_list[i + 1] > b_list[i]: + ans += b_list[i] + a_list[i + 1] = min(a_list[i + 1], a_list[i] + a_list[i + 1] - b_list[i]) + else: + ans += a_list[i] + a_list[i + 1] + a_list[i + 1] = 0 +print(ans)" +p03494,s798761949,Accepted,"# 線形探索 +# 与えられた数字を一気に2で割るとしたとき、何回まで整数のままで割れますか、という考え方 +# 2進数の1/2倍は右論理シフトになるだけ +# 2進数での右の0の個数(=はじめに1が出てくる数から1を引いた数)が2で割れる回数に等しい + +import math +n = input() +a = list(map(int, input().split())) +ans = float(""inf"") +for i in a: + ans = min(ans, len(bin(i)) - bin(i).rfind(""1"") - 1) +print(round(ans))" +p03146,s111654391,Accepted,"if __name__ == '__main__': + n = int(input()) + setN =set([n]) + count=1 + while True: + if n %2 ==1: + n=3*n+1 + else: + n=n/2 + if n in setN: + print(count+1) + break + else: + count+=1 + setN.add(n)" +p02748,s258735890,Accepted,"A,B,M = list(map(int,input().split())) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +d = [] +ans = a[0]+b[0] +for i in range(M): + d.append(list(map(int,input().split()))) +for i in range(M): + x = a[d[i][0]-1] + b[d[i][1]-1] - d[i][2] + if x < ans: + ans = x +a.sort() +b.sort() +print(min(a[0]+b[0],ans))" +p02714,s009428418,Accepted,"n = int(input()) +s = input() + +r = s.count('R') +g = s.count('G') +b = s.count('B') + +ans = r * g * b + +for i in range(n): + for d in range(1, n): + j = i + d + k = j + d + if k >= n: + break + if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]: + ans -= 1 + +print(ans)" +p03261,s894699488,Accepted,"N = int(input()) +word = [] +flag = 1 +for i in range(N): + st = input() + if i > 0 : + if final != st[0]: + flag = 0 + elif st in word: + flag = 0 + else: + final = st[-1] + word += [st] + else: + final = st[-1] + word += [st] +if flag: + print(""Yes"") +else : + print(""No"")" +p03693,s995527054,Accepted,"# coding: utf-8 +r, g, b = map(int, input().split()) +if (g * 10 + b) % 4 == 0: + print('YES') +else: + print('NO')" +p03433,s564747995,Accepted,"n=int(input()) +a=int(input()) +if n%500 <=a: + print('Yes') +else: + print('No') " +p03778,s601670402,Accepted,"W, a, b = map(int, input().split()) +d = b - (a + W) if a < b else a - (b + W) +print(max(d, 0))" +p02630,s619775387,Accepted,"import sys +N = int(sys.stdin.readline().rstrip()) +A = list(map(int, sys.stdin.readline().rstrip().split())) +S = [0]*(10**5) + +ans = 0 +for n in range(N): + a = A[n] + S[a-1] += a + ans += a + +Q = int(sys.stdin.readline().rstrip()) + +for q in range(Q): + B, C = list(map(int, sys.stdin.readline().rstrip().split())) + up = C * S[B-1]//B + down = S[B-1] + S[C-1] += C * S[B-1]//B + S[B-1] = 0 + ans = ans + up - down + print(ans)" +p03565,s479481725,Wrong Answer,"s = input() +t = input() + +n = len(s) +m = len(t) + +if n < m: + print(""UNRESTORABLE"") + exit() + +for i in range(n-m, -1, -1): + if s[i] == t[0]: + if all(s[i+j] == ""?"" or s[i+j] == t[j] for j in range(1,m)): + s = s[:i]+t+s[:i+m] + print(s.replace(""?"", ""a"")) + exit() +print(""UNRESTORABLE"")" +p02597,s189288231,Accepted,"N = int(input()) +C = list(input()) + +r = C.count(""R"") + +cnt = 0 +for i in range(r): + if C[i] == ""W"": + cnt += 1 + +print(cnt)" +p02683,s895874781,Accepted,"import numpy as np +from itertools import product + +def readlines(n): + for _ in range(n): + yield list(map(int, input().split())) + +def main(): + N, M, X = map(int, input().split()) + + books = np.array(list(readlines(N))) + ans = np.inf + for bit in product([0, 1], repeat=N): + comb_sum = np.dot(np.array(bit), books) + if all(comb_sum[1:] >= X): + ans = min(ans, comb_sum[0]) + + if ans == np.inf: + print(-1) + else: + print(ans) + + + +main()" +p02744,s171010156,Accepted,"n = int(input()) +def dfs(i,s): + if i == n: + print(s) + return + ma = 0 + for j in s: + ma = max(ma,ord(j)) + for j in range(ma - 95): + dfs(i+1,s+chr(97+j)) + return +dfs(1,""a"")" +p02717,s282508152,Wrong Answer,"num = input() + +a = num[0] +b = num[2] +c = num[4] +d = int + +d = a +a = b +b = d +d = c +c = a +a = d +print(a,b,c)" +p04031,s407054299,Accepted,"N = int(input()) +a = list(map(int,input().split())) + + +ans = 1e10 +for i in range(-100,101): + tmp = 0 + for j in a: + tmp += (i-j)**2 + ans = min(ans,tmp) + +print(ans)" +p02712,s723571871,Accepted,"n = int(input()) +a=0 +for i in range(1, n+1): + if i%3!=0 and i%5!=0: + a=a+i +print(a)" +p03062,s051956597,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +a.sort() +minus = n +for i in range(n): + if a[i] >= 0: + s = i + break + +a = list(map(abs, a)) +a.sort() + +if minus % 2 == 0: + print(sum(a)) +else: + print(sum(a) - 2 * a[0]) +" +p02719,s202746798,Wrong Answer,"N,K = map(int,input().split()) + +def replace(N,K): + if(K == 1 or N==K): + return 0 + if(N0): + if (N-K<=0 and abs(N-K)b-a: + print(c-b-a) +else: + print(0)" +p03371,s398608362,Accepted,"from numba import njit + + +@njit +def solve(a, b, c, x, y): + ans = 10000000000000000 + for i in range(100000 + 1): + X = i * (2 * c) + max(0, x - i) * a + max(0, y - i) * b + ans = min(ans, X) + return ans + + +a, b, c, x, y = map(int, input().split()) +print(solve(a, b, c, x, y)) +" +p03565,s191158885,Accepted,"s, t = input(), input() + +if len(s) < len(t): + print(""UNRESTORABLE"") + exit() + +possible = [] +for i in range(len(s)-len(t)+1): + temp = s[i:i+len(t)] + flag = True + for a, b in zip(t, temp): + if not (a == b or b == ""?""): + flag = False + if flag: + + possible.append((s[:i] + t + s[i+len(t):]).replace(""?"", ""a"")) + +if len(possible) == 0: + print(""UNRESTORABLE"") +else: + print(sorted(possible)[0])" +p03059,s892549075,Wrong Answer,"print(sum(max(x-y,0)for x,y in zip(*[map(int,t.split())for t in open(0)][1:])))" +p02691,s952412585,Wrong Answer,"n = int(input()) +an = map(int,input().split()) +A = list(an) +y=0 +for i in range(1, n-1): + for j in range(i+1, n): + if(A[i] + A[j] == j -i): + y=y+1 +print(y)" +p03455,s225530754,Accepted,"a, b = map(int, input().split()) +c = a * b +if(c % 2 == 0): + print(""Even"") +else: + print(""Odd"")" +p03637,s334963583,Accepted,"n = int(input()) +a = map(int, input().split()) +b1, b2, b4 = 0, 0, 0 + +for i in a: + if i % 4 == 0: + b4 += 1 + elif i % 2 == 0: + b2 += 1 + else: + b1 += 1 +if b2: + if b1 <= b4: + print(""Yes"") + else: + print(""No"") +else: + if b1 <= b4 + 1: + print(""Yes"") + else: + print(""No"") +" +p03208,s822048077,Accepted,"def main(): + n, k = map(int, input().split()) + h = [int(input()) for _ in range(n)] + h = sorted(h) + ans = 10**9 + for i in range(n - k + 1): + ans = min(ans, h[i + k - 1] - h[i]) + + print(ans) + +if __name__ == '__main__': + main()" +p03282,s440054633,Accepted,"s = input() +k = int(input()) +for c in s[:k]: + if c != '1': + print(c) + break +else: + print(1)" +p02606,s073109952,Accepted,"a,b,c = map(int, input().split()) + +top = b // c +if a%c == 0: + bottom = a//c - 1 +else: + bottom = a//c + +print(top-bottom)" +p02843,s243104038,Accepted,"def I(): return int(input()) +################################################## +X = I() +dp = [0]*(X+1) #IndexとXを合わせた。dpのIndex範囲:0~X +dp[0] = 1 +for i in range(X+1): + if dp[i]: + for j in range(100,106): + if i+j<=X: #「out of lange」対策。 + dp[i+j] = 1 +print(dp[-1])" +p03319,s111758573,Accepted,"n,k = map(int,input().split()) +a = [int(i) for i in input().split()] +if (n-1)%(k-1)!=0: + ans = (n-1)//(k-1)+1 +else: + ans = (n-1)//(k-1) +print(ans)" +p03219,s819911943,Wrong Answer,"a,b = map(int,input().split()) + +print(int((a + b) / 2))" +p03075,s192411248,Wrong Answer,"mn, mx = float('inf'), -float('inf') +for i in range(5): + a = int(input()) + mn = min(mn, a) + mx = max(mx, a) +k = int(input()) +if mx - mn < k: + print("":("") +else: + print(""Yay!"")" +p02747,s243732364,Accepted,"s=input() +s=s.replace(""hi"","""").replace(""hihi"","""").replace(""hihihi"","""").replace(""hihihihi"","""").replace(""hihihihi"","""") +if s == """": + print(""Yes"") +else: + print(""No"")" +p02814,s927632416,Accepted,"import sys +import fractions +sys.setrecursionlimit(10**9) + +n,m=map(int,input().split()) +alist=list(map(int,input().split())) +alist=list(set(alist)) + +n=len(alist) + + +def sks(n): + global alist + if n == 1: + return alist[0] + else: + tmp=sks(n-1) + return tmp*alist[n-1]//fractions.gcd(tmp,alist[n-1]) + +sk = sks(n) +gomi=sk//2 + +for a in alist: + if (gomi-a//2)%a != 0: + print(0) + sys.exit() + +print(int((m+gomi)//sk)) + +" +p02912,s000899321,Wrong Answer,"import heapq as hq + +co = list(map(int,input().split())) +A = list(map(int,input().split())) +N = co[0] +M = co[1] +A = list(map(lambda x: x * (-1),A)) +hq.heapify(A) +for i in range(M): + tmp = hq.heappop(A) //2 + hq.heappush(A,tmp) +list(A) + +print(sum(A) * (-1))" +p03479,s068449109,Wrong Answer,"import math +x, y = map(int, input().split()) +print(math.ceil(math.log(y, 2) - math.log(x, 2)))" +p02595,s729302295,Wrong Answer,"import math +a = list(map(int,input().split())) +#N a[0] +#D a[1] +d = 0 +for i in range(a[0]): + b = list(map(int,input().split())) + c = math.sqrt(b[0]*b[0]+b[1]*b[1]) + if c >= a[1]: d=d+1 +print(d)" +p03944,s416968371,Accepted,"w, h, n = map(int, input().split()) +plots = [list(map(int, input().split())) for _ in range(n)] + +w_min, w_max, h_min, h_max = 0, w, 0, h + +for i in range(n): + if plots[i][2] == 1: + w_min = max(w_min, plots[i][0]) + elif plots[i][2] == 2: + w_max = min(w_max, plots[i][0]) + elif plots[i][2] == 3: + h_min = max(h_min, plots[i][1]) + else: + h_max = min(h_max, plots[i][1]) + +print(max(0, (w_max - w_min)) * max(0, (h_max - h_min))) +" +p02595,s487870283,Wrong Answer,"N, D = map(int, input().split("" "")) +count = 1 +for i in range(N): + X, Y = map(int, input().split("" "")) + if X^2 + Y^2 <= D^2 : + count += 1 +print(count)" +p02546,s266836193,Wrong Answer,"s = input() + +if s[-1] == s: + print(s+""es"") +else: + print(s+""s"")" +p03721,s441154444,Accepted,"n, k = list(map(int, input().split(' '))) +abn = [None] * n +for i in range(n): + abn[i] = list(map(int, input().split(' '))) + +abn = sorted(abn, key=lambda ab: ab[0]) + +ans = -1 +temp = 0 +i = 0 +while True: + if temp + abn[i][1] >= k: + ans = abn[i][0] + break + temp += abn[i][1] + i += 1 +print(ans) + +" +p02789,s927649490,Wrong Answer,"a = list(map(int,input().split())) +n,m = a +if n == m: + print(""YES"") +else: + print(""NO"")" +p02831,s640536602,Accepted,"a, b = list(map(int, input().split(' '))) + +def gcd(a, b): + def _gcd(a, b): + if b == 0: + return a + else: + return gcd(b, a % b) + if a > b: + return _gcd(a, b) + else: + return _gcd(b, a) + + +print(a // gcd(a, b) * b) +" +p03319,s453922477,Wrong Answer,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +from math import ceil + +n, k = map(int, readline().split()) +a = list(map(int, readline().split())) +index_1 = a.index(1) +ans = 0 +if index_1 != 0: + ans += 1 + if index_1 > 3: + ans += ceil((index_1 - 3) / 2) +if index_1 != (n - 1): + ans += 1 + if index_1 < (n - 3): + ans += ceil((n - index_1 - 3) / 2) +print(ans) +" +p02917,s881825287,Wrong Answer,"N=int(input()) +B=list(map(int,input().split())) +A=[B[0],B[-1]] +if N==3: + A.append(min(B)) + +for i in range(N-3): + + if max(B[i],B[i+1])<=B[i+2]: + A.append(max(B[i],B[i+1])) + else: + A.append(B[i+2]) +print(sum(A)) + " +p03377,s912006332,Accepted,"a, b, x = map(int, input().split()) +if a <= x and a + b >= x: + print(""YES"") +else: + print(""NO"") +" +p03605,s754892239,Accepted,"n = list(input()) +print('Yes' if n.count('9') >= 1 else 'No')" +p02630,s499137197,Accepted,"n = int(input()) +A = list(map(int, input().split())) +q = int(input()) + +S = sum(A) +dp = [0] * 100001 +for a in A: + dp[a] += 1 + + +for i in range(q): + a, b = map(int, input().split()) + dp[b] += dp[a] + S = S + (b - a) * dp[a] + print(S) + dp[a] = 0 +" +p03284,s880387756,Accepted,"n, k = map(int, input().split()) +print(0 if n % k == 0 else 1)" +p02711,s225686084,Wrong Answer,"n = list(map(str, input())) +ans = ""NO"" +for i in range(len(n)): + if n[i] ==""7"": + ans = ""YES"" + break +print(ans)" +p03910,s999379308,Accepted,"import sys + +N = int(sys.stdin.readline().strip()) + +A = [] +t = 0 +i = 1 +while t <= N: + t += i + A.append(i) + i += 1 +# print(A) +for i in A: + if t - N == i: + # print(""continue"", i) + continue + else: + print(i)" +p02582,s676514784,Accepted,"#!/usr/bin/env python3 +import sys +input = sys.stdin.readline + +s = input().rstrip() +if ""RRR"" in s: + print(3) +elif ""RR"" in s: + print(2) +elif ""R"" in s: + print(1) +else: + print(0)" +p04033,s895501493,Wrong Answer,"def resolve(): + a, b = map(int, input().split()) + if a >= 1: + print('Positive') + elif len(range(a, 0)) % 2 == 0: + print('Positive') + elif len(range(a, 0)) == 1: + print('Zero') + else: + print('Negative') + +resolve() +" +p03680,s233125909,Accepted,"n = int(input()) +a = [int(input()) for i in range(n)] +ans = -1 +x = a[0] +m = 0 +for i in range(n): + m += 1 + if x == 2: + ans = m + break + else: + x = a[x-1] +print(ans)" +p03131,s685157007,Wrong Answer,"k, a, b = map(int, input().split()) + +if k > a+1: + print(max((k-a-1) // 2 * (b-a) + b + (k-a-1) % 2, k+1)) +else: + print(k+1)" +p02681,s892532272,Wrong Answer,"s = input() +t = input() +ls= list(s) +lt = list(t) +if len(ls)+1 == len(lt) : + print(""Yes"") +else: + print(""No"") +" +p02718,s619670929,Wrong Answer,"n, m = map(int, input().split()) +a = list(map(int, input().split())) + +total = sum(a) + +count = 0 + +valid = total / (4 * m) + +for i in a: + if i > valid: + count += 1 + +if count > m: + print('Yes') +else: + print('No') +" +p03385,s282814830,Accepted,"s = input() +if ""a"" in s and ""b"" in s and ""c"" in s: + print(""Yes"") +else: + print(""No"")" +p03456,s727874133,Wrong Answer,"a,b = list(map(int, input().strip().split())) +c=100*a+b +d=(c**0.5)//1 +if d**2==c: + print(""Yes"") +else: + print(""No"")" +p02707,s658943960,Accepted,"import math +import time +from collections import defaultdict,deque +from sys import stdin,stdout +from bisect import bisect_left,bisect_right +n=int(input()) +count=[0]*n +a=list(map(int,stdin.readline().split())) +for i in a: + count[i-1]+=1 +for i in count: + print(i)" +p03038,s136269311,Wrong Answer,"n,m = map(int,input().split()) +A = list(map(int,input().split())) +for _ in range(m): + b,c = map(int,input().split()) + A.extend([b for _ in range(c)]) +A.sort(reverse = True) + +print(sum(A[:n+1]))" +p03673,s577203037,Accepted,"n,a=int(input()),list(map(int,input().split())) +b=[a[1::2][::-1]+a[::2],a[0::2][::-1]+a[1::2]][n%2] +print(*b,sep=' ')" +p02719,s804727248,Accepted,"import numpy as np +N, K = list(map(int,input().split())) +tmp = np.zeros(2) +tmp[0] = N % K +tmp[1] = -N % K +print(int(tmp.min()))" +p03126,s807894369,Wrong Answer,"def main(): + N, M = map(int, input().split()) + answer = [[0]*M for n in range(N)] + for i in range(N): + K, *A = map(int, input().split()) + for a in A: + answer[i][a-1] = 1 + count = 0 + for j in range(1, M): + same = 0 + for i in range(N): + same += answer[i][j] + if same == N: + count += 1 + print(count) +main()" +p02572,s319135043,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + + +B = 0 +C = 0 +for i in range(N): + B += A[i] + C += A[i]**2 + +ans = (((B**2) - C) / 2) % (10 ** 9 + 7) +print(int(ans))" +p02897,s419888714,Accepted,"N = int(input()) +print(-(-N // 2) / N)" +p02912,s960037460,Accepted,"import heapq +n, m = map(int, input().split()) +price = list(map(lambda x: -x, map(int, input().split()))) +heapq.heapify(price) + +while m >= 1: + a = (heapq.heappop(price) + 1) // 2 + heapq.heappush(price, a) + m -= 1 + +print(sum(price) * (-1))" +p02708,s324873942,Accepted,"N,K=map(int, input().split());print((N-K+2)*((N-K+1)*(N+2*K)+6)//6%(10**9+7))" +p02621,s034553292,Accepted,"a = int(input()) +print(a + a**2 + a**3)" +p03814,s175578107,Accepted,"import sys +input = sys.stdin.readline + +S = input().rstrip('\n') +print(S.rfind(""Z"") - S.find(""A"") + 1) +" +p03274,s948337979,Accepted,"import sys +input = sys.stdin.buffer.readline +#input = sys.stdin.readline + + +# mod=10**9+7 +# rstrip().decode('utf-8') +# map(int,input().split()) +#import numpy as np + +def main(): + n,k=map(int,input().split()) + x=list(map(int,input().split())) + + ans=10**18 + + for i in range(n): + try: + l=x[i] + r=x[i+k-1] + if r<0: + ans=min(ans,-l) + elif l>0: + ans=min(ans,r) + else: + ans=min(ans,r-l+min(-l,r)) + except: + pass + print(ans) + + + +if __name__ == ""__main__"": + main() +" +p03146,s339609219,Wrong Answer,"s = int(input()) + +t = set([]) +for i in range(1,10**6+1): + if s%2==0: + s//=2 + else: + s=s*3+1 + if s in t: + print(i) + break + else: + t.add(s)" +p02792,s864115330,Accepted,"def mainFunc(): + N = int(input()) + matrix = [[0 for i in range(10)] for i in range(10)] + for i in range(1, N + 1): + start = int(str(i)[0]) + end = int(str(i)[-1]) + matrix[start - 1][end - 1] += 1 + + ans = 0 + for i in range(10): + for j in range(10): + ans += matrix[i][j] * matrix[j][i] + + print(ans) + + +mainFunc()" +p03815,s940266307,Wrong Answer,"x = int(input()) + +print(-(-x*2//11))" +p02594,s131584535,Accepted,"N=int(input()) +if N>=30: + print(""Yes"") +else: + print(""No"")" +p02783,s496918951,Accepted,"h,a = map(int,input().split()) +if h%a==0: + print(h//a) +else: + print(h//a+1)" +p02791,s401006125,Wrong Answer,"a=int(input()) +p=list(map(int,input().split())) +k=1 +for i in range(a-1): + if p[i+1]= a: + ans += i + +print(ans) +" +p02596,s645280126,Accepted,"K = int(input()) + +if K % 2 == 0 or K % 5 == 0: + print(-1) + exit() + +s = '7' * len(str(K)) +if int(s) < K: + s += '7' +ans = len(s) +s = int(s) + +while True: + s = s % K + if s == 0: + print(ans) + exit() + s = s * 10 + 7 + ans += 1 +" +p03637,s249773353,Accepted,"n = int(input()) +a = [int(x) for x in input().split()] +four = 0 +two = 0 +el = 0 +for i in range(n): + if a[i] % 4 == 0: + four += 1 + elif a[i] % 2 == 0 : + two += 1 + else: + el += 1 + +if two == 0: + if four + 1 >= el: + print(""Yes"") + else: + print(""No"") +else: + if four >= el: + print(""Yes"") + else: + print(""No"") +" +p03723,s436926631,Accepted,"import numpy as np +p = np.array(list(map(int, input().split()))) + +cnt = 0 +mem = [] +flag = True +while (p % 2).sum() == 0: + a = p[1] // 2 + p[2] // 2 + b = p[0] // 2 + p[2] // 2 + c = p[1] // 2 + p[0] // 2 + + p = np.array([a, b, c]) + if (a,b,c) in mem: + flag = False + break + else: + mem.append((a,b,c)) + + cnt += 1 + +print(cnt if flag else -1) +" +p03131,s289295771,Accepted,"#みんなのプロコン2019-C +k,a,b = map(int,input().split()) + +if b - a <= 2: + print(k+1) +else: + r = k - (a-1) + ans = max(0,a + r//2*(b-a)+r%2) + print(ans)" +p02957,s937285812,Accepted,"a,b = map(int,input().split()) +k = 0 +if (a + b) % 2 == 0: + print(int((a+b)/2)) +else: + print('IMPOSSIBLE')" +p03103,s192076071,Accepted,"N, M = map(int, input().split()) +L = [] +ans = 0 +for i in range(N): + L.append(list(map(int,input().split()))) +L.sort() +for i in range(N): + if L[i][1]<=M: + M -= L[i][1] + ans += L[i][0]*L[i][1] + else: + ans += L[i][0]*M + break +print(ans)" +p03419,s709677199,Wrong Answer,"N,M=list(map(int, input().split())) +if N>1 and M>1: + print(N*M - (N-2)*(M-2)) +else: + print(N*M-2)" +p02584,s417990819,Accepted,"X,K,D=map(int,input().split()) +X=abs(X) +if X-K*D>=0: + print(X-K*D) +else: + d,m=divmod(X,D) + if (K-d)%2==0: + print(m) + else: + print(abs(m-D))" +p03000,s169865528,Accepted,"N, X = map(int, input().split()) +L = list(map(int, input().split())) + +d = 0 +ans = 1 + +for i in range(N): + d += L[i] + if d <= X: + ans += 1 + else: + break + +print(ans) +" +p03456,s963972287,Wrong Answer,"a, b = input().split() +ab = int(str(a)+str(b)) +ans = 'No' +for i in range(1, 101): + if i*i == ab: + ans='Yes' + break +print(ans)" +p03854,s126083529,Wrong Answer,"s = str(input()) +i = 0 +while(1): + if len(s) - i < 5: + break + if s[i:i+5] == ""erase"" or s[i:i+5] == ""dream"": + i += 5 + if s[i:i+2] == ""er"": + i += 2 + else: + print(""No"") + exit() +print(""YES"" if i == len(s) else ""NO"")" +p03495,s724731669,Wrong Answer,"from collections import Counter +N, K = map(int, input().split()) +A = Counter(input().split()) +print(A) + +print(sum(sorted(A.values(), reverse=True)[K:]))" +p03221,s436256984,Accepted,"N, M = map(int, input().split()) +list=[] +for i in range(M): + p, y =map(int, input().split()) + list.append([p, y, i]) +list.sort(key=lambda list:(list[0], list[1])) +list[0][1]=1 +for i in range(M-1): + if list[i][0] != list[i+1][0]: + list[i+1][1] = 1 + else: + list[i+1][1] = list[i][1] + 1 +list.sort(key=lambda list:(list[2])) +for i in range(M): + print(str(list[i][0]).zfill(6)+str(list[i][1]).zfill(6))" +p03548,s578857019,Wrong Answer,"a,b,c = map(int, input().split()) +print((a-c) // b)" +p02772,s944794869,Wrong Answer,"N = int(input()) + + +def read(): return list(map(int, input().split())) + + +data = read() +flag = True +for i in data: + if (i % 2 == 0): + if (i % 3 != 0 and i % 5 != 0): + flag = False + break +if (flag == True): + print('APPROVED') +else: + print('DEFINED') +" +p03087,s948188105,Accepted,"n, q = map(int,input().split()) +s = list(input()) +lr = [list(map(int,input().split())) for i in range(q)] +ans = [0] +x = 0 + +for i in range(n-1): + if s[i] == ""A"" and s[i+1] == ""C"": + x += 1 + ans.append(x) + +for i in lr: + l = i[0] + r = i[1] + print(ans[r-1] - ans[l-1]) +" +p02682,s804359250,Wrong Answer,"a,b,c,k = map(int,input().split()) + +print(a-(1*(k-a-b)))" +p02753,s610820325,Accepted,"s = input() +if ""AB"" in s or ""BA"" in s: + print(""Yes"") +else: + print(""No"")" +p03030,s282028200,Accepted,"_,*l=open(0).read().split() +[print(i + 1)for i in sorted(range(len(l)//2),key=lambda i:(l[i*2],-int(l[i*2+1])))]" +p02682,s445155618,Accepted,"a , b , c , k = map(int, input().split()) + +if a > k: + print(k) +elif a + b >= k: + print(a) +else: + print(2*a - k + b) " +p02793,s808026460,Accepted,"# 最小公倍数 +from fractions import gcd +from functools import reduce +def lcm (x, y): + return (x * y) // gcd(x, y) + +# 最小公倍数(リスト) +def lcm_list(numbers): + return reduce(lcm, numbers, 1) + +mod = 10 ** 9 + 7 +N = int(input()) +A = list(map(int, input().split())) + +lcm_A = lcm_list(A) + +ans = 0 +for i in range(N): + ans += lcm_A // A[i] + +print(ans % mod)" +p03220,s639337958,Accepted,"n = int(input()) +t, a = map(int, input().split()) +h = list(map(int, input().split())) +d_min = 99999 +ans = 0 +for i in range(n): + d = abs(t - a - h[i] * 0.006) + if d < d_min: + d_min = d + ans = i + 1 +print(ans) +" +p02627,s984341309,Accepted,"a = ord(input()) +if a>= ord(""a"") and a<=ord('z'): + print('a') +else: + print(""A"")" +p03309,s822671795,Accepted,"n=int(input()) +l=list(map(int,input().split())) + +l=[l[i]-(i+1) for i in range(n)] + +from statistics import median +z=int(median(l)) + +x=0 +for j in range(n): + x+=abs(l[j]-z) + +print(x)" +p04029,s762062278,Wrong Answer,"n = int(input()) + +answer = (n + 1) * n / 2 + +print(answer)" +p02708,s400250123,Wrong Answer,"import itertools +N=10**100 +n,k=map(int,input().split()) +li=[] +for i in range(n+2): + li.append(i) +counter=0 +for i in itertools.combinations(li,k): + counter+=1 +print(counter)" +p03433,s969444603,Wrong Answer,"N = input() +A = input() +y = N/500 +if y == 0: + print ""Yes"" +elif N-500*y < A: + print ""Yes"" +else: + print ""No"" + " +p02639,s842666814,Accepted,"x = list(map(int, input().split())) +print(15 - sum(x))" +p02819,s648162712,Wrong Answer,"def isPrime(x): + if x <= 1: return False + i = 2 + while i ** 2 <= x: + if x % i == 0: return True + i += 1 + +a = int(input()) +while True: + a += 1 + if isPrime(a): + print(a) + break" +p02553,s101775036,Wrong Answer,"a, b, c, d = map(int, input().split()) + +ab = a +cd = c +ab_flag = 0 +cd_flag = 0 + +if abs(a) < abs(b): + ab = b + ab_flag = 1 + +if abs(c) < abs(d): + cd = d + cd_flag = 1 + +ans = ab * cd + +if ans < 0: + if a > 0: + ans = a * d + elif c > 0: + ans = b * c + elif a > 0 and d > 0: + ans = b * d + elif c > 0 and b > 0: + ans = d * b + +print(str(ans)) +" +p03487,s988741150,Wrong Answer,"import collections +n = int(input()) + +a = list(map(int,input().split())) + +b = collections.Counter(a) + +ans = 0 + +for k,v in b.items(): + ans += min(v,abs(k-v)) + +print(ans) " +p02706,s182370994,Accepted,"n,m= list(map(int,input().split("" ""))) +arr = list(map(int,input().split("" ""))) +if(sum(arr)>n): + print(-1) +elif(sum(arr)==n): + print(0) +else: + print(n-sum(arr))" +p03061,s101722224,Wrong Answer,"def gcd(a, b): + while b > 0: + a, b = b, a % b + return a + + +n = int(input()) +a = list(map(int, input().strip().split())) +x = a[1] + +for i in range(2, n): + x = gcd(x, a[i]) + +res = x +x = a[0] + +for i in range(1, n-1): + y = x + for j in range(i+1, n): + y = gcd(y, a[j]) + if res < y: + res = y + x = gcd(x, a[i]) + +y = gcd(x, a[n-1]) +if res < y: + res = y +print(res) +" +p02947,s884375662,Wrong Answer,"import collections +N = int(input()) +lsS = [] +for i in range(N): + lsS.append(''.join(sorted(input()))) + +counter = collections.Counter(lsS) +n=0 +for i in counter.values(): + if i > 1: + n+=1 +print(n)" +p02983,s901635596,Accepted,"L,R=map(int,input().split()) +M=2019;l=L%M;r=R%M +print(0 if l>r or R-L>671 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1)))" +p03106,s891799584,Accepted,"a, b, k = map(int, input().split()) +c = 0 +ans = [] +if a > b: + c = b +else: + c = a + +for i in range(1, c+1): + if a % i == 0 and b % i == 0: + ans.append(i) + else: + continue + + +print(ans[-k])" +p02713,s026113965,Accepted,"from math import gcd +ans = 0 +k = int(input()) +for i in range(1, k+1): + for j in range(1, k+1): + GCD = gcd(i, j) + for l in range(1, k+1): + ans += gcd(GCD, l) +print(ans)" +p02657,s289630755,Wrong Answer,"n,*a=map(int,open(0).read().split()) +s=1 +if 0 in a: + print(0) + exit() +for i in a: + s*=i + if s > 10**18: + print(-1) + exit() +print(s)" +p02768,s695900920,Wrong Answer,"n, a, b = map(int, input().split()) +mod = 10**9 + 7 +a = min(a, n-a) +b = min(b, n-b) +com = [1] * (max(a, b) + 1) +for i in range(1,len(com)): + com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod +print(pow(2, n, mod) - 1 - com[a] - com[b])" +p02694,s006373470,Accepted,"import math +x=int(input()) +t=100 +count=0 +while t0): + answer+=math.floor(N) + N//=5 + + print(answer)" +p02775,s021801131,Accepted,"X = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0] +def solve(N): + N = [int(c) for c in N][::-1] + p = 0 + b = 0 + for i in range(len(N)): + c = N[i] + b + p += X[c] + if c == 5: + b = 0 if i == len(N)-1 or N[i+1] < 5 else 1 + else: + b = c > 5 + return p + b + +print(solve(input())) +" +p03699,s688699281,Accepted,"n = int(input()) +s = [int(input()) for i in range(n)] +s.sort() +score = sum(s) +score2 = score +c=0 +for i in range(n): + if score2%10 == 0: + score2 = score - s[i] + c+=1 + else: + break +if c==n: + score2=0 +print(score2)" +p03545,s467408542,Wrong Answer,"li = [] +s = input() +li2 = [] +for i in range(4): + li.append(int(s[i])) +n1 = 4 +def func(n, t): + if n == 1: + if t == li[0]: + return True + else: + return False + if func(n-1, t+li[n-1]): + li2.append('-') + return True + elif func(n-1, t-li[n-1]): + li2.append('+') + return True + else: + return False +if func(n1, 7): + print(""{0}{4}{1}{5}{2}{6}{3}=7"".format(li[0], li[1], li[2], li[3], li2[0], li2[1], li2[2])) + print(li2) +" +p03264,s354325530,Wrong Answer,"K = int(input()) +a = int(K / 2) +if K % 2 == 0: + print(a ** a) +else: + print(a * (a + 1)) + " +p03797,s523164999,Accepted,"n, m = list(map(int, input().split())) + +pieces = min(n, m//2) +if pieces == n: + pieces += (m-2*n)//4 +print(pieces) + " +p02783,s500135419,Wrong Answer,"H, A = map(int,input().split()) +print(H//A +1)" +p03241,s694661596,Accepted,"def make_divisors(n): + divisors=[] + for i in range(1,int(n**0.5)+1): + if n%i==0: + divisors.append(i) + if i!=n//i: + divisors.append(n//i) + divisors.sort() + return divisors + + +n,m=map(int,input().split()) +A=make_divisors(m) +ans=0 +for i in A: + if m%i==0 and n<=m//i: + ans=max(ans,i) +print(ans)" +p03360,s629277976,Wrong Answer,"a,b,c=map(int, input().split()) +k=int(input()) +s=max(a,b,c) +for i in range(k-1): + s*=2 +print(a+b+c+s)" +p02793,s537192468,Wrong Answer,"from fractions import gcd + +def lcm(a): + ans = a[0] + + for i in range(1,len(a)): + ans = (ans//gcd(ans,a[i]))*a[i] + + return ans + +N = int(input()) +A = tuple(map(int,input().split("" ""))) +g = lcm(A) +ans = 0 +mod = 10**9+7 + +for i in A: + ans += (g//i)%(mod) + +print(ans)" +p02768,s737192518,Wrong Answer,"a,b,c=map(int,input().split()) +print(7)" +p02642,s017215492,Accepted,"N = 1000001 +a = [0]* N +input() +for x in input().split(): + a[int(x)] += 1 +for i in range(1, N): + if a[i]: + for j in range(i + i, N, i): + a[j] = 0 +print(a.count(1))" +p02838,s240369041,Accepted,"N = int(input()) +A = list(map(int,input().split())) +mod = 10**9+7 +ans = 0 + +for bit in range(60): + m = 1 << bit + # bit桁目のbitが立っている時の数 + c = sum(a&m for a in A) >> bit + # bit桁目の1の合計 + ans += (c*(N-c))<= m else m+(m-1))" +p03317,s799171944,Wrong Answer,"def resolve(): + N, K = list(map(int, input().split("" ""))) + A = list(map(int, input().split("" ""))) + i = A.index(1) + import math + print(math.ceil(len(A[:i])/(K-1)) + math.ceil(len(A[i+1:])/(K-1))) + +if '__main__' == __name__: + resolve()" +p02866,s864220268,Accepted,"n = int(input()) +D = list(map(int, input().split())) + +if D[0] != 0: + print(0) + exit() + +A = [0]*n + +for i in range(n): + A[D[i]] += 1 + +#print(A) + +if A[0] != 1: + print(0) + exit() + +ans = 1 +mod = 998244353 +for i in range(1, n): + ans *= A[i-1]**A[i] + ans %= mod +print(ans) +" +p03262,s381566447,Accepted,"n,x=map(int,input().split()) +z=list(map(int,input().split())) +z.sort() +def gcd(a,b): + if b==0: + return a + return gcd(b,a%b) +ans=abs(x-z[0]) + +for i in range(n-1): + sa=z[i+1]-z[i] + ans=gcd(sa,ans) +print(ans) + +" +p04030,s412764661,Wrong Answer,"s = [] +for l in raw_input(): + if s == 'B': + if s:s.pop() + else: + s.append(l) +print ''.join(s) +" +p03076,s751056027,Accepted,"xs = [] +for x in range(5): + xs.append(int(input())) + + +def lastDigit(x): + return x % 10 + + +xs.sort(key=lastDigit) +# print(xs) +time = 0 +first = True +for x in xs: + if x % 10 == 0: + time += x + else: + if first: + time += x + first = False + else: + time += x + 10 - x % 10 +print(time) +" +p02712,s879330053,Wrong Answer,"import sys +input=sys.stdin.readline +N = int(input()) +ans = 0 +for i in range(1,N+1): + if i%3!=0 or i%5!=0: + print(i) +print(ans) +" +p03001,s430114125,Wrong Answer,"W, H, x, y = map(int, input().split()) +S = W*H/2 +can = 1 if x == W//2 and y == H//2 else 0 + +print(S, can)" +p02755,s198914082,Wrong Answer,"A,B = map(int,input().split()) +for i in range(101): + if i*0.08//1 == A and i*0.1//1 == B: + print(i) + exit() +print(-1)" +p03951,s591579816,Wrong Answer,"n = int(input()) +s = input() +t = input() +t_ = t[::-1] +if s==t: + print(n) +else: + c,d = 0,0 + for i in range(n): + if s[i]==t[i]: + c += 1 + if s[i]==t_[i]: + d += 1 + print(2*n - max(c, d))" +p02681,s967819992,Wrong Answer,"S=input() +T=input() +num=0 +for i in range(len(S)): + if S[i]==T[i]: + num+=1 + else: + print(""No"") +if num==len(S): + print(""Yes"") +else: + print(""No"") +" +p02935,s372843562,Wrong Answer,"import itertools +n=int(input()) +a=[int(i) for i in input().split()] + +suma=set() +for i in itertools.combinations(a,2): + s=sum(i) + suma.add(s/2) + +print(max(suma))" +p03075,s108871668,Accepted,"A = [] +for a in range(5): + A.append(int(input())) + +k = int(input()) + + +if max(A)-min(A) > k: + print(':(') +else: + print('Yay!') + +" +p04034,s660676450,Accepted,"import sys + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) + +N, M = lr() +ball = [1] * (N+1) # 1-indexed +red = [True if x == 1 else False for x in range(N+1)] # 1-indexed +for _ in range(M): + x, y = lr() + if red[x]: red[y] = True + ball[x] -= 1 + ball[y] += 1 + if ball[x] == 0: + red[x] = False + +answer = sum(red) +print(answer) +# 37" +p03760,s670132042,Accepted,"#abc058 b +o=input() +e=input() +ans="""" +for i in range(len(e)): + ans+=o[i] + ans+=e[i] +if len(o)-len(e)==1: + ans+=o[-1] +print(ans)" +p02711,s969929386,Wrong Answer,"N=input() + +flg=0 +for i in range(len(N)): + if N[i]=='7': + flg=1 + exit(0) +if flg!=0: + print('Yes') +else: + print('No') + " +p03910,s300736921,Accepted,"N=int(input()) +for i in range(1000000): + if (i*(i+1))//2>=N: + a=i + break +pointer=a +while N>0: + if N>=pointer: + print(pointer) + N-=pointer + pointer-=1 + else: + print(N) + N=0 +" +p02677,s671558092,Accepted,"A,B,H,M=map(int,input().split()) + +h=(H*60+M)/2 +m=6*M +import math + +pi=math.pi +theta=abs(h-m)*2*pi/360 + + +ans=A**2+B**2-2*A*B*math.cos(theta) + +print(ans**0.5)" +p03137,s770407873,Accepted,"n,m=map(int,input().split()) +x=list(map(int,input().split())) + +#n=2 +#m=5 +#x=[10 ,12,1,2,14] + +#n=3 +#m=7 +#x=[-10,-3,0,9,-100,2,17] + +x.sort() +dx=[] +if n>=m: + print(0) +else: +# print(x) + for i in range(len(x)-1): + dx.append(x[i+1]-x[i]) + dx.sort() + dxsum=sum(dx[0:m-n]) + print(dxsum) +" +p02547,s758354257,Accepted,"L=0 +N=int(input()) +for i in range(N): + a,b=map(int,input().split()) + if a==b: + L+=1 + if L==3: + print(""Yes"") + exit() + else: + L=0 +print(""No"")" +p02787,s375421840,Wrong Answer,"H,N=map(int,input().split()) + +A=[] +B=[] + +for i in range(N): + a,b=map(int,input().split()) + A.append(a) + B.append(b) + +DP=[1000000000]*(H+max(A)+1) + + +for i in range(N): + DP[A[i]]=B[i] + +for i in range(N): + for h in range(A[i],H+max(A)+1): + DP[h]=min(DP[h-A[i]]+B[i],DP[h]) + +print(min(DP[H:]))" +p02899,s024982303,Accepted,"import sys +input = lambda : sys.stdin.readline().rstrip() +sys.setrecursionlimit(max(1000, 10**9)) +write = lambda x: sys.stdout.write(x+""\n"") + + +n = int(input()) +a = list(map(int, input().split())) +aa = [(num,i) for i,num in enumerate(a)] +aa.sort() +write("" "".join(map(str, [item[1]+1 for item in aa])))" +p03338,s875916030,Wrong Answer,"n = int(input()) +s = input() + +ANS = [] +for i in range(n): + p = 0 + A = set(s[0:i]) + B = set(s[i-1:n+1]) + for j in A: + if j in B: + p += 1 + ANS.append(p) + + +print(max(ANS))" +p02773,s772170985,Wrong Answer,"N = int(input()) + +S = [] +for i in range(N): + S.append([input()][0]) + +S.sort() +S_set = list(set(S)) +ans = [["""" for i in range(2)] for i in range(len(S_set))] +n = 0 +for i in range(len(S_set)): + count = S.count(S_set[i]) + ans[i][0] = S_set[i] + ans[i][1] = count + if n < count: + n = count + +for i in range(len(S_set)): + if ans[i][1] == n: + print(ans[i][0])" +p02835,s765875658,Accepted,"A, B, C = map(int, input().split()) +if A + B + C <= 21: + print(""win"") +else: + print(""bust"")" +p03293,s242869521,Accepted,"S=input() +s=list(S) +T=input() +t=list(T) +for i in range(len(s)): + s.insert(0,s[-1]) + s.pop(-1) + if s==t: + print('Yes') + exit() + +print('No')" +p03146,s266397882,Wrong Answer,"import itertools +import math +s =int(input()) +a = s +count = 0 +while a >=4: + if a % 2 == 0: + a /= 2 + else: + a = 3 * a + 1 + count += 1 + +print(count+3)" +p03997,s242112215,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +S = ((a+b)*c)/2 +print(S)" +p03087,s130874122,Accepted,"from bisect import bisect_left +n, q = map(int, input().split()) +s = list(input()) +L = [] +for i in range(n - 1): + if s[i] == ""A"" and s[i + 1] == ""C"": + L.append(i) +ans = [] +for i in range(q): + l, r = map(int, input().split()) + l, r = l - 1, r - 1 + st = bisect_left(L, l) + fi = bisect_left(L, r) + ans.append(fi - st) + +for i in ans: + print(i)" +p02678,s228955583,Wrong Answer,"import sys +import networkx as nx +n,m=map(int,input().split()) +g = nx.Graph() +l = sys.stdin.readlines() +for x in l: + g.add_edge(int(x.split(' ')[0]), int(x.split(' ')[1].strip()))" +p02783,s366177027,Wrong Answer,"a = list(map(int,input().split())) + +for i in range(10**4): + if a[1]*i > a[0]: + break + +print(i)" +p03944,s950095271,Wrong Answer,"w, h, n = [int(i) for i in input().split()] +x_list = [] +y_list = [] +a_list = [] +left = 0 +right = w +upper = h +lower = 0 + +for i in range(n): + x, y, a = [int(k) for k in input().split()] + if a == 1: + left = x + elif a == 2: + right = x + elif a == 3: + lower = y + elif a == 4: + upper = y + +S = (right-left)*(upper-lower) +if right-left < 0 or upper-lower < 0: + print(0) +else: + print(S) +" +p02873,s624499516,Accepted,"S = input() +a = [0]*(len(S)+1) + +for i in range(len(S)): + if S[i] is '<': + a[i+1] = max(a[i+1], a[i]+1) + + +for i in range(1, len(S)+1): + if S[-i] is '>': + a[-(i+1)] = max(a[-(i+1)], a[-i]+1) + +print(sum(a))" +p02724,s190253447,Accepted,"# B - Golden Coins + +# X +X = int(input()) + +kiri_happy = X // 500 +inaho_happy = (X - (500 * kiri_happy)) // 5 + +answer = (kiri_happy * 1000) + (inaho_happy * 5) + +print(answer) +" +p03943,s743541243,Accepted,"# 入力 +a, b, c = map(int, input().split()) + +# 処理 +if a + b == c or b + c == a or c + a == b: + print('Yes') + +else: + print('No') + + +# 出力 + +" +p03274,s263410529,Accepted,"N, K = map(int, input().split()) +X = list(map(int, input().split())) + +a = 10**10 +for left,x in enumerate(X): + right = left + K - 1 + if right == N: + break + left_to_right = abs(X[left])+abs(X[right]-X[left]) + right_to_left = abs(X[right])+abs(X[right]-X[left]) + m = min(left_to_right, right_to_left) + if a > m: + a = m + +print(a) + +" +p03433,s154395677,Accepted,"N = int(input()) +A = int(input()) + +remain = N % 500 + +if remain <= A: + print('Yes') +else: + print('No') +" +p03817,s574931356,Accepted,"x = int(input()) + +ans = (x // 11) * 2 +b = x % 11 +if b > 0: + ans += 1 + if b > 6: + ans += 1 + +print(ans) +" +p02900,s553777740,Wrong Answer,"a, b = map(int, input().split()) + +def gcd(a, b): + if b == 0: + return a + else: + return gcd(b, a%b) + +def cal(c): + d = [1] + for i in range(2, c): + if c%i == 0: + d.append(i) + c //= i + return d + +c = gcd(a, b) +d = cal(c) +print(len(d)) +" +p03264,s843702569,Accepted,"k = int(input()) + +e = k // 2 +o = k - e +ans = e * o +print(ans) +" +p02582,s352191832,Accepted,"ans = 0 +tmp = 0 +for s in input(): + if s == 'R': + tmp += 1 + else: + ans = max(ans,tmp) + tmp = 0 +print(max(ans,tmp))" +p02814,s795504681,Accepted,"import sys + +def gcd(x,y): + while y: + x,y = y , x % y + return x + +n,m=map(int,input().split()) +a=tuple(map(int,input().split())) + +lcm = 1 +for i in a: + lcm = lcm * i // gcd(lcm,i) +for i in a: + if (lcm//i)%2 == 0: + print(0) + sys.exit() +print((m+lcm//2)//lcm)" +p03351,s006255981,Wrong Answer,"a, b, c, d = map(int, input().split()) + +if abs(c-a) > d: + print('Yes') +elif abs(b-a) > d and abs(c-b) > d: + print('Yes') +else: + print('No')" +p03438,s502294262,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +cnt = 0 +for a, b in zip(A, B): + if a > b: + cnt -= a - b + if a < b: + cnt += (b - a) // 2 + +if cnt < 0: + print(""No"") +else: + print(""Yes"")" +p02556,s116687308,Wrong Answer,"N = int(input()) +A = 0 +Xmin = Ymin = 1e9 + 5 +Xmax = Ymax = 0 +for _ in range(N): + x, y = map(int, input().split()) + X = x + y + Y = abs(x - y) + Xmin = min(Xmin, X) + Xmax = max(Xmax, X) + Ymin = min(Ymin, Y) + Ymax = max(Ymax, Y) +if Xmin == 1e9 + 5: + Xmin = Xmax +if Ymin == 1e9 + 5: + Ymin = Ymax +Z = max(Xmax - Xmin, Ymax - Ymin) +print(Z)" +p03071,s476264119,Accepted,"A, B = map(int, input().split()) + +ans = max(A + max(A-1, B), B + max(A, B-1)) + +print(ans)" +p03493,s483334594,Accepted,"print(input().count(""1""))" +p02720,s732329716,Accepted,"import queue +k = int(input()) +q = queue.Queue() +cnt = 0 +for i in range(1,10): + q.put(i) +while True: + a = q.get() + cnt += 1 + if cnt == k: + print(a) + break + else: + s = a%10 + if s != 0: + q.put(10*a + s-1) + q.put(10*a + s) + if s != 9: + q.put(10*a + s+1)" +p02897,s820871748,Wrong Answer,"N=int(input()) +if N % 2 == 0: + print((N/2)/N) +else: + print((N+1/2)/N)" +p03723,s066475267,Accepted,"a, b, c = map(int, input().split()) + +if a % 2 == 1 or b % 2 == 1 or c % 2 == 1: + print(0) +elif a == b == c: + print(-1) +else: + num = 0 + while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0): + a, b, c = (b+c)/2, (a+c)/2, (a+b)/2 + num += 1 + print(num)" +p03239,s015411602,Accepted,"import itertools +import math +import fractions +import functools +n, t = map(int, input().split()) +pair = [] +for i in range(n): + ci, ti = map(int, input().split()) + pair.append([ci, ti]) + +c = 1001 +for i in range(n): + if pair[i][1] <= t: + c = min(c,pair[i][0]) + +if c == 1001: + print(""TLE"") +else: print(c)" +p03659,s207835964,Accepted,"n = int(input()) +a = list(map(int,input().split())) +s,temp = [],0 +for i in range(n): + temp += a[i] + s.append(temp) +sn,mi = s[n-1],2000000001 +for i in range(n-1): + snuke = s[i] + arai = sn-s[i] + if abs(snuke-arai)0 else ""None"") +" +p02700,s015788423,Accepted,"def main(): + abcd = list(map(int, input().split())) + aok = (abcd[2]-1) // abcd[1] + tac = (abcd[0]-1) // abcd[3] + print('Yes' if tac >= aok else 'No') + +if __name__ == '__main__': + main()" +p02695,s853088197,Wrong Answer,"from itertools import combinations + +n, m, q = map(int,input().split()) +a = [list(map(int,input().split())) for _ in range(q)] + +temp = list(combinations([i for i in range(1,m+1)],n)) + + +ans = 0 + +for a_temp in temp: + ans_temp = 0 + for i in range(q): + if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]: + ans_temp += a[i][3] + if ans < ans_temp: + ans = ans_temp +print(ans)" +p03645,s900475428,Wrong Answer,"n,m = map(int, input().split()) +from_start = [] +to_end = [] + +for _ in range(m): + temp = [] + temp = list(map(int, input().split())) + if temp[0]==1: + from_start.append(temp[1]) + elif temp[1]==n: + to_end.append(temp[0]) +else: + print(from_start) + print(to_end) + for i in from_start: + if i in to_end: + print('POSSIBLE') + break + else: + print('IMPOSSIBLE') + " +p03767,s324995451,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +num = 0 +a.sort(reverse=True) +i = 1 +j = 0 +while j < n: + num += a[i] + i += 2 + j += 1 +print(num)" +p03076,s688661680,Accepted,"a = [int(input()) for _ in range(5)] + +maxv = 0 +b = 4 +for i in range(5): + if maxv < 10 - (a[i]%10) and a[i] % 10 != 0: + maxv, b = 10 - (a[i]%10), i + +ans = 0 + +for i in range(5): + if i != b: + ans += a[i] + + if ans % 10 != 0: + for j in range(10): + ans += 1 + if ans % 10 == 0: + break + +ans += a[b] +print(ans)" +p02748,s692474861,Accepted,"a,b,m = map(int,input().split()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +xyc = [list(map(int,input().split())) for i in range(m)] + +a_m = min(a) +b_m = min(b) +ans = a_m + b_m + +for i in range(m): + a_i = xyc[i][0] - 1 + b_i = xyc[i][1] - 1 + c_i = xyc[i][2] + pri = a[a_i] + b[b_i] - c_i + ans = min(ans,pri) + +print(ans) + " +p03136,s107529121,Accepted,"n=int(input()) +l=sorted(map(int,input().split()))[::-1] + +if l[0]=10: + print(-1) +else: + print(a*b)" +p02702,s676729702,Wrong Answer,"# -*- coding: utf-8 -*- + +def count_all(text, part): + return sum(text.startswith(part, i) for i in range(len(text))) + +S = input() +I = 2019 +l = [] +count = 0 + +while I < 200000: + count += count_all(S,str(I)) + I += 2019 + +print(count)" +p02661,s293666003,Accepted,"import statistics +N = int(input()) +AB = [map(int, input().split()) for _ in range(N)] +A,B = [list(i) for i in zip(*AB)] +if N%2 == 1: + low_med = statistics.median(A) + high_med = statistics.median(B) + print(high_med - low_med +1) +else: + low_med = statistics.median(A) + high_med = statistics.median(B) + print(int(2 * (high_med - low_med) +1))" +p03474,s647818047,Wrong Answer,"a, b = map(int, input().split()) +s = input() +if len(s) >= 0 and len(s) <= 9: + if s[a] ==""-"" and s.count(""-"") ==1: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p02699,s868100486,Wrong Answer,"s, w = map(int, input().split()) + +if s > s: + print('safe') +if s < w: + print('unsafe')" +p03286,s213890868,Wrong Answer,"n=int(input()) +x="""" +while n!=0: + x= x+str(n%2) + n=-(n//2) + +if x=="""": + print(0) +else: + print(x) +" +p02813,s778840857,Wrong Answer,"from itertools import permutations + +N = int(input()) + +p = ''.join(input().split()) +q = ''.join(input().split()) + +l = list(range(1, N+1)) +l = sorted(permutations(l)) + +p_idx = 0 +q_idx = 0 +for n, i in enumerate(l): + if ''.join(map(str, i)) == p: + p_idx = n + elif ''.join(map(str, i)) == q: + q_idx = n +print(abs(p_idx-q_idx))" +p03017,s439571603,Accepted,"n,a,b,c,d=map(int,input().split()) +s=input() +if c k: + print(':(') + exit() + +print('Yay!')" +p02665,s719183871,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) + +able = True +count = 0 +if A[0] > 1: + able = False +else: + bb = 1-A[0] + count += 1 + for a in A[1:]: + print(count) + b = 2*bb - a + if 0 <= b and b <= 2*bb: + count += 2*bb + bb = b + else: + able = False + break +if able: + print(count) +else: + print(-1)" +p03011,s887173852,Accepted,"n = list(map(int, input().split())) +n.sort() +print(n[0] + n[1])" +p03469,s595592302,Accepted,"S = list(input()) +S[3] = ""8"" +print("""".join(S)) +" +p02952,s551069253,Accepted,"n = int(input()) + +def d(k): + s = 0 + while k > 0: + k //= 10 + s += 1 + return s + +dn = d(n) +a = 0 +for i in range(1, dn + 1): + if i % 2 == 1: + if n < 10 ** i: + a += n - 10**(i- 1) + 1 + else: + a += 10 ** i - 10 ** (i - 1) +print(a)" +p03352,s629802603,Accepted,"#!/usr/bin/env python3 + +def solve(x): + if x == 1: + return 1 + f = 2 + l = [1] + while f * f <= x: + d = f + while d <= x: + l.append(d) + d *= f + f += 1 + return max(l) + + + +def main(): + X = int(input()) + print(solve(X)) + return + +if __name__ == '__main__': + main() +" +p03136,s809005770,Accepted,"n = int(input()) +l = list(map(int, input().split())) +l.sort() +if l[-1] < sum(l[:-1]): + print('Yes') +else: + print('No')" +p02882,s138777989,Accepted,"import math +a,b,x = map(int,input().split()) +S = a*a*b +if 2*x>=S: + tmp = 2 * (S - x) / (a**3) +else: + tmp = a * b * b / (2 * x) +print(math.degrees(math.atan(tmp))) +" +p02717,s361637913,Wrong Answer,"x = 5 +y = 10 +temp = x +x = y +y = temp +print('The value of x after swapping: {}'.format(x)) +print('The value of y after swapping: {}'.format(y))" +p03221,s596330147,Accepted,"import bisect + +n,m=map(int,input().split()) + +x=[list(map(int,input().split())) for i in range(m)] + +lst=[[] for i in range(n)] + +for i,v in x: + lst[i-1].append(v) + +for i in range(n): + lst[i].sort() + +for i,v in x: + z=bisect.bisect_left(lst[i-1],v)+1 + + print('0'*(6-len(str(i)))+str(i)+'0'*(6-len(str(z)))+str(z))" +p03605,s311098689,Wrong Answer,"N = input() +if N in ""9"": + print(""Yes"") +else: + print(""No"")" +p03486,s152869637,Accepted,"s=sorted(list(input())) +t=sorted(list(input()),reverse=True) + +if s= c: + print(""Yes"") +else: + print(""No"")" +p03760,s947257749,Wrong Answer,"o = str(input()) +e = str(input()) +print(*[a + b for a, b in zip(o, e)], sep="""")" +p04044,s449742326,Accepted,"N,L = map(int,input().split()) +S = [input() for i in range(N)] +S = sorted(S) +for n in range(N): + tmp = S.pop(0) + print(tmp,end = """")" +p04011,s495476686,Accepted,"n,k,x,y=(int(input()) for i in range(4)) +print(n*x-(x-y)*max(n-k, 0))" +p02860,s580826609,Wrong Answer,"n=int(input()) +s=input() +if n==0 or n==1: + print(""No"") + exit() +a=s[0:len(s)//2] +b=s[len(s)//2 if len(s)%2 == 0 else ((len(s)//2)+1):] + +if a==b: + print(""Yes"") +else: + print(""No"")" +p02717,s347086043,Wrong Answer,"x, y, z = map(int, input().split()) +print(z, y, x) +" +p03721,s032618605,Wrong Answer,"import sys + +N, K = map(int, input().split()) +arr = [] +su = 0 +for n in range(N): + a, b = map(int, input().split()) + su += b + if su >= K: + print(a) + sys.exit() +" +p02748,s314905985,Accepted,"a, b, m = map(int, input().split()) + +aa = list(map(int, input().split())) +bb = list(map(int, input().split())) + +mm = list() +for ii in range(0,m): + mm.append(list(map(int, input().split()))) + +prices = list() + +prices.append(int(min(aa)) + int(min(bb))) + +for ml in mm: + prices.append(aa[ml[0]-1] + bb[ml[1]-1] - ml[2]) + +print(min(prices)) +" +p02777,s503669025,Accepted,"s, t = input().split("" "") +a, b = (int(x) for x in input().split("" "")) +u = input() + +if s==u: + print(a-1, b) +else: + print(a, b-1) " +p02881,s864097227,Wrong Answer,"import math +N = int(input()) +a = 1 +b = 1 +ran = int(math.floor(math.sqrt(N))) +m = 1 +for i in range(1,ran): + if N%i == 0: + if i > m: + m = i +print(m + N/m -2)" +p03289,s848734976,Wrong Answer,"# coding: utf-8 +# Your code here! +import sys +s = str(input()) + +ch = s[0]+s[2] + +test_st = s[1]+s[3:] +#print(test_st) +if ch == 'AC' and 'C' not in test_st: + print('AC') +else: + print('WA') +" +p02831,s187158001,Accepted,"A, B = map(int, input().split()) + +s = A +while s % B != 0: + s += A +print(s) +" +p02689,s055756267,Accepted,"n,m = map(int, input().split()) +H = list(map(int, input().split())) +d = {i:[] for i in range(1, n+1)} + +for _ in range(m): + a,b = map(int, input().split()) + d[a].append(b) + d[b].append(a) + +count = 0 + +for k,v in d.items(): + if not v: + count += 1 + else: + flg = True + for v_i in v: + if H[k-1]<=H[v_i-1]: + flg = False + break + if flg: + count += 1 + +print(count)" +p02838,s359393609,Accepted,"import numpy as np +n = int(input()) +a = np.array(list(map(int,input().split()))) +bit = [] +ans = 0 +mod = 10**9+7 +for i in range(60): + bit.append(np.count_nonzero(a&1)) + a >>= 1 +for i in range(60): + ans += ((n-bit[i])*bit[i]) * pow(2,i,mod) + ans %= mod +print(ans)" +p03103,s778520260,Accepted,"n,m = map(int,input().split()) +L = [list(map(int,input().split())) for _ in range(n)] +L = sorted(L, key=lambda x: x[0]) +limit = m +ans = 0 +for i in range(n): + if limit <= 0: break + ans += min(limit, L[i][1]) * L[i][0] + limit -= L[i][1] +print(ans)" +p02724,s620271275,Wrong Answer,"import math +x = input() +if len(x) > 3: + y = int(x)/100 + y = math.floor(y) + a = (y * 200) + (int(x[-2])*10) + print(a) +elif len(x) == 1: + print(0)" +p03944,s285725496,Accepted,"w,h,n=map(int,input().split()) +l,r=0,w +d,u=0,h +for i in range(n): + x,y,a=map(int,input().split()) + if a==2: + r=min(r,x) + elif a==1: + l=max(l,x) + elif a==4: + u=min(u,y) + else: + d=max(d,y) +print(0 if r<=l or u<=d else (r-l)*(u-d))" +p03705,s737282994,Accepted,"n,a,b = map(int,input().split()) +if a > b:ans = 0 +elif n == 1: + if a == b:ans = 1 + else:ans = 0 +else: + ans = (b-a)*(n-2)+1 +print(ans) +" +p03997,s711037987,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) +print((a + b) * h / 2)" +p03779,s345349304,Accepted,"import sys + +x = int(sys.stdin.readline().rstrip()) + +def main(): + n = int((x * 2) ** 0.5) + res = n if (1 + n) * n // 2 >= x else n + 1 + print(res) + +if __name__ == '__main__': + main()" +p02711,s578617536,Wrong Answer,"from random import random +print(['Yes', 'No'][random() < 0.5])" +p03407,s737766439,Accepted,"a,b,c=map(int,input().split()) +print(""Yes"" if a+b>=c else ""No"") " +p03779,s610275576,Wrong Answer,"import numpy as np + +x = int(input()) + +t = (-1 + np.sqrt(1 + 8 * x)) // 2 +t = int(t) + +print(t + 1)" +p03103,s189065830,Accepted,"n,m=map(int,input().split()) +array=[] +cost=0 +for i in range(n): + a,b=map(int,input().split()) + array.append([a,b]) +array.sort() +for i in array: + if m<=i[1]: + cost+=i[0]*m + break + else: + cost+=i[0]*i[1] + m-=i[1] + +print(cost)" +p04034,s941941458,Wrong Answer,"n,m=map(int,input().split()) +arr=[list(map(int,input().split())) for _ in range(m)] +count=[1]*(n+1) +s=set() +s.add(1) +for a,b in arr: + if a in s: + s.add(b) + count[b]+=1 + count[a]-=1 + if count[a]==0: + s.discard(a) +print(len(s))" +p02802,s851788822,Wrong Answer,"n,k=map(int,input().split()) +c=[] +d=[] +co=0 +wr=0 +for i in range(k): + a,b=map(str,input().split()) + c.append(int(a)) + if b=='AC': + d.append(a) + co+=1 + if b=='WA' and a not in d: + wr+=1 +print(co,wr) +" +p03086,s378455409,Wrong Answer,"s=input() +l=len(s) +ans=0 +for i in range(l): + if s[i] in ['A','T','G','C']: + ans+=1 +print(ans)" +p03723,s140253199,Accepted,"def main(): + a, b, c = map(int, input().split()) + if a%2 == 1 or b%2 == 1 or c%2 == 1: + print(""0"") + else: + if a == b == c: + print(""-1"") + else: + ans = 0 + while a%2 == 0 and b%2 == 0 and c%2 == 0: + a, b, c = (b+c)//2, (a+c)//2, (a+b)//2 + ans += 1 + print(ans) + +if __name__ == ""__main__"": + main()" +p02622,s491615951,Wrong Answer,"a = input() +b = input() +ans = 0 +for i in range(len(a)): + if a[i] == b[i]: + ans += 1 +print(ans)" +p02860,s727693891,Wrong Answer,"n = int(input()) +s = input() + +ans = ""Yes"" if (n & 1) and s[0:int(n / 2)] == s[int(n / 2):n] else ""No"" +print(ans) +" +p03042,s067002039,Wrong Answer,"n=input() +a=int(n[0:2]) +b=int(n[2:4]) +if a<13 and b<13: + print('AMBIGUOUS') +elif a>0 and a<13: + print('MMYY') +elif 0= h[i+1]: + a+=1 + else: + b.append(a) + a=0 +b.append(a) +print(max(b))" +p03555,s353824951,Wrong Answer,"a = input() +b = input() + +b_reverse = a[::-1] + +if a == b_reverse: + print('YES') +else: + print('NO')" +p02854,s149663300,Accepted,"n = int(input()) +a = list(map(int,input().split())) +s = sum(a) +x = 0 +m = s +for i in range(n): + x += a[i] + m = min(m, abs(s-x*2)) +print(m) +" +p03013,s695998770,Accepted,"n, m = map(int, input().split()) +aaa = [0] * (n + 1) +for _ in range(m): + aaa[int(input())] = 1 +dp = [0] * (n + 1) +dp[0] = 1 +dp[1] = 0 if aaa[1] == 1 else 1 +for i in range(2, n + 1): + if aaa[i] == 1: + dp[i] = 0 + else: + dp[i] = dp[i - 1] + dp[i - 2] + +print(dp[n] % 1000000007)" +p02778,s841473651,Accepted,"s = str(input()) +for i in range(len(s)): + print(""x"",end = '') +" +p03285,s998745409,Accepted,"def main(): + n = int(input()) + m = 100 // 7 + 1 + flag = False + for i in range(m): + for j in range(m): + if n == i * 7 + j * 4: + flag = True + if flag: + print('Yes') + break + else: + continue + break + if not flag: + print('No') +if __name__ == '__main__': + main()" +p02842,s591701603,Wrong Answer,"import sys +N=int(input()) +a=N//1.08 +c=a+1 +d=a-1 +b=a*1.08 +b=int(b) +if b==N: + print(a) + sys.exit() +elif int(c*1.08)==N: + print(c) +elif int(d*1.08)==N: + print(d)" +p03785,s985383191,Accepted,"n,c,k=map(int,input().split()) +t=[int(input()) for _ in range(n)] +t.sort() +cnt,now=0,0 +while now=n: + break + if t[i+1+a]>temp: + break + now+=1 + now+=1 + cnt+=1 +print(cnt) " +p02748,s072408973,Wrong Answer,"A, B, M = map(int, input().split()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +x = [0] * M +y = [0] * M +c = [0] * M + +min = 99999999 + +for i in range(M): + x[i], y[i], c[i] = map(int, input().split()) + cost = a[x[i] - 1] + b[y[i] - 1] - c[i] + if cost < min: + min = cost + +min = 99999999 + +for i in range(A): + for j in range(B): + cost = a[i] + b[j] + if cost < min: + min = cost + +print(min)" +p03243,s885528832,Accepted,"n = int(input()) + +for i in range(n, 1001): + if i % 111 == 0: + ans = i + break +print(ans) +" +p03103,s722965305,Accepted,"# coding: utf-8 +# Your code here! +N,M=map(int,input().split()) + +shop=[] + +for _ in range(N): + A,B=map(int,input().split()) + shop.append([A,B]) + +shop.sort(key=lambda x:x[0]) + +ans=0 +for money, num in shop: + if M<=num: + ans+=money*M + break + else: + ans+=money*num + M-=num + +print(ans) +" +p02859,s751554208,Accepted,"r=int(input()) +print(int(r**2))" +p03043,s833498178,Wrong Answer,"N,K=map(int,input().split()) +ans=0 +for i in range(1,N+1): + p=i + c=0 + while p<=K: + p*=2 + c+=1 + ans+=1/2**c +print(ans/N)" +p02971,s861696732,Wrong Answer,"n = int(input()) +l = [] +for i in range(n): + l.append(int(input())) +m = max(l) +ans = [m]*n +if len(set(l)) == 1: + [print(i) for i in ans] +else: + x = sorted(set(l))[-2] + a = [index for index, value in enumerate(l) if value == m] + for i in a: + ans[i] = x + [print(i) for i in ans] +" +p03487,s079745544,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + n = int(input()) + a = list(map(int, readline().split())) + + from collections import Counter + + counter = Counter(a) + ans = 0 + + for num, cnt in counter.items(): + if cnt > num: + ans += (cnt-num) + if cnt < num: + ans += cnt + + print(ans) + +if __name__ == '__main__': + main() +" +p02897,s301787099,Accepted,"def solve(): + N = int(input()) + if N % 2 == 0: + return 0.5 + return ((N+1) // 2) / N + +print(solve())" +p02729,s508661284,Wrong Answer,"s = input() +n = len(s) +t = s[:n // 2] +k = s[-n//2+1:] +if s == s[::-1] and t == t[::-1]: + print('Yes') +else: + print('No')" +p03680,s966478422,Wrong Answer,"n = int(input()) +l = [int(input()) for _ in range(n)] +m = [int(__) for __ in range(1,n+1)] + +x = l[0] +y = 1 +for i in range(10**5): + y += 1 + z = m.index(x) + if l[z] == 2: + break + else: + x = l[z] + +if y == 100001: + print('-1') +else: + print(y)" +p02832,s545424801,Accepted,"n = int(input()) +a = list(map(int, input().split())) +find_num = 1 +break_num = 0 +for i in range(n): + if a[i] == find_num: + find_num += 1 + else: + break_num += 1 +if break_num == n: + print(-1) +else: + print(break_num) +" +p02640,s137177102,Accepted,"x,y=map(int,input().split()) + +if (x*2) <= y <= (x*4) and y%2 ==0: + print('Yes') +else: + print('No') +" +p03854,s842723455,Wrong Answer,"s = input() +s = s.replace(""erase"", """") +s = s.replace(""eraser"", """") +s = s.replace(""dreamer"", """") +s = s.replace(""dream"", """") +if len(s) == 0: + print(""YES"") +else: + print(""NO"")" +p02642,s816256691,Accepted,"n = int(input()) +a = list(map(int,input().split())) +a.sort() + +n_max = 10**6+1 + +ans = 0 +flag = [True] * (n_max) +for i in range(n-1): + if(not flag[a[i]]): + continue + + if(a[i]!=a[i+1]): + ans += 1 + for j in range(a[i],n_max,a[i]): + flag[j] = False + +ans += flag[a[-1]]*1 +print(ans)" +p03555,s548230759,Accepted,"rli,cli=list(input()),list(input()) +if rli[0]==cli[2] and rli[1]==cli[1] and rli[2]==cli[0]: + print(""YES"") +else: + print(""NO"")" +p03208,s874192671,Accepted,"N, K = map(int, input().split()) +h = [int(input()) for _ in range(N)] +h.sort() +ans = max(h) +for i in range(N-K+1): + if h[i+K-1]-h[i] < ans: + ans = h[i+K-1]-h[i] +print(ans) +" +p03543,s547316564,Wrong Answer,"n = list(input()) +x = 0 +y = 1 +for i in n: + if y < 4: + if i == n[y]: + x += 1 + y += 1 + else: + x += 0 + y += 1 +if x >= 2: + print('Yes') +else: + print('No')" +p03910,s965254916,Accepted,"N = int(input()) + +s = 0 + +i = 1 +while s <= N: + s += i + i += 1 + +l = list(range(1, i)) +del l[l.index(s-N)] +print(*l)" +p03261,s803065509,Wrong Answer,"n= int(input()) +w=[list(input()) for i in range(n)] +cnt=0 +for k in range(n-1): + if w[[k][-1]] == w[[k+1][0]] and len(w) == len(set(w)): + cnt+=1 + +if cnt==n-1: + print('Yes') +else: + print('No') + " +p03127,s657307437,Wrong Answer,"n, *a = map(int, open(0).read().split()) +a.sort() +x, y = a[0], a[1] +while y%x: + y -= y//x*x + x, y = y, x +print(x)" +p02988,s673426891,Wrong Answer,"n = int(input()) +pl = list(map(int, input().split())) + +dic = {} +for i in range(1, n+1): + dic.setdefault(i, 0) + +for i in range(n-2): + tmp = sorted(pl[i:i+3]) + if tmp[0] < tmp[1] < tmp[2]: + dic[tmp[1]] += 1 + +count = 0 +for v in dic.values(): + if v > 0: + count += 1 + +print(count) +" +p03011,s578253826,Wrong Answer,"array = list(map(int, input().split())) +array.sort +print(sum(array[0:2]))" +p02659,s955569983,Accepted,"from decimal import Decimal +a,b = input().split() +print(int(Decimal(a)*Decimal(b)))" +p02645,s188316027,Accepted,"import sys +from collections import defaultdict, Counter, namedtuple, deque +import itertools +import functools +import bisect +import heapq +# import math +from fractions import gcd + +MOD = 10 ** 9 + 7 +# MOD = 998244353 +# sys.setrecursionlimit(10**8) + +s = input() +print(s[:3]) +" +p03612,s424742242,Accepted,"N = int(input()) +p = list(map(int, input().split())) +count = 0 +for i in range(len(p)): + if i + 1 == p[i]: + if i + 1 != len(p): + tmp = p[i] + p[i] = p[i + 1] + p[i + 1] = tmp + count += 1 + else: + tmp = p[i] + p[i] = p[i - 1] + p[i - 1] = tmp + count += 1 + +print(count) +" +p03723,s911228472,Accepted,"a,b,c= map(int,input().split()) +cnt = 0 +if a == b and b == c: + if a%2 == 0 and b%2 == 0 and c%2 == 0: + print(-1) + exit() + else: + print(0) + exit() +while a%2 == 0 and b%2 == 0 and c%2 == 0: + cnt +=1 + x =(b+c)//2 + y =(c+a)//2 + z =(b+a)//2 + a = x + b = y + c = z +print(cnt)" +p02697,s014616339,Accepted,"N,M= map(int, input().split()) + +num = list(range(1,N+1)) +ans = [] + + +if M % 2 == 0: + for i in range(M // 2): + ans.append([i+1,M+1-i]) + for i in range(M // 2): + ans.append([i+2+M,2*M+1-i]) + + +if M % 2 != 0: + for i in range(M // 2): + ans.append([i+1,M-i]) + for i in range(M - M//2): + ans.append([i+1+M,2*M+1-i]) + + +for an in ans: + print(an[0],an[1]) +" +p03469,s288280671,Wrong Answer,"s = input() +print(s[3])" +p03427,s392975727,Wrong Answer,"N = input() +ndig = len(N) +print(int(N[0]) - 1 + 9 * (ndig - 1))" +p04019,s661555122,Wrong Answer,"S = input() +if 'N' in S and 'W' in S and 'S' in S and 'E' in S: + print('Yes') +else: + print('No')" +p02695,s023682377,Wrong Answer,"import numpy as np +nmq = input() +[n, m, q] = [int(comp) for comp in nmq.split()] +abcd = [] +for i in range(q): + temp = input() + abcd.append([int(comp) for comp in temp.split()]) +a = np.ones(n, dtype=int) +maxi = 0 + + +def search(i, mini): + global maxi + global a + if(i == n): + temp = np.array([comp[3] for comp in abcd if ( + a[comp[1] - 1] - a[comp[0] - 1] == comp[2])]).sum() + maxi = max(temp, maxi) + return 0 + for j in range(mini, 11): + a[i] = j + search(i + 1, j) + + +search(0, 1) +print(maxi)" +p02939,s364306435,Accepted,"S = input() +curr = """" +last = """" +cnt = 0 +for c in S: + curr += c + if curr != last: + last = curr + curr = """" + cnt += 1 +print(cnt) +" +p02714,s668092757,Accepted,"n = int(input()) +s = input() +d = {'R':0,'G':0,'B':0} +for c in s: + d[c]+=1 +all = d['R']*d['G']*d['B'] +cnt = 0 +for i in range(n): + for j in range(i+1, n+1): + k = (j*2)-i + if k >= n: + continue + if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]: + cnt += 1 +print(all-cnt)" +p03699,s920686965,Accepted,"n = int(input()) +x = 0 +mn = 100 +for i in range(n): + s = int(input()) + x += s + if s % 10 != 0: + if s <= mn: + mn = s +if x % 10 != 0: + print(x) +else: + x -= mn + if x % 10 == 0: + print(0) + else: + if x < 0: + print(0) + exit() + print(x) + " +p02973,s896870219,Wrong Answer,"n = int(input()) +a = [] +for i in range(n): + a.append(int(input())) + +stk = [] +ret = 0 + +for item in a: + while stk and stk[-1] < item: + stk.pop() + stk.append(item) + if len(stk) > ret: + ret = len(stk) + +print(ret) +" +p02918,s105940411,Accepted,"import sys +from itertools import groupby +def input(): return sys.stdin.readline().rstrip() + +def main(): + n,k=map(int, input().split()) + S=list(input()) + p=len(list(groupby(S)))-2*k + pp=max(p,1) + print(n-pp) + +if __name__ == '__main__': + main()" +p02866,s000306342,Wrong Answer,"N = int(input()) +D = list(map(int, input().split())) +D.sort() +if D.pop(0) != 0: + ans = 0 +else: + ans = 1 + num = 1 + before = 1 + after = 0 + for i in D: + if i == num: + after += 1 + elif i == num+1: + ans *= before**after + num += 1 + before = after + after = 1 + else: + ans = 0 + ans *= before**after +print(ans%998244353)" +p03633,s109779432,Accepted,"from fractions import gcd +from functools import reduce +n=int(input()) +t=[int(input()) for i in range(n)] +def lcm(x,y): + return x*y//gcd(x,y) +ans=reduce(lcm,t) +print(ans)" +p02775,s887290928,Accepted,"s=input() +state=0 +mai=0 +for i in range(len(s)): + k=int(s[len(s)-1-i]) + if state==1: + k=k+1 + if k<0: + k=10+k + elif state==2: + if k>=5: + k=k+1 + if k<0: + k=10+k + if k>5: + mai+=10-k + state=1 + elif k<5: + mai+=k + state=0 + elif k==5: + state=2 + mai+=k +if k>=6: + mai+=1 +print(mai)" +p03673,s334957326,Wrong Answer,"n=int(input()) +a=list(map(str,input().split())) +b,c=[],[] +for i in range(n): + if i%2==0: + b.append(a[i]) + else: + c.append(a[i]) +c.reverse() +print("" "".join(c+b))" +p02814,s182026710,Wrong Answer,"N,M = list(map(int,input().split())) +a = list(map(int,input().split())) + +import math +import sys + +tmp = 1 +for i in range(N): + lcm = tmp*(a[i]//2)//math.gcd(tmp,(a[i]//2)) + tmp = lcm + +for i in a: + if tmp // i % 2 == 0: + print(0) + sys.exit() +print(ceil((M // tmp) / 2))" +p03779,s632687235,Accepted,"N = int(input()) +i = 1 +while True: + if i*(i+1)/2 >= N: + print(i) + break + i += 1" +p02583,s450520129,Accepted,"N = int(input()) +L = list(map(int, input().split())) + +OKs = 0 +import itertools +for c in itertools.combinations(L, 3): + if len(set(c))==3: + c = sorted(list(c)) + c1, c2 = c[2], c[:2] + if sum(c2) > c1: + OKs += 1 + +print(OKs)" +p02675,s297056697,Accepted,"n = input() +if n[-1] in ['2', '4', '5', '7', '9']: + print('hon') +elif n[-1] in ['0', '1', '6', '8']: + print('pon') +else: + print('bon')" +p03071,s273718265,Wrong Answer,"a,b = map(int,input().split()) +s = max(2*a,2*b,a+b) +if s == 2 *a or 2*b: + print(s-1) +else: + print(s)" +p03163,s889810220,Wrong Answer,"n, w = map(int,input().split()) +maxi = 0 +possibilities = [] +for i in range(n): + wi, vi = map(int, input().split()) + to_add =[[wi, vi]] + for wp, vp in possibilities: + wa = wp + wi + if wa < w: + va = vp + vi + maxi = max(maxi,va) + to_add.append([wp+wi, va]) + elif wa == w: + va = vp + vi + maxi = max(maxi, va) + possibilities += to_add +print(maxi) +" +p02946,s467364481,Wrong Answer,"K,X=map(int,input().split()) + +for i in range(X-K+1,X+K-1): + print(i,end="" "")" +p03698,s615355935,Wrong Answer,"s=str(input()) +x=0 +for i in range(len(s)): + if s.count(s[i])==0: + x+=1 +if x==len(s): + print('yes') +else: + print('no') + " +p03011,s020159937,Accepted,"P,Q,R=map(int,input().split()) +print(P+Q+R-max(P,Q,R))" +p03962,s882770200,Wrong Answer,"a,b,c = map(int,input().split()) + +if a != b != c: + print(3) +if a == b and a != c and b != c: + print(2) +if a == b == c: + print(1)" +p03285,s212191460,Accepted,"N = int(input()) +for i in range(N//4+1): + for j in range(N//7+1): + if 4*i + 7*j ==N: + print('Yes') + exit() +print('No')" +p02577,s465628503,Wrong Answer,"### 数列をいったん文字列に変換 +numberString = input() +print(numberString) +sumNumber = 0 + +### 文字列を分割、整数化 +for i in range(len(numberString)): + sumNumber += int(numberString[i]) +### 和を9を法とする式で計算。 + +if sumNumber % 9 == 0: + print(""Yes"") +else: + print(""No"")" +p02744,s101629453,Accepted,"import sys +import itertools +input = sys.stdin.readline +sys.setrecursionlimit(10**6) + + +def dfs(s, mx, n): + l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'] + if len(s) == n: + print(s) + return + for i in range(mx+2): + t = s + t += l[i] + dfs(t, max(mx, i), n) + + +def main(): + n = int(input()) + dfs('', -1, n) + + +main() +" +p02859,s467517934,Accepted,"r=int(input()) +print(r**2)" +p02640,s911040863,Accepted,"X, Y = map(int, input().split()) + +low = 2*X +upper = 4*X + +if low <= Y and Y <= upper and Y % 2 == 0: + print(""Yes"") +else: + print(""No"")" +p03745,s968001888,Accepted,"N = int(input()) +a_list = list(map(int,input().split())) + +cur=a_list[0] +pat=0 #0:change,1:asc,2:desc +ans=0 +for a in a_list: + if a==cur: + continue + if pat==0: + if cura: + ans+=1 + pat=0 + elif pat==2 and cur=K: + print(A) +else: + print(A-(K-(A+B))) +" +p03711,s856551629,Accepted,"L = [[1, 3, 5, 7, 8, 10, 12],[4, 6, 9, 11],[2]] +x, y = map(int,input().split()) +ans = False +for i in range(len(L)): + if x in L[i] and y in L[i]: + ans = True +if ans: + print(""Yes"") +else: + print(""No"") +" +p03109,s457621716,Wrong Answer,"l = list(map(int, input().split(sep='/'))) + +if l[0] > 2019: + print('TBD') +else: + if l[1] > 5: + print('TBD') + else: + if l[2] >30: + print('TBD') + else: + print('Heisei')" +p03544,s883953585,Accepted,"n = int(input()) + +A = [2, 1] + +for i in range(n-1): + A.append(A[-1] + A[-2]) + +print(A[-1])" +p03289,s568735578,Accepted,"s = input() +ans = ""AC"" +if s[0] == ""A"": + c_cnt = 0 + for i in range(2,len(s)-1): + if s[i] == ""C"": + c_cnt += 1 + if c_cnt == 1: + for i in s: + if i.lower() != ""a"" and i.lower() != ""c"" and i.lower() != i: + ans = ""WA"" + break + else: + ans = ""WA"" +else: + ans = ""WA"" +print(ans)" +p02994,s405622240,Accepted,"n,l=map(int,input().split()) +x=[] +for i in range(n): + x.append(i+l) + +if max(x)*min(x)<=0: + print(sum(x)) +elif min(x)>0: + print(sum(x)-min(x)) +elif max(x)<0: + print(sum(x)-max(x))" +p03150,s606117337,Accepted,"import sys + +s = input() + +for i in range(8): + ans = s[:i] + s[-(7-i):] + if i == 7: + ans = s[:7] + + if ans == 'keyence': + print('YES') + sys.exit() + +print('NO') +" +p02629,s553047379,Accepted,"N = int(input()) +N -= 1 +S = chr(N % 26 + 97) +N //= 26 +while N > 0: + N -= 1 + S += chr(N % 26 + 97) + N //= 26 +print(S[::-1])" +p02900,s717752626,Wrong Answer,"def is_Prime(i): + if i == 2: + return True + if i % 2 == 0 or i == 1: + return False + s = int(i ** 1 / 2) + while True: + if s == 1: + return True + if i % s == 0: + return False + s -= 1 + +a, b = map(int, input().split()) +ans = 1 +for i in range(2, int(max(a, b) ** (1 / 2)) + 1): + if a % i == b % i == 0: + if is_Prime(i): + ans += 1 +print(ans)" +p03331,s346404968,Accepted,"n=input() +ai=0 +if int(n) % 10 != 0: + for i in range(len(n)): + ai += int(n[i]) +else: + ai = 10 +print(ai)" +p03220,s906781949,Wrong Answer,"N = input() +TA = input().split() +T = int(TA[0]) +A = int(TA[1]) + +first = True +place = 0 +minTmep = 0 + +H = list(map(int, input().split())) +for i in range(0,len(H)): + compare = abs(A - T - H[i] * 0.006) + if first == True: + place = i + minTmep = compare + first = False + + if minTmep > compare: + place = i + +print(place + 1)" +p03041,s118996782,Accepted,"n,k = map(int, input().split()) +s = input() +k-=1 +print(s[:k] + s[k].lower() + s[k+1:]) +" +p02767,s408605763,Wrong Answer,"n = int(input()) +l = list(map(int, input().split())) +sl = [0] + +ma, mi = max(l), min(l) + +for x in range(mi, ma): + s = 0 + for i in l: + s += (i - x)**2 + sl.append(s) + +print(min(sl))" +p03324,s638822228,Accepted,"d, n = map(int, input().split()) + +div = 100 ** d + +if n < 100: + print(div * n) + exit(0) +else: + print(div * 101) + exit(0)" +p03210,s140609446,Accepted,"X = int(input()) +if (X==7) or (X==5) or (X==3): + print(""YES"") +else: + print(""NO"")" +p03041,s804735530,Wrong Answer,"a, b = list(map(int,input().split())) +S = list(str(input())) +S[a-1] = str.lower(S[a-1]) +S = """".join(map(str,S)) +print(S)" +p03059,s870578161,Wrong Answer,"a,b,t=map(int,input().split()) +c=0 +n=2 +while True: + if a<=t: + c+=b + a=a*n + n+=1 + else: + break +print(c)" +p03799,s728408210,Wrong Answer,"n, m = map(int, input().split()) +ans = n +m -= n*2 +ans += m // 4 +print(ans) +" +p03013,s942562722,Wrong Answer,"N,M = map(int,input().split()) +a = [1]*(N+1) +Answer = [] +for i in range(M): + a[int(input())-1] = 0 +Answer.append(1*a[0]) +Answer.append(1*a[1]+1*a[0]) +for j in range(2,N): + A = ((Answer[j-1]%(10**9+7)) + (Answer[j-2]%(10**9+7)))*a[j] + Answer.append(A%(10**9+7)) +print(Answer[-1])" +p03672,s924044916,Accepted,"s = list(input()) + +while (s): + s.pop() + s.pop() + sl = s[:len(s) // 2] + sr = s[len(s) // 2:] + if sl == sr: + # print(sl) + # print(sr) + print(len(sl) * 2) + exit() +" +p03379,s131016873,Wrong Answer,"n = int(input()) +x = list(map(int, input().split())) +xsort = sorted(x) + +for i in range(n): + if x[i] < xsort[n//2]: + print(xsort[2//n]) + else: + print(xsort[n//2-1])" +p03472,s435644797,Wrong Answer,"n,h = map(int, input().split()) +A = 0 +B = [] +for _ in range(n): + a,b = map(int, input().split()) + if A < a: A = a + B.append(b) +B.sort(reverse=True) +hit = 0 +cnt = 0 +for i in range(n): + if hit >= h: break + if A < B[i]: + hit += B[i] + cnt += 1 + else: break +if hit >= h: print(cnt) +else: print(cnt + round((h-hit)/A))" +p02836,s195588632,Accepted,"import math +S=list(input()) +N=len(S) +a=0 +for i in range(0,N): + if S[i]!=S[N-1-i]: + a+=1 +a=math.ceil(a/2) +print(a)" +p02792,s020961218,Accepted,"n = int(input()) +t = [[0 for j in range(10)] for i in range(10)] +for i in range(1,n+1): + s = str(i) + t[int(s[0])][int(s[-1])] += 1 +ans = 0 +for i in range(1,10): + for j in range(1,10): + ans += t[i][j]*t[j][i] +print(ans)" +p03821,s318416413,Accepted,"N=int(input()) +A=[] +B=[] +x=[] +c=0 +for i in range(N): + y=list(map(int,input().split())) + A.append(y[0]) + B.append(y[1]) +for i in range(N-1,-1,-1): + x=A[i] + y=B[i] + if (x+c)%y!=0: + c+=y-(x+c)%y +print(c)" +p02622,s493029286,Accepted,"s=input() +t=input() +cnt=0 +for i in range(len(s)): + if s[i]!=t[i]: + cnt+=1 +print(cnt)" +p03210,s324278331,Accepted,"n=int(input()) +if(n==3 or n==5 or n==7): + print(""YES"") +else: + print(""NO"") +" +p02696,s724580870,Wrong Answer,"import math + + +def target(x): + return math.floor(A * x / B) - A * math.floor(x / B) + + +A, B, N = map(int, input().split()) + +left = 0 +right = N + +while right - left > 1: + mid = (left + right) // 2 + y = target(mid) + prv = target(mid - 1) + nxt = target(mid + 1) + if prv <= y <= nxt: + left = mid + else: + right = mid + + +print(target(right))" +p02783,s014205551,Accepted,"import math +def A(): + temp = [int(i) for i in input().split()] + print(int(math.ceil(temp[0]/temp[1]))) + +A()" +p03659,s029010448,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +x = a[0] +y = sum(a[1:]) +ans = abs(x - y) +for i in range(1, n-1): + x += a[i] + y -= a[i] + ans = min(abs(x-y), ans) +print(ans) +" +p03524,s646786301,Accepted,"s = list(input()) +a = [s.count('a'),s.count('b'),s.count('c')] +print(""NO"" if max(a)-min(a)>1 else ""YES"")" +p02675,s968921643,Accepted,"str = input() +if(int(str[-1]) in [2, 4, 5, 7, 9]): + print('hon') +elif(int(str[-1]) in [0, 1, 6, 8]): + print('pon') +else: + print('bon')" +p03095,s164311854,Wrong Answer,"from collections import Counter +N = int(input()) +S = Counter(input()) +ans = 1 +for v in S.values(): + ans *= (v+1) +print(ans-1)" +p03448,s713815083,Wrong Answer,"A=int(input()) +B=int(input()) +C=int(input()) +N=int(input()) +count=0 +for i in range(A+1): + for j in range(B+1): + for k in range(C+1): + if 500*i+100*j+C*k== N: + count+=1 +print(count)" +p03386,s390519271,Accepted,"A,B,K=map(int,input().split()) +ans=[] + +for i in range(K): + if A+i<=B: + ans.append(A+i) + if B-i>=A: + ans.append(B-i) + +l=set(ans) +ans2=list(l) +ans2.sort() + +for i in range(len(ans2)): + print(ans2[i]) + +" +p02818,s808014856,Wrong Answer,"from itertools import accumulate, permutations, combinations, product, combinations_with_replacement +from math import floor, ceil, sqrt, factorial, log +from bisect import bisect_left, bisect_right +from collections import Counter, defaultdict +from heapq import heappop, heappush, heappushpop +from itertools import product +import sys +stdin = sys.stdin +mod = 10**9 + 7 + + +def ns(): return stdin.readline().rstrip() + + +def ni(): return int(ns()) + + +def na(): return list(map(int, stdin.readline().split())) + + +a, b, k = na() +takahashi = a - min((k + 1) // 2, b) +aoki = b - min(k // 2, a) +print(takahashi, aoki) +" +p03951,s310677378,Accepted,"n = int(input()) +s = input() +t = input() + +for i in range(n, -1, -1): + ans = [""""] * (2 * n - i) + ans[:n] = list(s) + ans[-n:] = list(t) + if ans[:n] == list(s): + break + +print(2 * n - i) +" +p02552,s727877082,Accepted,"x = int(input()) +if x == 0: + print(1) +else: + print(0) + +" +p03910,s581260996,Accepted,"n=int(input()) +for i in range(n+7): + if i*(i+1)//2>=n:w=i;break +for i in range(w,0,-1): + if n>=i: + print(i) + n-=i" +p03785,s446697382,Wrong Answer,"n,c,k = map(int, input().split()) +a = [] +bus = 1 +for i in range(n): + a.append(int(input())) +a.sort() +j = 0 +count = 1 +while j + count in range(n): + if a[j+count] < a[j] + k and count < c: + count = count + 1 + else: + bus = bus + 1 + j = j + count + count = 1 +print(bus)" +p02952,s453895424,Wrong Answer,"N = int(input()) + +result = 0 +if len(str(N)) % 2 == 0: + loop = ((len(str(N)) - 1) -1) //2 + 1 + for i in range(loop): + result += 9 * pow(10,2*i) + else: + for i in range(len(str(N)) - 2): + result += 9 * pow(10,i) + result += N - pow(10,len(str(N)) - 1) + 1 + +print(result) +" +p02729,s808823832,Wrong Answer,"from scipy.misc import comb +N,M = map(int,input().split()) +even = comb(N,2) +odd = comb(M,2) +print(int(even + odd))" +p03627,s644283610,Accepted,"from collections import Counter +n = int(input()) +A = list(map(int, input().split())) +d = Counter(A) +key = d.keys() +ans = [] +for k in key: + if d[k] >= 2: + ans.append(k) + if d[k] >= 4: + ans.append(k) +if len(ans) < 2: + print(0) +else: + ans.sort() + print(ans[-1]*ans[-2])" +p03799,s947341454,Wrong Answer,"import math +n, m = map(int, input().split()) +# ans = 0 +# +# if m >= 2*n: +# ans += n +# m -= 2*n +# ans += math.floor(m/4) +# +# print(ans) +# + +scc = n*2 + m +ans = math.floor(scc/4) +print(ans)" +p03000,s233090415,Wrong Answer,"import sys + + +def input(): return sys.stdin.readline().strip() +def I(): return int(input()) +def LI(): return list(map(int, input().split())) +def IR(n): return [I() for i in range(n)] +def LIR(n): return [LI() for i in range(n)] +def SR(n): return [S() for i in range(n)] +def S(): return input() +def LS(): return input().split() + + +INF = float('inf') + + +n, x = LI() +l = LI() +cnt = 0 +d = 0 +for i in range(n): + if d <= x: + cnt += 1 + d += l[i] +print(cnt) +" +p02657,s756229552,Accepted,"def resolve(): + a,b=map(int,input().split()) + print(a*b) +resolve()" +p03862,s671543302,Wrong Answer,"N,x = map(int,input().split()) +a = [0] + list(map(int,input().split())) +b = [0] +for i in range(1,N): + b.append(a[i]+a[i+1]) + +cnt = 0 +for i in range(N-1,0,-1): + if b[i] > x: + c = b[i] - x + cnt += c + b[i] -= c + b[i-1] -= c +print(cnt) " +p03817,s652733136,Accepted,"x = int(input()) +x,y=divmod(x, 11) +if y > 6: + print(2*x+2) +elif y > 0: + print(2*x+1) +else: + print(2*x) +" +p03796,s586438749,Accepted,"N = int(input()) +ans = 1 +for i in range(1,N+1): + ans *= i + ans %= 10**9+7 +print(ans)" +p03672,s930024462,Accepted,"s = input() + +if(len(s) % 2 == 0): + s = s[:-2] +else: + s = s[:-1] + +while(s != """"): + l = len(s)//2 + if(s[:l] == s[l:]): + print(l*2) + break + s = s[:-2] +" +p02697,s575889682,Accepted,"N, M = map(int, input().split()) + +if N % 2 == 0: + N -= 1 + +H = N // 2 +if H % 2 == 1: + H += 1 + +m = 0 +i = 1 +while m < M: + print(i, H - i + 1) + i += 1 + m += 1 + if i >= H - i + 1: + break + +i = 1 +while m < M: + print(H + i, N + 1 - i) + i += 1 + m += 1 +" +p03150,s827795498,Wrong Answer,"S = input() + +key = list(""keyence"") + +flg = False +for i in range(len(S)): + for j in range(len(S)): + tmp = S[0:i]+S[j:] + + if tmp == key and not flg: + print(""YES"") + exit() + +if not flg: + print(""NO"") +" +p03075,s486216613,Accepted,"max_dis = 0 +a = int(input()) +for _ in range(3): + input() +b = int(input()) +k = int(input()) +if b - a <= k: + print(""Yay!"") +else: + print("":("") + +" +p03681,s419840303,Accepted,"def resolve(): + ''' + code here + + ''' + import math + + N, M = [int(item) for item in input().split()] + + deff = N - M + + if deff == -1: + N, M = M, N + + if deff == 0: + temp = math.factorial(N) + res = (temp**2 * 2) % (10**9+7) + + elif abs(deff) == 1: + res = (math.factorial(N) **2 // N ) % (10**9+7) + + else: + res = 0 + + print(res) + +if __name__ == ""__main__"": + resolve() +" +p03665,s755018445,Wrong Answer,"def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) +import math + +n,p = iim() +A = iil() + +if n > 1: + even = 0 + odd = 0 + for i in A: + if i%2 == 0: + even += 1 + else: + odd += 1 + + p0 = 2**(odd-1) + print(2**even*p0) +else: + if p == 0: + print(2 if A[0]%2 == p else 0) + else: + print(1 if A[0]%2 == p else 0) +" +p02612,s596623363,Accepted,"import math +N = int(input()) +print(math.ceil(N / 1000) * 1000 - N)" +p02647,s275977412,Accepted,"import numpy as np +from numba import jit +n, k = map(int, input().split()) +a = np.array(list(map(int, input().split()))) +@jit +def imos(a): + tmp = np.zeros(n+1, dtype=np.int64) + for i in range(n): + tmp[max(0, i - a[i])] += 1 + tmp[min(i + a[i] + 1, n)] -= 1 + tmp = np.cumsum(tmp) + return tmp[:n] + +for j in range(1, min(k+1, 50)): + a = imos(a) +print(*a)" +p02678,s937477490,Accepted,"from collections import deque +n,m=map(int,input().split()) +l=[[0] for _ in range(n+1)] +vi=[0 for _ in range(n+1)] + +for i in range (m): + a,b=map(int,input().split()) + l[a].append(b) + l[b].append(a) +st=deque([1]) +f=set([1]) + + +while st: + x=st.popleft() + for k in l[x]: + if k not in f: + st.append(k) + f.add(k) + vi[k]=x + +print(""Yes"") +for m in vi[2:]: + print(m) + + +" +p03457,s369708731,Accepted,"N = int(input()) +tpr, xpr, ypr = 0, 0, 0 +count = 0 +for i in range(N): + t, x, y = map(int, input().split()) + d = abs(x-xpr) + abs(y-ypr) + n = ((t-tpr) - d) / 2 + if n >= 0 and n % 1 == 0: + count += 1 + tpr, xpr, ypr = t, x, y +if count == N: + print(""Yes"") +else: + print(""No"") " +p03286,s775029715,Accepted,"# coding: utf-8 +import sys + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) + +def F(x): + if x == 0: + return '' + if x % 2 == 0: + return F(x//-2) + '0' + else: + return F((x-1)//-2) + '1' + +N = ir() +answer = F(N) +if N == 0: + answer = 0 +print(answer) +" +p02572,s793697017,Accepted,"n = int(input()) +a = list(map(int,input().split())) + +max = (10 ** 9) + 7 + +#入力配列の総和 +line = 0 +for i in range (n): + line += a[i] + +#a11, a22, ...対角線要素の総和 +rem = 0 +for i in range(n): + rem += a[i]*a[i] + +sum = ((line*line) - rem) // 2 + +ans = sum % max + +print(ans) +" +p02630,s515851062,Accepted,"N=int(input()) +A=list(map(int,input().split())) +X=[0 for i in range(10**5+1)] +Q=int(input()) +sum_=sum(A) +for i in range(N): + X[A[i]]+=1 +for i in range(Q): + B,C=map(int,input().split()) + sum_+=X[B]*(C-B) + X[C]+=X[B] + X[B]=0 + print(sum_)" +p02729,s921217158,Accepted,"n,m=map(int,input().split()) +a=0 +b=0 +if n!=1: + a=(n*(n-1))/2 +if m!=1: + b=(m*(m-1))/2 +c=int(a+b) +print(c) +" +p02843,s230826672,Accepted,"x = int(input()) +n = x // 100 +if n * 105 >= x: + print(1) +else: + print(0)" +p03457,s459417473,Accepted,"N = int(input()) +txy = list(list(map(int, input().split())) for _ in range(N)) +dt = 0 +dx = 0 +dy = 0 +for i in range(N): + if abs(txy[i][1]-dx)+abs(txy[i][2]-dy) > txy[i][0]-dt or (txy[i][1]+txy[i][2])%2 != txy[i][0]%2: + print(""No"") + break + dt = txy[i][0] + dx = txy[i][1] + dy = txy[i][2] +else: + print(""Yes"")" +p03433,s518288030,Accepted,"N = int(input()) +A = int(input()) + +answer = ""Yes"" if N % 500 <= A else ""No"" +print(answer)" +p03698,s856685772,Accepted,"s = str(input()) +L = [] +for i in s: + if i in L: + print('no') + exit() + else: + L.append(i) +print('yes')" +p03814,s712350337,Accepted,"s = input() +print(s.rfind('Z') - s.find('A') + 1)" +p04011,s874228904,Wrong Answer,"a, b, c, d = [int(input()) for i in range(4)] +if b > a: + a = b +print(b*c + (a - b)*d)" +p02627,s389791402,Accepted,"a = input() +if 97 <= ord(a) <= 122: + print('a') +else: + print('A')" +p03250,s397082952,Accepted,"data=list(map(int,input().split())) +data.sort(reverse=True) +print(10*data[0]+data[1]+data[2])" +p02729,s090999413,Wrong Answer,"n,m=map(int,input().split()) + +print(n*(n-1)/2+m*(m-1)//2)" +p03262,s981241504,Accepted,"from functools import reduce +from fractions import gcd +N,x=map(int,input().split()) +X=[abs(int(i)-x) for i in input().split()] +print(reduce(gcd,X)) +" +p02743,s374124578,Accepted,"from decimal import Decimal as de +a,b,c=map(de,input().split()) +print('Yes' if a**de('0.5')+b**de('0.5')= N: + break +A_dash = A_dash[:N] + +A_dash.extend(A) +A_dash = sorted(A_dash, reverse=True)[:N] + +print(sum(A_dash)) +" +p02606,s666571342,Wrong Answer,"l,r,d = map(int,input().split()) +ans = 0 + +for i in range(100): + if d * i <= l: + ans += 1 + if d * i >= r: + ans += 1 + break + +print(ans) +" +p02994,s966559596,Wrong Answer,"n,l = map(int,input().split()) + +apples = [l-i for i in range(n)] + +eat = float('inf') +for a in apples: + eat = a if abs(a)< abs(eat) else eat + +print(sum(apples) - eat)" +p02602,s547009453,Accepted,"N, K = map(int, input().split()) + +A = list(map(int, input().split())) + +for i in range(N - K): + if A[i] >= A[i + K]: + print('No') + else: + print('Yes') + +" +p03324,s076534692,Accepted,"D, N = map(int, input().split()) + +if N != 100: + print(100**D*N) +else: + print(100 ** D * 101) + + +" +p02696,s947392149,Accepted,"a,b,n=map(int,input().split()) +x=min(n,b-1) +l=(a*x)//b +r=a*(x//b) +print(l-r)" +p02554,s376213571,Wrong Answer,"""""""AtCoder Beginner Contest 178. + +C +"""""" + +import sys + + +def input() -> str: # noqa: A001 + """"""Input."""""" + return sys.stdin.readline()[:-1] + + +def main(): + """"""Run."""""" + mod = 1000000007 + n = int(input()) + + ans = 0 + + if n <= 1: + ans = 0 + elif n == 2: + ans = 2 + else: + ans = 10**n + ans -= 8**n + ans -= 8**n + ans += 7**n + + print(ans % mod) + + +main() +" +p03379,s709261035,Accepted,"n = int(input()) +x = list(map(int,input().split())) +y = sorted(x) + +for i in range(n): + if x[i] <= y[(n//2) - 1]: + print(y[(n//2)]) + elif x[i] >= y[(n//2)]: + print(y[(n//2) - 1])" +p03481,s120850384,Accepted,"X ,Y = map(int, input().split()) +l = [] +ans = 1 + +for i in range(Y-X): + t = X * 2**i + if t <=Y: + l.append(t) + else: + break + +ans = len(l) +if X == Y: + ans = 1 +print(ans) + +" +p02629,s761123066,Wrong Answer,"n = int(input()) + +alphabets = [chr(i) for i in range(ord('a'), ord('a') + 26)] +x = 0 +for i in range(1, 100): + if n <= 26**i: + x = i + break +ans = '' +for i in range(x, 0, -1): + ans = alphabets[n % 26 - 1] + ans + n = n // 26 + +print(ans) +" +p03371,s815063707,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def main(): + A, B, C, X, Y = map(int, input().split()) + + print( + min(X * A + Y * B, + 2 * X * C + B * max(0, Y - X), + 2 * Y * C + A * max(0, X - Y))) + + +if __name__ == ""__main__"": + main() +" +p03379,s108660838,Accepted,"n = int(input()) +X = list(map(int, input().split())) + +Y = X[::] +Y.sort() + +m = n // 2 +median = (Y[m] + Y[m - 1]) / 2 + +for x in X: + if x < median: + print(Y[m]) + else: + print(Y[m-1]) + +" +p02678,s355102214,Wrong Answer,"from collections import deque +n,m=map(int,input().split()) +root=[[] for _ in range(n)] +for i in range(m): + a,b=map(int,input().split()) + root[a-1].append(b-1) + root[b-1].append(a-1) +times=[0]*n +sign=[-1]*n +sign[0]=0 +que=deque([0]) +while que: + q=que.popleft() + for i in root[q]: + if sign[i]==-1: + sign[i]=q + que.extend(root[i]) +for i in range(n-1): + print(sign[i+1]+1)" +p03617,s592522393,Wrong Answer,"q, h, s, d = map(int, input().split()) +n = int(input()) +m = 0 +l = [q, min(q*2, h), min(q*4, h*2, s), min(q*8, h*4, s*2, d)] + +if n % 2 == 0: + m += (n / 2) * l[3] +else: + m += (n // 2) * l[3] + l[2] + +print(int(m))" +p03493,s617629569,Accepted,"N = list(input()) +print(N.count('1'))" +p03611,s530222601,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = [0]*(10**5+2) + +for a in A: + B[a+1]+=1 + B[a+2]+=1 + B[a]+=1 + +print(max(B))" +p02676,s562803309,Accepted,"k=int(input()) +s=input() + +if len(s)<=k: + print(s) +else: + print(s[0:k]+'...') +" +p02753,s746589013,Accepted,"#!/usr/bin/env python3 +import sys + +input = sys.stdin.readline + + +def Y(): + print(""Yes"") + + +def N(): + print(""No"") + + +def ST(): + return input().rstrip() + + +def I(): + return int(input()) + + +def MI(): + return map(int, input().split()) + + +def LI(): + return list(MI()) + + +S = ST() + +if (""A"" not in S) or (""B"" not in S): + N() +else: + Y() +" +p02555,s567404957,Wrong Answer,"from operator import mul +from functools import reduce + +def cmb(n,r): + r = min(n-r,r) + if r == 0: return 1 + over = reduce(mul, range(n, n - r, -1)) + under = reduce(mul, range(1,r + 1)) + return over // under + +N = int(input()) +ans = 0 +Sum = 0 +if N==1: + ans=0 +if N==2: + ans=2 +if 2i[1]: + continue + else: + a += 1 + lim = i[0] +print(a)" +p02900,s090417585,Accepted,"A, B = map(int, input().split()) + + +def prime_factorization(n): + from collections import Counter + counter = Counter() + + if n < 2: + return counter + + for i in range(2, int(n ** 0.5) + 1): + if i * i > n: + break + + while n % i == 0: + counter[i] += 1 + n //= i + + if n > 1: + counter[n] += 1 + + return counter + + +x = prime_factorization(A) +y = prime_factorization(B) + +z = set(x.keys()) & set(y.keys()) +print(len(z) + 1) +" +p02595,s053953797,Wrong Answer,"N, D = map(int,input().split()) +data = [list(map(int,input().split())) for _ in range(N)] +#print(data) +count = 0 +for d in data: + if d[0]*d[0] + d[1]*d[1] >= D*D: + count += 1 +print(count) +#print(N,D)" +p02760,s401480569,Accepted,"import numpy as np +card = np.array([list(map(int,input().split())) for i in range(3)]) +N = int(input()) +nums = np.array([int(input()) for i in range(N)]) + +res = np.ones((3, 3), dtype=int) +for y in range(3): + for x in range(3): + if card[y, x] in nums: + res[y, x] = 0 + +lis = [\ + np.multiply.reduce(res.sum(axis=0)), \ + np.multiply.reduce(res.sum(axis=1)), \ + np.trace(res),\ + np.trace(np.rot90(res.T))] +print(""Yes"" if 0 in lis else ""No"")" +p03861,s119582230,Accepted,"a,b,x = map(int,input().split()) + +print(b//x - (a-1)//x)" +p03163,s936010353,Accepted,"N, W = map(int, input().split()) + +dp = [[0 for i in range(W+1)] for j in range(N+1)] + +for i in range(1,N+1): + w, v = map(int,input().split()) + for j in range(0,W+1): + if (j-w) >=0: + dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v) + else: + dp[i][j] = dp[i-1][j] + #print(dp) + + +ans = dp[N][W] +print(ans)" +p03161,s304609396,Accepted,"import sys,queue,math,copy,itertools,bisect,collections,heapq +sys.setrecursionlimit(10**7) +INF = 10**18 +MOD = 10**9 + 7 +LI = lambda : [int(x) for x in sys.stdin.readline().split()] +NI = lambda : int(sys.stdin.readline()) + +N,K = LI() +h = LI() +dp = [INF for _ in range(N)] +dp[0] = 0 +for i in range(N-1): + for j in range(i+1,i+K+1): + if j < N: + dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j])) +print(dp[-1])" +p03657,s244838127,Accepted,"A, B = map(int, input(). split()) + +if A % 3 == 0: + print('Possible') + +elif B % 3 == 0: + print('Possible') + +elif (A + B) % 3 == 0: + print('Possible') + +else: + print('Impossible')" +p02711,s487138044,Accepted,"N = input() +if '7' in N: + print('Yes') +else: + print('No')" +p03061,s396244638,Accepted,"def gcd(a,b): return a if b==0 else gcd(b,a%b) + +n = int(input()) +a = [int(x) for x in input().split()] +pref = [x for x in a] +suff = [x for x in a] +for i in range(1,n): + pref[i] = gcd(pref[i-1],a[i]) +for i in range(n-2,-1,-1): + suff[i] = gcd(suff[i+1],a[i]) + +print(max([pref[-2],suff[1]]+[gcd(pref[i-1],suff[i+1]) for i in range(1,n-1)])) " +p02700,s495325106,Wrong Answer,"a,b,c,d=map(int,input().split()) +x=float(a/d) +y=float(c/b) + +if x>=y: + print(""yes"") +elif 0d[4]::2]) +else: print('YNeos'[d[1]-1>d[4]::2])" +p04029,s889298186,Accepted,"n = int(input()) +print(int(n*(n+1)/2))" +p02548,s823016604,Accepted,"#!/usr/bin/env python3 + +import sys +input=sys.stdin.readline + +n=int(input()) +ans=0 +for a in range(1,n+1): + for b in range(1,n+1): + if a*b>=n: + break + ans+=1 +print(ans)" +p02888,s283143185,Accepted,"import bisect + +N = int(input()) +L = sorted(list(map(int,input().split()))) +ans = 0 +for bi in range(1,N-1): + for ai in range(0,bi): + ci = bisect.bisect(L,L[bi]+L[ai]-1) - 1 + if bi a: + print('No') +else: + print('Yes')" +p02597,s893085965,Wrong Answer,"n=int(input()) +s=input() +c=0 +for i in range(len(s)-1): + if(s[i]=='W' and s[i+1]=='R'): + c+=1 +print(c)" +p02664,s585764432,Wrong Answer,"s = input() + +li = [] +for i, c in enumerate(s): + if c == '?': + if i == len(s) - 1: + c = 'D' + else: + if s[i + 1] == 'D' or s[i + 1] == '?': + c = 'P' + else: + c = 'D' + li.append(c) + +print(''.join(li))" +p03095,s676112389,Accepted,"n = int(input()) +s = input() +mod = 10**9 + 7 + +cnt = [0] * 26 +for i in range(26): + cnt[i] = s.count(chr(i+97)) + 1 + +ans = 1 +for i in cnt: + ans *= i + ans %= mod + +ans -= 1 +ans %= mod +print(ans)" +p02606,s981336303,Wrong Answer,"def main(): + l, r, d = map(int, input().split()) + res = r // d - l // d + print(res) + +if __name__ == '__main__': + main()" +p02760,s398245665,Accepted,"a = [list(map(int, input().split())) for _ in range(3)] +n = int(input()) +for _ in range(n): + d = int(input()) + for i in range(3): + if d in a[i]: + a[i][a[i].index(d)] = -1 + +for i in range(3): + if sum(a[i])==-3: + print('Yes') + exit() + s = 0 + for j in range(3): + s += a[j][i] + if s==-3: + print('Yes') + exit() +if a[0][0]+a[1][1]+a[2][2]==-3: + print('Yes') + exit() +if a[0][2]+a[1][1]+a[2][0]==-3: + print('Yes') + exit() + +print('No')" +p03012,s293970860,Wrong Answer,"n=int(input()) +listw=list(map(int,input().split())) +lists1=[] +for t in range(1,n): + count=0 + for i in range(t-1): + count+=listw[i] + lists1.append(count) +lists2=[] +for s1 in lists1: + lists2.append(sum(listw)-s1) +ans=[] +for x in range(n-1): + ans.append(abs(lists2[x]-lists1[x])) +print(min(ans))" +p03243,s160160733,Accepted,"N = int(input()) +for i in range(9): + if 111 * i < N and N <= 111 * (i + 1): + print(111 * (i + 1))" +p02973,s775793797,Wrong Answer,"a = int(input()) +l = [] +for i in range(a): + t = int(input()) + l.append(t) +d=[False]*a + +#print('Hello World') +#a = 5 +#l = [2,1,100000,5,3] +used=[] +res =0 +for i in range(a): + if l[i] !=-1: + f = l[i] + #print(1,f) + L = [] + L.append(f) + res +=1 + l[i] = -1 + for j in range(i+1,a): + if f < l[j] and l[j] !=-1: + f = l[j] + l[i] = -1 + #print(f) + + L.append(f) + #print(L) +#print(used) +print(res)" +p03284,s730091186,Wrong Answer,"n, k = map(int, input().split()) +if k == 1: + print(0) +print(int(n % k != 0))" +p03723,s867440487,Accepted,"A, B, C = [int(x) for x in input().split()] +ans = 0 +while True: + if A % 2 == 1 or B % 2 == 1 or C % 2 == 1: + break + elif A == B == C: + ans = -1 + break + ans += 1 + A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2 + +print(ans)" +p02756,s614173611,Accepted,"from collections import deque +S=input() +Q=int(input()) +query=[list(map(str,input().split())) for _ in range(Q)] + +d=deque(S) +reverse=False +for q in query: + if len(q)==1: + reverse=not reverse + else: + _,f,c=q + if f=='1': + d.append(c) if reverse else d.appendleft(c) + else: + d.appendleft(c) if reverse else d.append(c) +print(*reversed(d),sep='') if reverse else print(*d,sep='')" +p03239,s404145492,Accepted,"N,T = map(int,input().split()) +ls = [] +for i in range(N): + c,t = map(int,input().split()) + if t <= T: + ls.append(c) +if len(ls) == 0: + print(""TLE"") +else: + print(min(ls))" +p03644,s879133838,Accepted,"n=int(input()) +for i in range(1,n+1): + if 2**i>n: + print(2**(i-1)) + exit() + + " +p03803,s054574227,Accepted,"A,B = input().split() +A = int(A) +B = int(B) +if A ==1 or B ==1: + if A == 1 and B==1: + print(""Draw"") + elif A==1 and B!=1: + print(""Alice"") + elif A!=1 and B==1: + print(""Bob"") +else: + if A>B: + print(""Alice"") + elif A= 30: + print(""Yes"") +else: + print(""No"") +" +p02989,s005847397,Wrong Answer,"n = int(input()) +l = sorted(list(map(int, input().split()))) +d = int(n / 2) +r = l[d] - l[d-1] +print(l) +print(r)" +p02583,s607200097,Wrong Answer,"n = int(input()) +l = list(map(int,input().split())) +tmp = set() +ans = 0 +for i in range(n): + for j in range(i+1,n): + for k in range(j+1,n): + if (l[i],l[j],l[k]) not in tmp and abs(l[i]-l[j])=b else b) +" +p02717,s402656635,Wrong Answer,"X, Y, Z = input().split() +A = X +B = Y +C = Z +# swap the contents of the boxes A and B +temp = B +B = A +A = temp +print(A + "" "" + B + "" "" + C) +# swap the contents of the boxes A and C +swapAC = C +C = A +A = swapAC +print(A + "" "" + B + "" "" + C) +" +p03632,s116732656,Accepted,"A,B,C,D = map(int,input().split()) +ans = 0 +for i in range(A+1,B+1): + if C max(s[j]): + c+= 1 +print(c) +" +p02622,s801755057,Accepted,"str_1 = input() +str_2 = input() + +count = 0 +for i in range(len(str_1)): + if str_1[i] != str_2[i]: + count += 1 + +print(count)" +p03220,s776693817,Accepted,"n = int(input()) +t,a = map(int, input().split()) +arr = map(int, input().split()) + +ans = (-1,float('inf')) +for i,h in enumerate(arr): + tmp = t - h * 0.006 + if abs(tmp - a) < abs(ans[1]): + ans = (i, tmp-a) + +print(ans[0]+1)" +p03698,s965137043,Accepted,"from collections import defaultdict +import numpy as np + +S = list(map(str, input().rstrip())) + +memo = defaultdict(int) + +for s in S: + memo[s] += 1 + +ans = np.array(list(memo.values())) + +print(""yes"") if np.where(ans>1)[0].shape[0]==0 else print(""no"")" +p02713,s047867751,Wrong Answer,"import math +from functools import reduce + +k = int(input()) +sum = 0 + +for a in range(0, k + 1): + for b in range(0, k + 1): + d = math.gcd(a, b) + for c in range(0, k + 1): + sum += math.gcd(d, c) + +print(sum)" +p03821,s382769962,Accepted,"n = int(input()) +ab = [] +for _ in range(n): + a, b = map(int, input().split()) + ab.append((a, b)) + +ans = 0 +for a, b in reversed(ab): + ans += (-a-ans)%b +print(ans)" +p02993,s494784089,Accepted,"S = str(input()) + +if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]: + print(""Bad"") +else: + print(""Good"")" +p03150,s717088631,Wrong Answer,"S=input() +N=len(S) +T=""keyence"" +U="""" +V="""" + +for i in range(7): + if S[i]==T[i]: + pass + else: + U=S[:i] + break +for j in range(7): + if S[-1-j]==T[-1-j]: + pass + else: + V=S[-1-j+1:] + break + +if U=="""" or V=="""" or U+V==T: + print(""YES"") +else: + print(""NO"")" +p03639,s897818096,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +num_four = 0 +num_two = 0 +num_odd = 0 +for i in range(N): + if A[i] % 4 == 0: + num_four += 1 + elif A[i] % 2 == 0: + num_two += 1 + else: + num_odd += 1 + +# print(num_four, num_two, num_odd) + +v = num_four * 2 +if num_two <= 1: + v += 1 +if num_two >= 2: + v += num_two +ans = 'Yes' if v >= N else 'No' +print(ans) + +# 2 2 2 2 4 o 4 o 4 ... o 4 o +# o 4 o 4 .... o 4 o +" +p03345,s210787796,Accepted,"a, b, c, k = map(int, input().split()) + +if abs(b - a) > 10**18: + print('Unfair') +elif k % 2 == 0: + print(a - b) +else: + print(b - a) +" +p03161,s234534574,Accepted,"#!python3 + +LI = lambda: list(map(int, input().split())) + +# input +N, K = LI() +H = LI() + +INF = 10 ** 10 + + +def main(): + dp = [INF] * N + dp[0] = 0 + for i in range(1, N): + n = min(K + 1, i + 1) + for j in range(1, n): + dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j])) + ans = dp[-1] + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02576,s125203102,Accepted,"N, X, T = map(int, input().split()) + +if N % X == 0: + times = N / X +else: + times = N // X + times += 1 + +ans = int(times * T) + +print(str(ans)) +" +p02933,s312294050,Wrong Answer,"a=int(input()) +s=input() +if a>=3200: + print('s') +else: + print('red')" +p03095,s888965864,Accepted,"from collections import Counter +_=input() +s=input() +s=Counter(s) +ans=1 +for i in s.values(): + ans=(ans*(i+1))%(10**9+7) +print(ans-1)" +p02681,s517809281,Accepted,"mae=str(input()) +ato=str(input()) +mcb=len(mae) +mca=len(ato) +if ato==mae+ato[mca-1]: + print(""Yes"") + +else: + print(""No"")" +p02731,s622980959,Wrong Answer,print((int(input()))**3) +p03625,s085549178,Wrong Answer,"import math +import calendar +import fractions +import itertools + +n = int(input()) +a = list(map(int, input().split())) +ans = 1 +cnt = 0 +minimum = min(a) +maximum = max(a) +for i in range(maximum, minimum - 1, -1): + if a.count(i) < 2: + continue + if cnt == 1: + ans *= i + cnt += 1 + break + if a.count(i) >= 4: + ans = i ** 2 + cnt += 1 + break + ans *= i + cnt += 1 + +if cnt < 2: + ans = 0 +print(ans)" +p02791,s939591315,Wrong Answer,"N = int(input()) +li = list(map(int,input().split())) + +counter = 0 +li2 =[] +for i in range(N): + if li[i]>li[i-1]: + li2.append(1) + elif N == 1: + li2.append(1) +print(len(li2))" +p03986,s031893065,Accepted,"S = input() + +num_s = 0 + +ans = 0 +for c in S: + if c == ""S"": + num_s += 1 + else: + if num_s > 0: + num_s -= 1 + else: + ans += 1 + +ans += num_s + +print(ans) +" +p02727,s623282099,Wrong Answer,"x,y,a,b,c = map(int,input().split()) +p = list(map(int,input().split())) +q = list(map(int,input().split())) +r = list(map(int,input().split())) + +p.sort() +q.sort() +r.sort() +l = p[a-x:a] + q[b-y:b] +l.sort() + +j = 0 +for i in range(min(c,x+y)): + if l[j] < r[i]: + l[j] = r[i] + j += 1 +print(sum(l))" +p03338,s985450280,Accepted,"N = int(input()) +S = input() + +ans = 0 + +for i in range(1,N): + left = S[:i] + right = S[i:] + tmp = 0 + for alpha in 'qwertyuiopasdfghjklzxcvbnm': + if alpha in left and alpha in right: + tmp += 1 + ans = max(ans,tmp) + +print(ans)" +p02838,s592462598,Accepted,"#!/usr/bin/env python3 +import numpy as np + +n = int(input()) +a = np.array(list(map(int, input().split()))) +mod = 10 ** 9 + 7 +ans = 0 + +for j in range(60): + li = (a >> j) & 1 + i = np.count_nonzero(li) + o = n - i + ans += o * i * 2 ** j + +print(ans % mod) +" +p02859,s920979731,Wrong Answer,"r=int(input()) +print(int(22/7*r**2))" +p03339,s917269609,Wrong Answer,"N = int(input()) +S = list(input()) + +Lw = 0 +Re = S.count(""E"") +ans_lst = [Lw+Re]*(N) + +# i+1をリーダーとみなす +for i in range(1,N): + if S[i-1] == ""W"": + Lw += 1 + else: + Re -= 1 + ans_lst[i] = Lw + Re + print(Lw, Re ,ans_lst[i]) + +ans = min(ans_lst) +print(ans) +" +p03160,s550679715,Accepted,"n=int(input()) +h=list(map(int,input().split())) +dp=[0]*n +dp[0]=0 +dp[1]=abs(h[1]-h[0]) +for i in range(2,n): + dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) +print(dp[n-1])" +p02556,s877332608,Accepted,"#E_Manhattan +n = int(input()) +a, b = [],[] +for i in range(n): + x, y = map(int, input().split()) + a.append(x+y) + b.append(x-y) +a.sort() +b.sort() +ans = max(a[-1]-a[0], b[-1]-b[0]) +print(ans)" +p03815,s500117392,Accepted,"x = int(input()) +c = 2 * (x // 11) +if x % 11 == 0: + pass +elif x - 11 * (x // 11) > 6: + c += 2 +else: + c += 1 +print(c) +" +p03221,s407245921,Wrong Answer,"n, m = map(int, input().split()) + +p = [[] for _ in range(n)] + +for i in range(m): + x, y = map(int, input().split()) + x -= 1 + p[x].append(y) + +for i in range(n): + p[i].sort() + city_cnt = 1 + for j in p[i]: + p_num = str(i + 1) + ans = '0' * (6 - len(p_num)) + ans += p_num + city_num = str(city_cnt) + ans += '0' * (6 - len(city_num)) + ans += city_num + city_cnt += 1 + print(ans) +" +p03493,s795094233,Accepted,"s = input() + +print(s.count('1')) +" +p03645,s246097090,Wrong Answer,"n, m = map(int, input().split()) +A, B = [], [] +ans = 'IMPOSSIBLE' +for i in range(m): + a, b = map(int, input().split()) + A.append(a) + B.append(b) +now = A[0] +result = n in B +if result == False: + print(ans) + exit() +else: + be = B.index(n) + before = A[be] + for i in range(m): + if B[i] == before: + if A[i] == now: + ans = 'POSSIBLE' + break +print(ans)" +p03698,s841472728,Accepted,"S=input() +chars = [] +for c in S: + chars.append(c) + +ans = len(S) == len(set(chars)) + +if ans: + print('yes') +else: + print('no')" +p03061,s244460080,Wrong Answer,"n = int(input()) +L = list(map(int,input().split())) + +def gcd(a,b): + while b: + a,b = b,a%b + return a + +l = [0]*(n+1) +r = [0]*(n+1) +for i in range(n): + l[i+1] = gcd(l[i],L[i]) + r[i+1] = gcd(r[i],L[n-i-1]) +r = r[::-1] + +ans = 0 +for i in range(n-1): + ans = max(ans,gcd(l[i],r[i+1])) +print(ans)" +p03126,s222473485,Wrong Answer,"import collections +n, m = map(int, raw_input().split(' ')) +cc = collections.Counter() +for _ in range(n): + for a in map(int, raw_input().split(' ')): cc[a] += 1 +count =0 +for k in cc: + if cc[k] == n: count +=1 +print count" +p02792,s655286603,Wrong Answer,"import queue +import math +import copy +"""""" +N = int(input()) +#S = input() +# (N,M) = (int(i) for i in input().split("" "")) +# A = [int(i) for i in input().split()] +A = [] +for i in range(N): + A.append(int(input())) + +print(A) + +"""""" + +N = int(input()) +mp = [[0 for j in range(10)]for i in range(10)] +for i in range(N): + j = i + + while j >= 10: + j //= 10 + + mp[j][i%10] += 1 +ans = 0 +for i in range(1,10): + for j in range(1,10): + ans += mp[i][j]*mp[j][i] +print(ans)" +p03067,s441098583,Accepted,"a,b,c = (int(x) for x in input().split()) +if a= before_num: + ans += num_count - before_num + else: + ans += num_count + num_count = 1 + before_num = num + +print(ans) +" +p03804,s166714664,Wrong Answer,"N,M=map(int, input().split()) +A = [input() for i in range(N)] +B = [input() for i in range(M)] + +for i in range(N-M+1): + for j in range(N-M+1): + t = True + for k in range(M): + if B[k] != A[i+k][j:j+M]: + t = False + if t: + print(""Yes"") + exit() +print(""No"")" +p03386,s027614364,Accepted,"A,B,K = map(int,input().split()) +ans = [] +for i in range(A,min(A+K,B)): + ans.append(i) +for j in range(max(A,B-K+1),B+1): + ans.append(j) +ans = list(set(ans)) +ans.sort() +for h in ans: + print(h)" +p03814,s240544060,Accepted,"s=list(input()) +for i in range(len(s)): + if s[i]==""A"": + start=i + break +for j in reversed(range(0,len(s))): + if s[j]==""Z"": + last=j + break +print(last-start+1)" +p02959,s236479825,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +dp = [0]*N #勇者が倒す数 + +for i in range(N): + dp[i] = min(A[i], B[i]) + A[i] -= dp[i] + B[i] -= dp[i] + rem = A[i] + if rem==0: + dp[i] += min(A[i+1], B[i]) +print(sum(dp))" +p03030,s067592235,Wrong Answer,"n = int(input()) +n_list = [0]*n +for i in range(n): + n_list[i] = input().split() + n_list[i].append(i+1) +for i in range(n): + n_list[i][1] = int(n_list[i][1]) +n_list.sort() +n_list.append(""dum"") +print(n_list) +L = 0 +for i in range(n): + if n_list[i][0] != n_list[i+1][0]: + for j in range(i,L-1,-1): + print(n_list[j][2]) + L = i+1" +p03163,s778487414,Accepted,"N, W = map(int, input().split()) +wv = [list(map(int, input().split())) for _ in range(N)] + +dp = [-1 for _ in range(W + 1)] # dp[重量の総和]:= 価値の総和 +dp[0] = 0 + +for i in range(N): + w, v = wv[i] + for j in range(W, -1, -1): + if dp[j] >= 0 and j + w <= W: + dp[j+w] = max(dp[j+w], dp[j]+v) + +print(max(dp))" +p02633,s827094078,Wrong Answer,"b3=[39, 78, 156, 161, 175, 168] +a=int(input()) +b=360/a +b2=str(b) +head, sep, tail = b2.partition('.') +for c in b3: + if c==a: + print(int(head)) +if tail=='0': + print(int(b)) +else: + print(int(head)+1)" +p03293,s820799433,Accepted,"s = input() +t = input() +n = len(s) + +for i in range(n): + if t == s: + print('Yes') + exit() + else: + s = s[-1] + s[:-1:] + +print('No')" +p02813,s855627113,Accepted,"import itertools + +N = int(input()) +P = list(map(int, input().split("" ""))) +Q = list(map(int, input().split("" ""))) +a, b = 0, 0 + +for i, perm in enumerate(itertools.permutations(range(N))): + if all([p1 == (p2 + 1) for p1, p2 in zip(P, perm)]): + a = i + if all([p1 == (p2 + 1) for p1, p2 in zip(Q, perm)]): + b = i + +print(abs(a - b)) +" +p02947,s514886820,Accepted,"n=int(input()) +ans=0 +lis=[] +def cnt(n): + ret=0 + for i in range(1,n): + ret+=i + return ret +for i in range(n): + lis.append(sorted(list(input()))) +co=1 +lis.sort() +bef=lis[0] + +for i in lis[1:]: + if bef!=i: + ans+=cnt(co) + co=1 + bef=i + else: + co+=1 +ans+=cnt(co) +print(ans)" +p03455,s897602689,Wrong Answer,"a, b = map(int, input().split()) + +answer = a * b + +if answer / 2 == 0: + print('Odd') +else: + print('Even')" +p03799,s334201016,Wrong Answer,"n,m=map(int,input().split()) +cnt_s=n +cnt_c=m +ans=0 +if cnt_s>2*cnt_c: + ans=cnt_c//2 + print(ans) +elif cnt_s<=2*cnt_c: + ans+=n + cnt_c-=2*n + ans+=cnt_c//4 + print(ans) + +" +p03264,s166027776,Accepted,"x=range(1,int(input())+1) +y=[t for t in x if t%2==0] +z=[t for t in x if t%2==1] +print(len(y)*len(z))" +p03814,s730664261,Wrong Answer,"import sys +sys.setrecursionlimit(4100000) +import math +import itertools +INF = float('inf') +from heapq import heapify, heappop, heappush +import collections +import bisect + +def main(): + S = input() + + l = 0 + r = 0 + for i in range(len(S)): + if l==0 and S[i]=='A': + l = i + elif S[i]=='Z': + r = i + print(r - l + 1) + + +if __name__ == '__main__': + main() +" +p03220,s942807649,Wrong Answer,"n = int(input()) +x = list(map(int, input().split())) +h = list(map(int, input().split())) + +t = x[0] +a = x[1] +cnt = 1000000000000000000000 +ans = 0 +for i in range(n): + tmp = abs(t*h[i] - a) + if cnt > tmp: + cnt = tmp + ans = i+1 +print(ans)" +p03611,s598603362,Wrong Answer,"import sys +import numpy as np +input = sys.stdin.readline +N = int(input()) +a = list(map(int, input().split())) +k = [0] * (max(a)+1) + +for p in a: + k[p] += 1 +ans = 0 +for q,r,s in zip(k, k[1:] , k[2:]): + ans = max(ans, q+r+s) + +print(ans)" +p02727,s461374655,Wrong Answer,"x,y,a,b,c=map(int,input().split()) +p=sorted(list(map(int,input().split())),reverse=True) +q=sorted(list(map(int,input().split())),reverse=True) +r=sorted(list(map(int,input().split())),reverse=True) +p=p[:x] +q=q[:y] +ans=sum(p)+sum(q) + +while p[-1] sorted_ab[i][1]: + price += sorted_ab[i][0] * sorted_ab[i][1] + m -= sorted_ab[i][1] + else: + price += m * sorted_ab[i][0] + break + +print(price)" +p03137,s083384954,Accepted,"N, M = map(int, input().split()) +X = list(input().split()) +MAP = list(sorted([int(X[i]) for i in range(M)])) + +if M <= N: + print(0) +else: + MAP_diff = list(sorted([MAP[i+1] - MAP[i] for i in range(M-1)])) + print(sum(MAP_diff[:M-N]))" +p02613,s915705386,Wrong Answer,"n=int(input()) +d=dict() +d[""AC""]=0 +d[""WA""]=0 +d[""TLE""]=0 +d[""RE""]=0 +for i in range(n): + s=str(input()) + d[s]+=1 +print(""AC ×"",end="" "") +print(d[""AC""]) +print(""WA ×"",end="" "") +print(d[""WA""]) +print(""TLE ×"",end="" "") +print(d[""TLE""]) +print(""RE ×"",end="" "") +print(d[""RE""])" +p03486,s429508893,Wrong Answer,"s = list(input()) +t = list(input()) +s.sort() +t.reverse() + +S=''.join(map(str, s)) +T=''.join(map(str, t)) +if S=10 else r+100*(10-n))" +p03448,s297236877,Accepted,"A,B,C,X=[int(input()) for i in range(4)] + +print([500*a+100*b+50*c for c in range(C+1) for b in range(B+1) for a in range(A+1)].count(X))" +p02571,s378640803,Wrong Answer,"s=str(input()) +t=str(input()) +lens=len(s) +lent=len(t) +cnt=1000 +for i in range(lens-lent): + temp=0 + for j in range(lent): + if t[j]!=s[i+j]: + temp+=1 + if temp x: + y = a[i] + a[i+1] - x + count += y + a[i+1] = max(0, a[i+1]-y) +print(count)" +p02546,s263254582,Accepted,"s = input() +l = [] +for i in range(len(s)): + l.append(s[i]) +if l[len(l)-1] == ""s"": + print(s+str(""es"")) +else: + print(s+str(""s"")) +" +p03127,s543983049,Accepted,"def gcd(a, b): + if a= lst[1] else lst[1]) + +" +p03030,s973169075,Accepted,"n= int(input()) +x = [input().split() for i in range(n)] +for i in range(n): + x[i].append(i+1) +y= sorted(x,key= lambda i:(i[0],-int(i[1]))) +for i in range(n): + print(y[i][2])" +p02755,s106229487,Wrong Answer,"#output <= 1000 + +nums = [int(e) for e in input().split()] +for i in range(1,1001): + if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])): + print(i) + else: + print(-1)" +p03486,s064682616,Accepted,"s = input() +t = input() + +N, M = len(s), len(t) +min_len = min(N, M) + +s_ = sorted(s) +t_ = sorted(t, reverse=True) + + +for a, b in zip(s_, t_): + if a == b: + continue + elif a > b: + print('No') + exit() + else: + print('Yes') + exit() + +if N < M: + print('Yes') +else: + print('No')" +p03557,s438322174,Wrong Answer,"import bisect + +N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) + +A.sort() +B.sort() +C.sort() + +ans = 0 +for b in B: + a = bisect.bisect_left(A, b) + b = bisect.bisect_right(C, b) + ans += (a + 1)*b + +print(ans)" +p02820,s825101630,Accepted,"N, K = map(int, input().split()) +R, S, P = map(int, input().split()) +T = list(input()) + +for i in range(N-K): + if T[i+K] == T[i]: + T[i+K] = 0 + +print(T.count(""r"")*P+T.count(""s"")*R+T.count(""p"")*S)" +p02713,s814585274,Wrong Answer,"import math + +K = int(input()) + +_sum = 0 +_sum = sum([i for i in range(1, K)]) +_sum += sum([sum([math.gcd(i, j)*6 for i in range(j+1, K)]) for j in range(1, K)]) + +for a in range(1, K): + for b in range(a+1, K): + for c in range(b+1, K): + _sum += math.gcd(math.gcd(a, b), c) +print(_sum)" +p04045,s807211132,Wrong Answer,"import sys + +N, _ = map(int, input().split()) +D = input().split() + +answer = sys.maxsize +for x in range(N, 10000): + s = str(x) + if all([y not in s for y in D]): + answer = min(answer, x) +print(answer) +" +p03471,s357144040,Accepted,"a,b=map(int,input().split()) +c=-1 +d=-1 +e=-1 +x=b//10000 +for i in range(0,x+1,1): + y=(b-10000*i)//5000 + for j in range(0,y+1,1): + k=(b-10000*i-5000*j)//1000 + if i+j+k==a: + c=i + d=j + e=k +print(c,d,e)" +p03351,s729469198,Accepted,"a, b, c, d = map(int, input().split()) +print(""Yes"" if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d else ""No"")" +p02641,s347473681,Accepted,"X,N=map(int,input().split()) +if N==0: + print(X) +else: + a = list(map(int,input().split())) + res = 10**9 + mi = 10**9 + for val in range(200,-100,-1): + if val not in a: + tmp = abs(X-val) + if res >= tmp: + res = tmp + mi = val + print(mi)" +p04030,s561787459,Accepted,"s = input() +n = len(s) +d = [] +for i in range(n): + if s[i] == 'B': + if len(d) > 0: + d.pop() + else: + d.append(s[i]) +print(''.join(d)) +" +p03481,s457006107,Accepted,"X,Y=map(int,input().split()) +for i in range(1,1000): + if X*(2**i)>Y: + print(i) + exit()" +p03309,s091349688,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +B=[] +for i in range(N): + B.append(A[i]-(i+1)) +B.sort() +if N%2==0: + a=N/2 +else: + a=(N+1)/2 +b=B[int(a-1)] +for i in range(N): + B[N-1]=abs(B[N-1]-b) +print(sum(B)) + + + " +p02935,s833591220,Wrong Answer,"import numpy as np +N = int(input()) +M = np.fromiter(input().split(), dtype=int) +K = (0.5) ** np.arange(1, N+1) +print(np.dot(M, K))" +p03221,s397430583,Accepted,"N, M = map(int, input().split()) +piys = [[] for _ in range(N)] +for i in range(M): + p, y = map(int, input().split()) + piys[p-1].append((y, i)) + +ans = [None]*M +for p, iys in enumerate(piys): + iys.sort() + for k, (y, i) in enumerate(iys): + ans[i] = ""%06d%06d"" % (p+1, k+1) + +for i in ans: + print(i)" +p02910,s859181972,Wrong Answer,"S = input() +if ""L"" in S[::2] and ""R"" in S[1::2]: + print(""Yes"") +else: + print(""No"")" +p02600,s081837287,Accepted,"import sys + +input = sys.stdin.readline + +n = int(input()) + +print(8 - int((n - 400) / 200)) +" +p03836,s495232025,Accepted,"sx, sy, tx, ty = [int(n) for n in input().split()] +dx = tx - sx +dy = ty - sy +print('U'*dy+'R'*dx, end="""") +print('D'*dy+'L'*dx, end="""") +print('L'+'U'*(dy+1)+'R'*(dx+1)+'D', end="""") +print('R'+'D'*(dy+1)+'L'*(dx+1)+'U') +" +p02854,s513039205,Accepted,"import itertools + +N = int(input()) +A = [int(x) for x in input().split()] + +reg = 10**12 +Acum = list(itertools.accumulate(A)) +for i in range(N): + L = Acum[i] + R = Acum[-1] - L + tmp = abs(L-R) + reg = min(reg, tmp) +print(reg)" +p02918,s812398773,Wrong Answer,"N, K = map(int,input().split()) +S = list(input()) + +not_happy = 0 +R = 0 +R_edge = 0 + +for i in range (N-1): + if S[i] == ""R"" and S[i+1] == ""L"": + R += 1 + +if S[0] == ""L"": + R_edge +=1 +if S[N-1] == ""R"": + R_edge +=1 + +#print(R) +#print(R_edge) + +if K <= R: + R -= K +elif K <= R + R_edge: + R = 0 + R_edge -= K - R +else: + R = 0 + R_edge = 0 + +not_happy = R*2 + R_edge +happy = N - not_happy + +#print(R) +#print(R_edge) +#print(not_happy) +print(happy) + +" +p02748,s926722896,Accepted,"A, B, M = map(int, input().split()) +*a, = map(int, input().split()) +*b, = map(int, input().split()) +x, y, c = [], [], [] +for _ in range(M): + xa, ya, ca = map(int, input().split()) + x += [xa]; y += [ya]; c += [ca] +mi = min(a[x[i]-1] + b[y[i]-1] - c[i] for i in range(M)) +print(min(mi, min(a)+min(b)))" +p03438,s493431397,Accepted,"n = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +m = sum(B)-sum(A) +cnt1 = 0 +cnt2 = 0 +for a, b in zip(A, B): + if a > b: + cnt1 += (a-b) + elif a < b: + cnt2 += (b-a+1)//2 + else: + pass + +if cnt1 <= m and cnt2 <= m: + print('Yes') +else: + print('No') +" +p02731,s616020590,Accepted,"import math + +L = int(input()) +a = L/3 +print(pow(a, 3)) +" +p02862,s229352034,Wrong Answer,"X,Y = map(int, input().split()) + +mod=10 ** 9 + 7 +def binomial(n,k): + x=1 + y=1 + for i in range(k): + x=x*(n-i)%mod + y=y*(i+1)%mod + return x*pow(y,mod-2,mod)%mod + +if (2*X-Y)%3==0 and (2*Y-X)%3==0: + a=(2*X-Y)//3 + b=(2*Y-X)//3 + if a<0 and b<0: + print(0) + else: + print(binomial(a+b,a)%mod) +else: + print(0)" +p02681,s766050590,Wrong Answer,"import sys +import math +from functools import reduce +from operator import mul +sys.setrecursionlimit(10**6) + +def InMap(): return list(map(int, sys.stdin.readline().split(' '))) +def In(): return int(sys.stdin.readline()) +def InS(): return sys.stdin.readline() + +S = InS() +T = InS() + +if S[:-2:] == T[:-3:]: + print(""Yes"") +else: + print(""No"")" +p03632,s561937121,Accepted,"a, b, c, d = map(int, input().split()) +s = max(a, c) +e = min(b, d) +print(e - s if e - s > 0 else 0)" +p03379,s929151102,Wrong Answer,"n=int(input()) +l=list(map(int,input().split())) +l.sort() +for i in range(1,n+1): + if i<=n//2: + print(l[n//2]) + else: + print(l[n//2-1])" +p02683,s989809538,Accepted,"n,m,x = list(map(int,input().split())) +b = [] +import numpy as np +for i in range(n): + ca = list(map(int,input().split())) + b.append(ca) +b = np.array(b) +ans = float('inf') +for i in range(1<>k&1)==1: + num += b[k] + if (num[1:]>=x).sum()==m: + ans = min(ans, num[0]) +print(ans if ans!=float('inf') else -1)" +p02756,s710516689,Wrong Answer,"s=list(input()) +n=int(input()) +count=0 +for i in range(n): + a=list(input().split()) + if len(a)==1: + count+=1 + else: + if count%2==0: + if a[1]=='1': + s.insert(0,a[2]) + else: + s.insert(-1,a[2]) + else: + if a[1]=='1': + s.insert(-1,a[2]) + else: + s.insert(0,a[2]) +if count%2==0: + print(''.join(s)) +else: + print(''.join(reversed(s)))" +p02771,s543717458,Accepted,"ri = lambda S: [int(v) for v in S.split()] +def rii(): return ri(input()) + +A, B, C = rii() + +print(""Yes"" if len(set([A, B, C])) == 2 else ""No"")" +p03645,s948306325,Accepted,"n,m=map(int,input().split()) +d={}#{中継地:(1 or n)} +flag=False + +for i in range(m): + a,b=map(int,input().split()) + if a==1: + try: + flag=(d[b]==n) + except: + d[b]=1 + elif b==n: + try: + flag=(d[a]==1) + except: + d[a]=n + if flag: + print('POSSIBLE') + break + +if not flag: + print('IMPOSSIBLE') +" +p02780,s197733631,Accepted,"n, k = map(int, input().split()) +p = [(int(p) + 1) / 2. for p in input().split()] +sumexp = sum(p[:k]) +maxexp = sumexp +for i in range(n-k): + sumexp += p[i+k] - p[i] + if sumexp > maxexp: + maxexp = sumexp +print(maxexp)" +p02584,s295508610,Accepted,"x , k , d= map(int, input().split()) + +t = abs(x)/d +t2 = abs(x)//d +if t>=k: + print(abs(x)-k*d) +else: + x = abs(x)-t2*d + if (k-t2)%2==0: + print(x) + else: + print(d-x) +" +p02951,s209809848,Wrong Answer,"a, b, c = map(int,input().split()) + +print(c-a+b)" +p02629,s725002428,Accepted,"N = int(input()) +ans = '' +while N > 0: + N -= 1 + ans += chr(ord('a') + N % 26) + N //= 26 +print(ans[::-1])" +p02641,s649708964,Accepted,"X, N = map(int, input().split()) +P = list(map(int, input().split())) +ans = -1 +mi = 1000 +for i in range(102): + if i in P: + continue + if abs(i-X) < mi: + mi = abs(i-X) + ans = i +print(ans) +" +p02880,s734479458,Wrong Answer,"n = int(input()) + +for i in range(n // 2): + for j in range(n // 2): + if i*j == n: + print('Yes') +print('No')" +p03386,s364934073,Accepted,"a,b,k = map(int,input().split()) +r = range(a,b+1) +for i in sorted (set(r[:k])|set(r[-k:])): + print(i)" +p03162,s697910669,Wrong Answer,"N = int(input()) +a = [0]*N +b = [0]*N +c = [0]*N + +for i in range(N): + a[i], b[i], c[i] = map(int, input().split()) + +dp = [0] * (N+10) +dp[0] = max(a[0], b[0], c[0]) +for i in range(1, N): + if dp[i-1] == a[i-1]: + dp[i] = max(b[i], c[i]) + elif dp[i-1] == b[i-1]: + dp[i] = max(a[i], c[i]) + else: + dp[i] = max(a[i], b[i]) +print(sum([dp[i] for i in range(0, N)]))" +p02597,s643149123,Wrong Answer,"n = int(input()) +c = input() +l = 0 +j = 0 +a = [0]*n +b = [0]*n +for i in range(n): + if(c[i]=='W'): + a[l] =i+1 + l +=1 +l = 0 +for i in range(n-1,0,-1): + if(c[i]=='R'): + b[j] = i+1 + j +=1 +j = 0 +while(a[l] < b[l]): + a[l]=0 + b[l]=0 + l+=1 + j+=1 +print(j)" +p02848,s097895725,Wrong Answer,"N=int(input()) +S=list(input()) +A=[""A"",""B"",""C"",""D"",""E"",""F"",""G"",""H"",""I"",""J"",""K"",""L"",""M"",""N"",""O"",""P"",""Q"",""R"",""S"",""T"",""U"",""V"",""W"",""X"",""Y"",""Z""] +newS=[] +for i in range(len(S)): + for r in range(len(A)): + if S[i]==A[r]: + a=r+N + if r+N>25: + a=(r+N)%25-1 + newS.append(A[a]) +for h in range(len(newS)): + print(*newS[h],end='')" +p03797,s958703440,Accepted,"n,m = map(int,input().split()) +count = 0 +s = 2*n +if m-s < 0: + print(m//2) +else: + m -= s + m = (m//2)//2 + print(n+m) +" +p02691,s598725532,Accepted,"#!/usr/bin/python3 +# -*- coding: utf-8 -*- +n = int(input()) +a_list = list(map(int, input().split())) +l_dict = {} +ans = 0 +for i in range(0, n): + a = a_list[i] + ri = i - a + if ri in l_dict: + ans += l_dict[ri] + li = i + a + if li in l_dict: + l_dict[li] += 1 + else: + l_dict[li] = 1 +print(ans)" +p03377,s023567439,Accepted,"A,B,X = map(int,input().split()) + +if X < A: + print(""NO"") + exit() + +if (A+B) < X: + print(""NO"") +else: + print(""YES"") +" +p03487,s183356509,Accepted,"N = int(input()) +A = input().split() +A = [int(a) for a in A] + +D = {} + +for a in A: + D[a] = D.get(a, 0) + 1 + +cnt = 0 +for k, v in D.items(): + if k < v: + cnt += v - k + elif v < k: + cnt += v +print(cnt) +" +p03479,s249413608,Wrong Answer,"import math +x,y=map(int,input().split()) +a=int(math.log2(y)-math.log2(x)) +print(a+1)" +p02675,s593369929,Accepted,"N = str(input()) +if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9': + print('hon') +elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8': + print('pon') +else: + print('bon')" +p03449,s812461139,Accepted,"from itertools import accumulate +N = int(input()) +A = [list(map(int,input().split())) for _ in range(2)] +acc1 = list(accumulate(A[0], lambda x,y:x+y)) +acc2 = [0]+list(accumulate(A[1], lambda x,y:x+y)) +ma = -1 +for i in range(N): + ma = max(ma, acc2[-1]-acc2[i]+acc1[i]) +print(ma)" +p02802,s651063454,Accepted,"n, m = map(int, input().split()) +ps = [] +memo = [0 for i in range(n)] +pena = [0 for i in range(n)] +for i in range(m): + p, s = input().split() + p = int(p) + if s == ""AC"": + memo[p-1] = 1 + else: + if memo[p-1] == 0: + pena[p-1] += 1 +ans = 0 +for i, p in enumerate(pena): + if memo[i]: + ans += p +print(sum(memo), ans) +" +p03479,s095299826,Wrong Answer,"import math +from decimal import * +X, Y = map(int,input().split()) +getcontext().prec = 40 +log = Decimal(math.log2(Decimal(Y) / Decimal(X))) +print(int(math.modf(log)[1]+1))" +p03073,s392040035,Accepted,"s = list(input()) +n = len(s) +t = 0 +odd = 0 +even = 0 +while t < n: + odd += int(s[t]) + t += 2 +u = 1 +while u < n: + even += int(s[u]) + u += 2 +if n%2 == 0: + print(min(n//2+odd-even,n//2+even-odd)) +else: + print(min(n//2+odd-even,n//2+even+1-odd))" +p02646,s092736096,Wrong Answer,"a, v = map(int, input().split()) +b, w = map(int, input().split()) + +t = int(input()) + +if v == w: + print(""NO"") + +elif (v < w): + ans = (a - b) / (v - w) + if t <= abs(ans): + print(""YES"") + else: + print(""NO"") +else: + ans = (b - a) / (v - w) + if t > ans: + print(""YES"") + else: + print(""NO"") + +" +p03011,s900312471,Accepted,"L = [i for i in map(int,input().split())] +L.sort() +print(L[0]+L[1])" +p02727,s228863580,Wrong Answer,"X, Y, A, B, C = map(int, input().split()) +AA = list(map(int, input().split())) +BB = list(map(int, input().split())) +CC = list(map(int, input().split())) +a = sorted(AA, reverse=True) +b = sorted(BB, reverse=True) +c = sorted(CC, reverse=True) + +if X < A: + del a[X:] + +if Y < B: + del b[Y:] +print(a) +print(b) + +NEW = a + b + c +NEWnew = sorted(NEW, reverse=True) +del NEWnew[X+Y:] +K = sum(NEWnew) +print(K) + + + +" +p03252,s538904050,Wrong Answer,"s=input() +t=input() +d=dict() +flag=True +for i in range(len(s)): + if not(t[i] in d): + d[t[i]]=s[i] + else: + if d[t[i]]!=s[i]: + flag=False + break +if flag: + print(""Yes"") +else: + print(""No"")" +p02600,s607075496,Accepted,"X = int(input()) +print(10 - (X // 200)) +" +p02833,s848160848,Accepted," +def main(): + n = int(input()) + if n%2 == 1: + print(0) + return + + five_cnt = 0 + for i in range(1,25+1): + base = 2*(5**i) + five_cnt += n//base + + print(five_cnt) + +if __name__ == ""__main__"": + main()" +p02832,s364582620,Accepted,"n1 = int(input()) +n2 = [int(i) for i in input().split()] + +t3 = 0 + +for i4 in range(n1): + if n2[i4] != i4 - t3 + 1: + t3 += 1 + + + +if t3 == n1: + print(-1) +else: + print(t3)" +p03493,s861714785,Wrong Answer,"a = str(input()) +k = 0 +for i in a: + print(i) + if i == (""0""): + k += 0 + elif i == (""1""): + k += 1 +print(k) +" +p03493,s152167530,Wrong Answer,"number = input() +count = 0 + +for n in number: + if n == 1: + count += 1 + +print(count)" +p03043,s140405732,Accepted,"from collections import Counter + +n,k=list(map(int,input().split())) +enum=0 +denom=2**20 + +for pip in range(1,n+1): + cnt=0 + score=pip + while score v: + m = v + ans = i + print(ans) + else: + print(x)" +p02789,s698410353,Accepted,"n, m = map(int, input().split()) +if n == m: + print(""Yes"") +else: + print(""No"")" +p04020,s735069605,Wrong Answer,"def Z(): return int(input()) +def ZZ(): return [int(_) for _ in input().split()] + +def main(): + N = Z() + A = [Z() for _ in range(N)] + output = 0 + for i in range(N): + output += A[i]//2 + A[i] %= 2 + for i in range(N-1): + x = min(A[i], A[i+1]) + output += x + A[i] -= x + A[i+1] -= x + print(output) + + return + +if __name__ == '__main__': + main() +" +p02714,s288422979,Wrong Answer,"n=int(input()) +s=input() +ans = 0 + +for i in range(n): + for j in range(n): + for k in range(n): + if s[i] != s[j] and s[i] != s[k] and s[j] != s[k] and i < j and j < k and j-i != k-j: + print(i,j,k) + ans = ans + 1 + +print(ans)" +p03862,s963871672,Wrong Answer,"n,x=map(int,input().split()) +a=list(map(int,input().split())) +ans=0 +if a[0]>x: + ans+=x-a[0] + a[0]=x +for i in range(n-1): + if a[i]+a[i+1]>x: + t=a[i]+a[i+1]-x + a[i+1]-=t + ans+=t +print(ans) +" +p02939,s370415998,Wrong Answer,"S=input() +tmp=S[0] +i=1 +ans=1 +while i=X else ""NO"")" +p02699,s371988468,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +def main(): + s, w = map(int, input().split()) + if w >= s: + print('unsafe') + else: + print('safe') +if __name__ == '__main__': + main() +" +p02854,s518808392,Accepted,"n=int(input()) +a=list(map(int,input().split())) +s=sum(a) +cn=0 +buf=s +for i in range(n): + cn+=a[i] + buf=min(buf,abs(s-2*cn)) +print(buf) +" +p02729,s891050277,Wrong Answer,"a,b=list(map(int, input().split())) +ct=(a*(a-1))//2 +ct+=b +print(ct)" +p02947,s490003020,Accepted,"n = int(input()) +s = {} +ans = 0 +for _ in range(n): + sn = sorted(input()) + sn = ''.join(sn) + + if sn in s: + ans += s[sn] + s[sn] += 1 + else: + s[sn] = 1 + +print(ans)" +p03481,s404036088,Accepted,"#-*-coding:utf-8-*- +import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +def main(): + x,y=map(int,readline().split()) + ans=0 + while x<=y: + x*=2 + ans+=1 + print(ans) + +if __name__==""__main__"": + main()" +p03796,s547612705,Accepted,"N = int(input()) +import math as m +print(m.factorial(N) % (10**9+7))" +p03745,s622279649,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = [] +i = 0 +while i < N - 1: + if A[i] != A[i+1]: + B.append(A[i]) + i += 1 +B.append(A[-1]) + +ans = 1 +i = 0 +while i < len(B) - 2: + if (B[i + 1] - B[i]) * (B[i + 2] - B[i + 1]) < 0: + ans += 1 + i += 2 + else: + i += 1 +print(ans) +" +p02684,s929894370,Wrong Answer,"N,K=map(int, input().split()) +A = list(map(int, input().split())) + +A = [0] + A + +visited = [1] +now = 1 +while True: + next = A[now] + if next in visited: + break + visited.append(next) + now = next + +initial = visited.index(next) +cycle = len(visited[initial:]) + +residual = (K - initial) % cycle +print(visited[initial+residual])" +p02972,s684985588,Accepted,"n = int(input()) +a = list(map(int, input().split())) +b = set() +c = [0]*n + +for i in range(n, 0, -1): + x = 0 + for j in range(2*i, n+1, i): + x+=c[j-1] + if a[i-1] != x%2: + c[i-1] += 1 + b.add(i) +print(len(b)) +print(*b)" +p02784,s973627625,Accepted,"h, n = map(int, input().split()) +a = list(map(int, input().split())) +if sum(a) >= h: print('Yes') +else: print('No')" +p02833,s867003220,Wrong Answer,"import math + +n = int(input()) +c = 10 +ans = 0 +while c <= n: + ans += math.floor(n / c) + c *= 5 +print(ans) +" +p03779,s484090745,Accepted,"N=int(input()) +i=1 +buf=0 +while True: + if (buf0: + if x>0: + x-=1 + cnt+=2 + k-=1 + else: + if y>0: + cnt+=1 + y-=1 + k-=1 + else: + break +print(cnt) +" +p02621,s304381586,Wrong Answer,"a=int(input()) +b=a**a +print(int(a+b+a*b))" +p02797,s663438150,Accepted,"N, K, S=map(int, input().split()) +if S==10**9: + ans=[10**9]*K+[10**9-1]*(N-K) + print(*ans) +else: + ans=[S]*K+[S+1]*(N-K) + print(*ans)" +p02910,s059990604,Accepted,"import sys + +s = input() + +for c in s[::2]: + if(c == 'L'): + print(""No"") + sys.exit() + +for c in s[1::2]: + if(c == 'R'): + print(""No"") + sys.exit() + +print(""Yes"")" +p03407,s229932764,Accepted,"import sys + +sys.setrecursionlimit(10**7) +def I(): return int(sys.stdin.readline().rstrip()) +def MI(): return map(int,sys.stdin.readline().rstrip().split()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり +def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip().split()) #空白あり +def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし + + +A,B,C = MI() +print('Yes' if A+B >= C else 'No') +" +p04020,s100371188,Accepted,"n=int(input()) +ans=int(0) +s=int(0) +for i in range(n): + now=int(input()) + if now==0: + ans+=int(s/2) + s=int(0) + else: + s+=now +ans+=int(s/2) +print(ans)" +p02676,s716469766,Accepted,"import sys +sys.setrecursionlimit(300000) + +def I(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LMI(): return list(map(int, sys.stdin.readline().split())) +MOD = 10 ** 9 + 7 +INF = float('inf') + + +K = I() +S = input() + +if len(S) <= K: + print(S) +else: + print(S[:K] + '...')" +p02753,s718061237,Accepted,"S = input() + +ps = '' +for s in S: + if s != ps and ps != '': + print('Yes') + break + ps = s +else: + print('No')" +p03711,s912394983,Accepted,"g1=[1,3,5,7,8,10,12] +g2=[4,6,9,11] +a,b = map(int,input().split()) +if (a in g1 and b in g1) or (a in g2 and b in g2): + print(""Yes"") +else: + print(""No"")" +p02584,s477386983,Accepted,"x,k,d=map(int,raw_input().split()) + +def solve(x,k,d): + x=abs(x) + if (x>0 and x/d>=k): + x=x-k*d + return x + y=x//d + x-=y*d + k-=y + if k%2==0: + return abs(x) + return min(abs(x+d),abs(x-d)) +print(solve(x,k,d)) +" +p03759,s326370199,Wrong Answer,"A,B,C = list(map(int,input().split())) +if abs(A-B) - abs(B-C) == 0: + print(""YES"") +else: + print(""NO"")" +p03543,s081797789,Accepted,"import sys +s=input() +cnt=1 +for i in range(0, len(s)-1): + if(s[i]==s[i+1]): + cnt+=1 + else: + cnt=1 + if(cnt==3): + print(""Yes"") + sys.exit() +print(""No"") + " +p04043,s571111210,Wrong Answer,"a, b, c = map(int, input().split()) +def iroha(a,b,c): + if (a==5 or a==7) and (b==5 or b==7) and (c==5 or c==7) and a+b+c==17: + if [a,b,c]==[5,7,5]: + return ""NO"" + else: + return ""YES"" + else: + return ""NO"" +print(iroha(a,b,c))" +p02726,s965372999,Accepted,"n, x, y = map(int, input().split()) +c = [0 for _ in range(1, n)] +for i in range(1, n+1): + for j in range(1, n+1): + if i <= j: + continue + a = i - j + b = abs(j - x)+1+abs(i - y) + if a < b: + c[a-1] += 1 + else: + c[b-1] += 1 +for e in c: + print(e)" +p02688,s046709450,Wrong Answer,"N, K = map(int, input().split()) +a = [] +for i in range(K): + di = int(input()) + a.append(map(int, input())) + + + +a = set(a) +print(N - len(a)) + " +p02793,s630896546,Accepted,"from fractions import gcd +N = int(input()) +A = list(map(int,input().split())) +MOD = 10**9+7 + +def lcm(a,b): + g = gcd(a, b) + return a*b // g + +l = 1 +for a in A: + l = lcm(l, a) + +# print(l) + +ans = 0 +for a in A: + ans += l//a + # ans %= MOD + +print(ans%MOD)" +p03493,s875864677,Accepted,"a = input() +count = 0 +if a[0] == '1': + count += 1 +if a[1] == '1': + count += 1 +if a[2] == '1': + count += 1 + +print(count)" +p02727,s636342957,Accepted,"x,y,a,b,c = map(int,input().split()) +P = list(map(int,input().split())) +Q = list(map(int,input().split())) +R = list(map(int,input().split())) +p = sorted(P,reverse=True) +q = sorted(Q,reverse=True) +r = sorted(R,reverse=True) +V = p[0:x] + q[0:y] + r +v = sorted(V,reverse=True) +print(sum(v[0:x+y]))" +p02577,s005510466,Accepted,"total = 0 +for ch in input().strip(): + total = (total + int(ch)) % 9 +print('No' if total else 'Yes') " +p02608,s604972909,Accepted,"N=int(input()) +a=[] +for i in range(N): + a.append(0) +for x in range(1,N+1): + if x**2>=N: + break + for y in range(1,N+1): + if x**2 + y**2 >= N: + break + for z in range(1,N+1): + if x**2+y**2+z**2>=N: + break + t=x**2+y**2+z**2+x*y+y*z+z*x + if t<=N: + a[t-1] += 1 +for m in range(N): + print(a[m])" +p03317,s877529131,Accepted,"import math + +def solve(n, k, A): + return math.ceil((len(A) - A.count(min(A))) / (k - 1)) + +_n, _k = map(int, input().split()) +_A = list(map(int, input().split())) +print(solve(_n, _k, _A)) +" +p03131,s687352334,Accepted,"K,A,B = map(int,input().split()) +if B-A<=2: + print(1+K) +else: + if K<=A-1: + print(1+K) + else: + d = K-(A-1) + if d==1: + print(A+1) + elif d%2==0: + print(B+((d-2)//2)*(B-A)) + else: + print(B+((d-3)//2)*(B-A)+1)" +p03328,s611673978,Accepted,"a, b = map(int, input().split()) +print(((b - a) * (b - a - 1) // 2)- a) +" +p03543,s768446237,Accepted,"s= input() +print(""Yes"" if int(s[:3])%111 == 0 or int(s[1:])%111 == 0 else ""No"") +" +p02717,s327265634,Accepted,"X,Y,Z = map(int, input().split()) +print(Z,X,Y)" +p02768,s331966394,Accepted,"import sys + +sys.setrecursionlimit(100000000) +input = lambda: sys.stdin.readline().rstrip() + +MOD = 10**9 + 7 + +def factorial(a): + return 1 if a == 1 else a * factorial(a - 1) % MOD + +def inverse(x): + return pow(x, MOD - 2, MOD) + +def combination(a, b): + ans = 1 + for i in range(b): + ans = ans * (a - i) * inverse(i + 1) % MOD + return ans + +n, a, b = map(int, input().split()) +ans = pow(2, n, MOD) - 1 +ans -= combination(n, a) + combination(n, b) +print(ans % MOD) +" +p03605,s493972827,Accepted,print('Yes' if '9' in list(input()) else 'No') +p02987,s505840731,Accepted,"s = input() +if len(set(s)) == 2 and s.count(s[0]) == 2: + print('Yes') +else: + print('No')" +p02658,s962303753,Accepted,"import sys +n = int(input()) +numlist = list(map(int, input().split())) +if 0 in numlist: + print(0) +else: + ans = 1 + for i in numlist: + ans *= i + if ans > 10**18: + print(""-1"") + sys.exit() + print(ans)" +p03073,s369863725,Wrong Answer,"s=input() +t=s[::2] +u=s[1::2] +a=t.count(""0"") +b=u.count(""0"") +if len(s)==1: + print(0) +if a>=b: + print(len(t)-a+b) +else: + print(len(u)-b+a)" +p03796,s487797944,Wrong Answer,"mycode = ''' +# distutils: language=c++ +# cython: language_level=3, boundscheck=False, wraparound=False +# cython: cdivision=True + +ctypedef long long LL +cdef LL MOD = 10**9 + 7 +cdef LL N = int(input()) +cdef LL ans = 1 + +cdef i +for i in range(2, N + 1): + ans *= i + ans %= MOD +print(ans) +''' +import sys +import os +if sys.argv[-1] == 'ONLINE_JUDGE' or os.getcwd() == '/imojudge/sandbox': # コンパイル時 or コードテスト時 + with open('mycode.pyx', 'w') as f: + f.write(mycode) + os.system('cythonize -i -3 -b mycode.pyx') + +import mycode +" +p02572,s281461607,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) + +S = sum(A) +S2 = sum(map(lambda x: x*x,A)) + +print((S*S - S2) / 2 % 1000000007)" +p02688,s391630503,Accepted,"N, K = map(int, input().split()) +st = set() +for _ in range(K): + input() + st |= set(map(int, input().split())) +print(len(set(range(1, N + 1)) - st)) +" +p02882,s688503327,Accepted,"import math + +a,b,x = map(int,input().split()) + +tr = a*a*b/2 + +if x <= tr: + rlt = (180/math.pi)*math.atan2(a*b**2, 2*x) +else: + rlt = (180/math.pi)*math.atan2(2*(a**2*b - x), a**3) + +print(rlt)" +p03239,s100498106,Wrong Answer,"N,T = map(int,input().split()) +CT = [] +for n in range(N): + c,t = map(int,input().split()) + CT.append([c,t]) +CT = sorted(CT,key=lambda x: x[0]) +for ct in CT: + if ct[1] <= T: + print(ct[0]) + break +" +p02607,s978630018,Accepted,"n = int(input()) +a = list(map(int, input().split())) +c = 0 +for i in range(0, n, 2): + if a[i] % 2 != 0: + c += 1 +print(c) +" +p02711,s307889073,Wrong Answer,"n='str(input())' +for i in range(len(n)): + if n[i]=='7': + print('Yes') + exit() +print('No')" +p03854,s450890009,Accepted,"s=input() +l=len(s) +def judge(): + cnt=0 + while True: + if s[l-cnt-6:l-cnt]=='eraser': + cnt+=6 + elif s[l-cnt-5:l-cnt]=='erase': + cnt+=5 + elif s[l-cnt-7:l-cnt]=='dreamer': + cnt+=7 + elif s[l-cnt-5:l-cnt]=='dream': + cnt+=5 + else: + print('NO') + exit() + if cnt==len(s): + print('YES') + exit() + +judge()" +p03137,s160648677,Accepted,"n,m = map(int,input().split()) +x = [int(x) for x in input().split()] +x.sort() + +if n > m: + print(0) +else: + ans = [] + for i in range(m-1): + ans.append(x[i+1] - x[i]) + ans.sort() + print(sum(ans[0:(m-n)])) +" +p03011,s737980718,Accepted,"p,q,r = map(int, input().split()) +print(min(min(p+q,p+r),r+q))" +p02996,s425059661,Accepted,"N = int(input()) +s = [] +now = 0 +simekiri = 0 +flag = 0 +for i in range(N): + a,b = map(int,input().split()) + s.append([b,a]) +s.sort() +for i in range(N): + now += s[i][1] + simekiri = s[i][0] + if now>simekiri: + print(""No"") + flag = 1 + break +if flag == 0: + print(""Yes"")" +p03815,s460349579,Wrong Answer,"import sys +import itertools +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +import math +import collections +MOD = 10**9 + 7 +x = int(input()) +cnt = 0 +if x<=6: + print(1) +elif x<=11: + print(2) +else: + if x%11 == 0: + print((x//11)*2) + else: + print((x//11)*2 + 1)" +p03693,s153287914,Accepted,"# 入力 +r, g, b = map(int, input().split()) + +# 出力 +if 1 <= r and g and b <= 9: + if ((r * 100) + (g * 10) + b) % 4 == 0: + print('YES') + else: + print('NO') +" +p02910,s463458162,Accepted,"a = [""R"", ""U"", ""D""] +b = [""L"", ""U"", ""D""] +s = input() +iscan = True +for i in range(len(s)): + if i%2 == 0: + if s[i] not in a: + iscan = False + else: + if s[i] not in b: + iscan = False +print(""Yes"" if iscan else ""No"") +" +p02623,s509508239,Wrong Answer,"N, M, K = map(int, input().split()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +min = 0 +cnt = 0 +for i,k in enumerate(b): + min += k +j = i +for i in range(N): + while(j > 0 and min > K): + j -= 1 + min -= b[j] + if(min > K): + break + cnt = max(cnt, i + j) + if(i == N): + break + min += a[i] +print(cnt) +" +p02696,s469800146,Accepted,"ABN = input().split() +A = int(ABN[0]) +B = int(ABN[1]) +N = int(ABN[2]) + +answer = 0 +temp = 0 + +if N >= B: + answer = A*(B-1) // B - A * ((B-1)//B) + +else: + answer = A*N //B - A * (N//B) + +print(answer)" +p03545,s246405850,Accepted,"l = list(input()) +n = len(l) + +def dfs(i,f,sum): + if i == n-1: + if sum == 7: + print(f+""=7"") + exit() + + else: + dfs(i+1,f+""+""+l[i+1],sum+int(l[i+1])) + dfs(i+1,f+""-""+l[i+1],sum-int(l[i+1])) + +dfs(0,l[0],int(l[0])) + + +" +p03803,s425199652,Accepted,"a, b = input().split() +l = [""2"", ""3"", ""4"", ""5"", ""6"", ""7"", ""8"", ""9"", ""10"", ""11"", ""12"", ""13"", ""1""] +if l.index(a) > l.index(b): + print(""Alice"") +elif l.index(a) == l.index(b): + print(""Draw"") +else: + print(""Bob"")" +p02771,s298763075,Accepted,"a = map(int, input().split()) +if len(set(a)) == 2: + print('Yes') +else: + print('No')" +p02719,s349229837,Accepted,"N, K = list(map(int, input().split())) +if N > K: + p = (N - 1)//K + N_p = N - p*K + N_q = -(N_p - K) + ans = min(N_p, N_q) +else: + ans = min(N, K-N) +print(ans)" +p03474,s973079970,Accepted,"a,b=map(int, input().split()) +s = input() +for i in range(len(s)): + if i == a: + if s[i] != ""-"": + print(""No"") + break + else: + if not ""0"" <= s[i] <= ""9"": + print(""No"") + break +else: + print(""Yes"")" +p03086,s085559014,Wrong Answer,"S=input() +count=0 +max_count=-1 +for i in range(len(S)): + if S[i]!=""A"" and S[i]!=""C"" and S[i]!=""G"" and S[i]!=""T"": + count=count+1 + else: + if max_count0: + m.sort(reverse=True) + return solve(m) + else: + return(m) +ans=solve([n]) +for i in ans: + print(i)" +p03075,s414943741,Wrong Answer,"L = [int(input()) for i in range(5)] +k = int(input()) +for i in range(4): + if L[i+1]-L[i] > k: + print("":("") + quit() +print(""Yay!"")" +p02646,s397820477,Accepted,"a,b=map(int,input().split()) +v,w=map(int,input().split()) +t=int(input()) +if a<=v: + d1 = a + t*b + d2 = v + t*w + if d1>=d2: + print('YES') + else: + print('NO') +else: + d1 = a - t*b + d2 = v - t*w + if d1<=d2: + print('YES') + else: + print('NO')" +p02988,s895778546,Accepted,"# coding: utf-8 +# Your code here! + +def MI():return map(int,input().split()) +def LI():return list(MI()) + +n,*p=map(int,open(0).read().split()) + +cnt=0 +for a,b,c in zip(p[0:],p[1:],p[2:]): + if a>b>c or a= x: + print('Yes') +else: + print('No')" +p03331,s435538005,Accepted,"numero = int(input()) +soma = 0 +minimo = 100000 +for aux in range(numero-1,1,-1): + prim = str(aux) + seg = str(numero - aux) + for x in range(len(prim)): + soma += int(prim[x]) + for x in range(len(seg)): + soma += int(seg[x]) + if soma < minimo : + minimo = soma + soma = 0 +if numero == 2: + print(numero) +else: + print(minimo)" +p02786,s137543755,Wrong Answer,"import math +h=int(input()) +n=math.floor(math.log2(h)) +x=0 +for i in range(n+1): + x+=2**i // 2^i +print(x)" +p02729,s209962948,Wrong Answer,"S = input() +N = len(S) + +def is_palindrome(s): + return s == s[::-1] + +if is_palindrome(S) \ +and is_palindrome(S[:int((N-1)/2)]) \ +and S[:int((N-1)/2)] == S[int((N+3)/2-1):]: + print('Yes') +else: + print('No')" +p03761,s864198615,Wrong Answer,"import collections +n = int(input()) +s = [[] for _ in range(n)] +l = [collections.defaultdict(lambda:0) for _ in range(n)] +for i in range(n): + s[i] = list(input()) + for j in s[i]: + l[i][j] += 1 + print(l) +mind = [float(""inf"")]*26 +for i in range(26): + for j in range(n): + mind[i] = min(mind[i],l[j][chr(97+i)]) +ans = """" +for i in range(26): + ans += chr(97+i)*mind[i] +print(ans)" +p02789,s473181823,Accepted,"N, M = map(int, input().split()) +if N == M: + print('Yes') +else: + print('No') + " +p02923,s501857361,Accepted,"N = int(input()) +H = list(map(int, input().split())) +sub = [] +for i in range(N-1): + sub.append(H[i+1]-H[i]) +#print(sub) +ans = 0 +tmp = 0 +for s in sub: + if s <= 0: + tmp += 1 + else: + ans = max(ans, tmp) + tmp = 0 +ans = max(ans, tmp) + + +print(ans) + + + + +" +p03289,s284449874,Wrong Answer,"S = str(input()) + +result = False + +if S[0] == 'A': + + check = S[2:len(S)-1] + + if check.count('C') == 1: + + result = check[1:] + + result = result.replace('C','') + + if result.islower(): + result = True + + + + +if result: + print('AC') +else: + print('WA') + + " +p03795,s167488013,Accepted,"a=int(input()) #fjfkdajadjgkalds;fj'kaskajlsjfdka's +b=a//15 +c=a*800-b*200 +print(c)" +p02665,s217265589,Accepted,"n,*l=map(int,open(0).read().split()) +e=[1] +for i in range(n): e+=[(e[-1]-l[i])*2] +a=t=0 +for i in range(n,-1,-1): + if l[i]>e[i]: print(-1); break + t=min(l[i]+t,e[i]); a+=t +else: print(a)" +p03456,s421892136,Accepted,"import math +a,b = input().split() + + +s = int(a+b) + +if math.sqrt(s)%1 == 0: + print(""Yes"") +else: + print(""No"")" +p04020,s343438355,Accepted,"N = int(input()) +ans = 0 +B = 0 +for i in range(N): + A = int(input()) + C = A+B + ans += C//2 + if B == 1 and C == 1: + B = 0 + continue + B = C % 2 +print(ans) +" +p03146,s470737440,Accepted,"k = input().split() +a = int(k[0]) + +def b(n): + return int(n/2) +def c(n): + return int((3*n)+1) + +Counter = 0 + +flag = True +IntSet = set() +IntSet.add(a) +Buffer = int(a) +for i in range(1,1000000+1): + if Buffer%2 == 0: + Buffer = b(Buffer) + Counter+=1 + else: + Buffer = c(Buffer) + Counter+=1 + if Buffer in IntSet: + print(Counter+1) + break + else: + IntSet.add(Buffer)" +p02795,s924567754,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +h = int(input()) +w = int(input()) +n = int(input()) + +a = 0 +c = 0 + +if h > w: + m = h +else: + m = w + +while a < n: + a += m + c += 1 + +print(c)" +p03944,s256986480,Wrong Answer,"W, H, N = map(int, input().split()) +w = 0 +h = 0 +lx = list() +ly = list() +la = list() +for i in range(1, N+1): + X, Y, A = map(int, input().split()) + lx.append(X) + ly.append(Y) + la.append(A) + if A == 1 and w < X: + w = X + elif A == 2 and X < W: + W = X + elif A == 3 and h < Y: + h = Y + elif A == 4 and Y < H: + H = Y +S = (W - w)*(H - h) +if S < 0: + S = 0 +print(S)" +p02731,s733433578,Wrong Answer,"L = int(input()) + +ans = 0 +for x in range(L): + for y in range(L): + z = L - (x+y) + if z > 0: + ans = max(ans,x*y*z) +print(ans)" +p03379,s167129649,Accepted,"n=int(input()) +x=list(map(int,input().split())) + +z=sorted(x) +r=z[n//2] +l=z[n//2-1] +for i in x: + if i dep: + res += 1 + cnt = 1 + dep = T[i] + k + else: + cnt += 1 + + print(res + 1) + + +if __name__ == '__main__': + resolve() +" +p02631,s123257324,Wrong Answer,"def xor(x): + for i in range(len(x)-1): + x[i+1]=x[i]^x[i+1] + return x[len(x)-1] +N=int(input()) +a=list(map(int,input().split())) +num=xor(a) +for i in range(N): + A=[num,a[i]] + print(xor(A),end="" "")" +p02657,s367831113,Accepted,"a, b = map(int, input().split()) + +print(a*b)" +p02700,s366269030,Accepted," +a, b, c, d = map( int, input().split() ) +#print( a, b, c, d ) + +for i in range( 200 ): + c = c - b + if c <= 0: + print( ""Yes"" ) + exit() + + a = a - d + if a <= 0: + print( ""No"" ) + exit()" +p03449,s455253092,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +ans=0 +for i in range(n): + ans=max(ans,sum(a[:i+1])+sum(b[i:])) +print(ans)" +p02646,s974299146,Accepted,"from sys import stdin +import math +import re +import queue + +input = stdin.readline + +MOD = 1000000007 +INF = 122337203685477580 + + +def solve(): + + A,V = map(int, input().split()) + B,W = map(int, input().split()) + T = int(input().rstrip()) + if(B < A): + V *= -1 + W *= -1 + if (A-B)*(A + T*V - B -T*W) <= 0: + print(""YES"") + else: + print(""NO"") + +if __name__ == '__main__': + solve() +" +p03672,s291795610,Accepted,"s=input() +l=len(s) +for i in range(1,l//2): + k=(l-i*2) + if s[:k//2]==s[k//2:k]: + print(k) + break" +p03210,s762202697,Accepted,"x = input() +if x == ""7"" or x == ""5"" or x == ""3"": + print(""YES"") +else: + print(""NO"")" +p03136,s245467273,Accepted,"def main(): + n = int(input()) + l_list = list(map(int, input().split())) + + sum_l = sum(l_list) + max_l = max(l_list) + + if max_l < sum_l - max_l: + print(""Yes"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main() +" +p03617,s980779475,Accepted,"Q,H,S,D = map(int, input().split()) +N = int(input()) +a = N//2 * 2 +k = min(a*Q*4, a*H*2, a*S, a*D//2) +if N%2 == 1: + k += min(Q*4, H*2, S) +print(k)" +p03693,s096613546,Accepted,"r,g,b=map(int,input().split()) +print(""YES"" if (r*100+g*10+b)%4==0 else ""NO"")" +p02818,s014857085,Wrong Answer,"A, B, K = map(int, input().split()) + +# for i in range(K): +# if A > 0: +# A -= 1 +# elif B > 0: +# B -= 1 + +if A >= K: + A -= K +elif A+B >= K: + A = 0 + B -= K-A + +if B < 0: + B = 0 + +print(A, B)" +p03345,s960056825,Wrong Answer,"a, b, c, k = map(int, input().split()) +if abs(a - b) > 1e18: + print(""Unfair"") +elif k % 2 == 0: + print(b - a) +else: + print(a - b) +" +p02607,s454416435,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +c = 0 +for i in range(n): + if i%2 != 0 and a[i] %2 != 0: + c +=1 +print(c)" +p04034,s522143804,Accepted,"n,m = map(int, input().split()) + +boxl = [1]*(n+1) +redl = [False]*(n+1) +redl[1] = True + +for _ in range(m): + x,y = map(int, input().split()) + if redl[x]: + redl[y] = True + if boxl[x] == 1: + redl[x] = False + boxl[x] -= 1 + boxl[y] += 1 + +ans = 0 +for r in redl: + if r: ans += 1 + +print(ans)" +p03017,s271469385,Accepted,"n, a, b, c, d = map(int, input().split()) +s = input() + +if c < d: + print(""Yes"" if s[a - 1:d].count(""##"") == 0 else ""No"") +else: + print(""Yes"" if s[a - 1:c].count(""##"") == + 0 and s[b - 2:d + 1].count(""..."") > 0 else ""No"")" +p03208,s974317808,Accepted,"import sys +import math +import itertools +import bisect +from copy import copy +from collections import deque,Counter +from decimal import Decimal +def s(): return input() +def k(): return int(input()) +def S(): return input().split() +def I(): return map(int,input().split()) +def X(): return list(input()) +def L(): return list(input().split()) +def l(): return list(map(int,input().split())) +def lcm(a,b): return a*b//math.gcd(a,b) +def gcd(*numbers): reduce(math.gcd, numbers) +sys.setrecursionlimit(10 ** 9) +mod = 10**9+7 +count = 0 +ans = 0 + +N, K = I() +a = [] +for i in range(N): + x = k() + a.append(x) + +a.sort() + +print(min(a[i+K-1]-a[i] for i in range(N-K+1))) +" +p03673,s907227118,Accepted,"n = int(input()) +a = list(map(int,input().split())) +start = n - 1 +while start >= 0: + print(a[start],end=' ') + start -= 2 +if n % 2 == 0: + start = 0 +else: + start = 1 +while start < n: + print(a[start],end=' ') + start += 2 +" +p02787,s798450557,Wrong Answer,"import math +H,N=map(int,input().split()) +A=[] +B=[] +eff=[] +mp=0 + +for i in range(N): + a,b=map(int,input().split()) + A.append(a) + B.append(b) + eff.append(a/b) + +while H!=0: + eff_max_index=eff.index(max(eff)) + tmp=math.floor(H/A[eff_max_index]) + H-=tmp*A[eff_max_index] + mp+=tmp*B[eff_max_index] + for i in range(N): + if A[i]>H: + A[i]=H + eff[i]=A[i]/B[i] +print(mp) +" +p03681,s884699635,Accepted,"from math import factorial + +N, M = map(int, input().split()) +if abs(N - M) > 1: + ret = 0 +elif N == M: + ret = factorial(N) * factorial(M) * 2 +else: + ret = factorial(N) * factorial(M) + +print(ret % (10 ** 9 + 7)) +" +p02772,s234942292,Accepted,"# -*- coding: utf-8 -*- + +# 整数の入力 +a = int(input()) +# スペース区切りの文字列の入力 +st = input().split() +st_list = [] +st_list = [int(st) for st in st] + +num = 0 +flg = 0 +for num in range(len(st_list)): + if(st_list[num] % 2 == 0): + if(st_list[num] % 5 != 0 and st_list[num] % 3 != 0): + flg = 1 +if(flg == 0): + print(""APPROVED"") +else: + print(""DENIED"") + + +" +p03827,s144340651,Accepted,""""""" +author : halo2halo +date : 31, Jan, 2020 +"""""" + +import sys +import itertools + +# import numpy as np + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +N = int(readline()) +S = readline().decode('utf8') + +ans = 0 +cnt=0 +for i in S: + + if i == 'I': + cnt += 1 + else: + cnt -= 1 + + ans=max(ans, cnt) +print(ans)" +p02922,s317061955,Wrong Answer,"A, B = map(int, input().split()) + +C = B//A + 1 + +number_of_mouth = A * C - (C-1) + +if number_of_mouth >= B: + print(C) + +elif A == B: + print('1') + +else: + C += 1 + print(C)" +p02743,s349324928,Accepted,"a, b, c = list(map(int, input().split())) + +if c-a-b > 0: + if 4*a*b < (c-a-b)**2: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p03416,s717627102,Wrong Answer,"A, B = map(int, input().split()) + +count = 0 +for q in range(A, B): + if list(str(q)) == list(reversed(str(q))): + count += 1 +print(count) + +" +p03705,s911893534,Accepted,"N, MIN, MAX = map(int, input().split()) + +sum_min = (N-1)*MIN + MAX +sum_max = (N-1)*MAX + MIN +# print(sum_max) +# print(sum_min) + +if N > 1: + if sum_max >= sum_min: + print(sum_max - sum_min + 1) + else: + print(0) +elif N == 1: + if MIN!= MAX: + print(0) + else: + print(1)" +p02833,s633712046,Accepted,"n = int(input()) + +if n%2 == 0: + ans = 0 + l = 1 + while(True): + if n//pow(5, l) == 0: + break + ans += n//pow(5, l)//2 + l+=1 + print(ans) +else: + print(0)" +p02843,s935552641,Accepted,"import sys +X = int(input()) +if 1 <= X and X < 100: + print(""0"") + sys.exit() +i = 0 +dp = [0]*(X+1) +dp[0] = 1 +for i in range(100, X+1): + for j in range(6): + if dp[i-(100+j)] == 0: + pass + else: + dp[i] = 1 +print(dp[X]) +" +p02665,s305478227,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +bottom = sum(A) + +if bottom <= 0: + print(-1) + exit() + +ret = 1 +children = 1 - A[0] +bottom -= A[0] + +for i in range(N): + children = children * 2 - A[i+1] + if children <= -1: + ret = -1 + break + + bottom -= A[i+1] + if children >= bottom: + children = bottom + ret += children + A[i+1] +print(ret) +" +p03673,s273739772,Accepted,"from collections import deque +n = int(input()) +a = list(map(int, input().split())) +b = deque() + +ok = True +for i in range(n): + if ok: + b.append(a[i]) + ok = False + else: + b.appendleft(a[i]) + ok = True + +b = list(map(str, list(b))) +if ok: + print("" "".join(b)) +else: + print("" "".join(b[::-1]))" +p02814,s569117791,Accepted,"import sys +read = sys.stdin.buffer.read +from fractions import gcd +from functools import reduce + +n,m,*alst = list(map(int,read().split())) +mm=2*m +def lcm(x,y): + g=gcd(x,y) + if x//g %2==0 or y//g%2==0: + return 0 + g=x*y//g + if g>mm: + return 0 + return g +g=reduce(lcm,alst) +if g==0: + print(0) + quit() +else: + res=(mm//g) + print(res//2+res%2) +" +p02576,s025129268,Accepted,"import math +n, x, t = map(int, input().split()) +print(t * math.ceil(n/x))" +p03471,s947965357,Accepted,"n,Y = map(int,(input().split())) +x = 0 +y = 0 +z = 0 +f = True +for i in range(n+1): + for j in range(n+1): + k=Y-i*10000-j*5000 + if k==(n-i-j)*1000 and k>=0: + x=i + y=j + z=int(k/1000) + f=False +if f : + x = -1 + y = -1 + z = -1 +print(x,y,z) + +" +p02796,s105262361,Accepted,"import sys +def input(): + return sys.stdin.readline()[:-1] +N=int(input()) +l=[None]*N +for i in range(N): + X,L=map(int,input().split()) + l[i]=(X-L,X+L) +l.sort(key=lambda x: x[1]) +t=-10**12 +a=0 +for i in l: + if t<=i[0]: + a+=1 + t=i[1] +print(a)" +p03043,s668721393,Accepted,"from math import ceil, log2 + +n, k = map(int,input().split()) + +ans = 0 +d = {} +d[0] = 1 +for i in range(n, 0, -1): + c = ceil(log2(k / i)) + if c < 0: + c = 0 + if c not in d: + d[c] = pow(1/2, c) + ans += d[c] / n + +print(ans)" +p02613,s030068836,Accepted,"n=int(input()) +lis=['AC', 'WA', 'TLE', 'RE'] +ans=[0,0,0,0] +for _ in range(n): + s=input() + ans[lis.index(s)]+=1 + +for i in range(4): + print(lis[i]+' x '+str(ans[i]))" +p03625,s899846764,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +d = {} +for x in a: + d[x] = d.get(x, 0) + 1 +l = [] +ans = 0 +for num, cnt in sorted(d.items(), key=lambda x: x[0], reverse=True): + if cnt > 3: + ans = num ** 2 + print(ans) + exit() + elif cnt > 1: + l.append(num) + if len(l) == 2: + ans = l[0] * l[1] + print(ans) + exit() +print(ans)" +p03274,s160138342,Accepted,"n,k = map(int,input().split()) +X = list(map(int, input().split())) + +ans = 10**10 +for i in range(n-k+1): + d1 = abs(X[i]) + abs(X[i] - X[i+k-1]) + d2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1]) + if ans > min(d1, d2): + ans = min(d1,d2) +if ans == 10**10: + print(0) +else: + print(ans) + + +" +p02596,s647657343,Wrong Answer,"import sys +k = int(input()) +if k % 7 == 0: + k = k // 7 +tmp = 1 +for i in range(k+2): + if tmp == 0: + print(i+1) + sys.exit() + tmp = (tmp * 10 + 1) % k +print(-1)" +p02761,s816326684,Accepted,"n,m = map(int,input().split()) + +rest = [] +for i in range(m): + a,b = input().split() + rest.append((int(a),b)) + +done = False + +for i in range(0,1000): + x = str(i) + if (len(x) == n): + ok = True + for t in rest: + if (x[t[0] - 1] != t[1]): + ok = False + break + if ok: + print(i) + done = True + break + +if not done: + print(-1)" +p02718,s757655476,Wrong Answer,"n = list(map(int,input().split())) +vote = list(map(int,input().split())) +a = 4*n[1]*sum(vote) +result = 0 +for i in range(n[0]): + if vote[i]=0: + print(int(A)) +else: + print(int(B))" +p02787,s832555647,Wrong Answer,"import bisect +H,N = [int(x) for x in input().split()] +AB = [[int(x) for x in input().split()] for _ in range(N)] +dp = [[10**18]*10**4 for _ in range(N+1)] +for i in range(N+1): + dp[i][0]=0 +mi=10**9 +for i in range(N): + for w in range(10**4): + dp[i+1][w]=min(dp[i+1][w],dp[i][w]) + if w-AB[i][1]>=0: + dp[i+1][w]=min(dp[i+1][w],dp[i + 1][w - AB[i][0]] + AB[i][1]) +for i in range(H,10**4): + mi = min(mi,dp[N][i]) +print(mi)" +p02759,s269003748,Wrong Answer,"import math +n = int(input()) +print(math.ceil(n))" +p03860,s382648000,Wrong Answer,"print(""A""+input()[0]+""C"")" +p02771,s915746508,Wrong Answer,"from sys import stdin + +a, b, c = [int(x) for x in stdin.readline().rstrip().split()] + +print(""Yes"" if not ((a == b == c) or (a != b != c)) else ""No"") +" +p03730,s539836673,Wrong Answer," +a, b, c = map(int, input().strip().split()) +a_temp = a + +flg = False + +for i in range(b): + if a_temp % b == c: + print('Yes') + exit() + a_temp += a +else: + print('No') +" +p03657,s797199326,Wrong Answer,"a, b = list(map(int, input().split())) +if a % 3 == 0 or b & 3 == 0 or (a + b ) % 3 == 0: + print('Possible') +else: + print('Impossible') +" +p02948,s735159388,Accepted,"from heapq import * +N,M = map(int,input().split()) +l = [[0] for _ in range(M+1)] +for _ in range(N): + a, b = map(int, input().split()) + if a<=M: + l[a].append(b) + +ans = 0 +h = [] + +for i in range(1,M+1): + for j in l[i]: + heappush(h, -j) + ans += heappop(h) +ans *= -1 +print(ans)" +p03408,s478154428,Accepted,"import collections,sys +def I(): return int(sys.stdin.readline().rstrip()) +def S(): return sys.stdin.readline().rstrip() +s = [S() for _ in range(I())] +t = [S() for _ in range(I())] +ans = 0 +count_s = collections.defaultdict(int) +count_t = collections.defaultdict(int) +for x in s: + count_s[x] += 1 +for y in t: + count_t[y] += 1 +for k,v in count_s.items(): + ans = max(ans,v-count_t[k]) +print(ans) +" +p02723,s774967247,Accepted,"s = input() +if s[2] == s[3] and s[4] == s[5]: + print('Yes') +else: + print('No')" +p03037,s425553136,Accepted,"def solve(lx, rx): + diff = min(rx) - max(lx) + ans = diff+1 if diff >= 0 else 0 + return ans + + +if __name__ == '__main__': + n, m = map(int, input().split()) + lx = [] + rx = [] + + for i in range(m): + l, r = map(int, input().split()) + lx.append(l) + rx.append(r) + + print(solve(lx, rx)) +" +p02780,s123988320,Accepted,"n, k = map(int, input().split()) +ls = list(map(int, input().split())) + +exv = 0 + +for j in range(k): + exv += (ls[j] + 1) / 2 + +ans = exv + +for i in range(k, n): + exv += (ls[i] + 1) / 2 + exv -= (ls[i - k] + 1) / 2 + + if exv > ans: + ans = exv + +print(ans)" +p03220,s792786477,Wrong Answer,"from decimal import * + +import numpy as np + +import math + +if __name__ == '__main__': + n = int(input()) + b, c = map(int, input().split()) + list =[] + min = 100000 + d = [int(i) for i in input().split()] + + for i in d: + a =Decimal(i)*Decimal(0.006) + diff=0 + if a > c: + diff =abs(c+a) + else: + diff =abs(c-a) + list.append(diff) + if min > diff: + min=diff + print(list.index(min)+1) + +" +p03910,s412045147,Accepted,"import sys + +N=int(input()) +temp=0 +ans=[] +for i in range(1,N+1): + temp+=i + if temp==N: + for j in range(1,i+1): + print(j) + else: + sys.exit() + elif temp>N: + for j in range(1,i+1): + if j==temp-N: + continue + print(j) + else: + sys.exit() +" +p03485,s297322484,Wrong Answer,"a, b = map(int, input().split()) +ans = (a+b)//2+1 +print(ans)" +p02832,s874902050,Wrong Answer,"N = int(input()) +A = [int(a) for a in input().split()] + +next_target = 1 + +idx = [] + +for i, a in enumerate(A): + if a == next_target: + idx.append(i) + next_target += 1 + +if not idx: + print(-1) +else: + prev = -1 + sum_ = 0 + for x in idx: + sum_ += x - prev - 1 + prev = x + + print(sum_) +" +p02663,s779954891,Wrong Answer,"#スペース区切りの整数の入力 +h1, m1, h2, m2, k = map(int, input().split()) + + +asa = h1 * 60 + m1 +yoru = h2 * 60 + m2 + + +if(((yoru - asa )%k) == 0): + ans = int((yoru - asa )/k)-1 +else: + ans = int((yoru - asa )/k) +print(ans* k)" +p02814,s927118191,Accepted,"f=lambda:map(int,input().split()) +n,m=f(); l=list(f()) +import fractions as f +k=1 +for i in l: + i//=2; k=k*i//f.gcd(k,i) + if (k//i)%2<1 or k>m: print(0); break +else: print(m//k-m//(k*2))" +p02556,s456994866,Accepted,"N=int(input()) +L1=[] +L2=[] +L3=[] +for i in range(N): + x,y=map(int,input().split()) + L1.append(x+y) + L2.append(x-y) + L3.append(y-x) +L1.sort() +L2.sort() +L3.sort() + +M1=L1[-1]-L1[0] +M2=L2[-1]-L2[0] +M3=L3[-1]-L3[0] +print(max(M1,M2,M3))" +p02556,s641835021,Accepted,"n = int(input()) +line = [map(int, input().split()) for _ in range(n)] +x, y = [list(i) for i in zip(*line)] + +def f(x,y): + return x-y + +def g(x,y): + return x+y + +print(max(max([f(x[i],y[i]) for i in range(n)])-min([f(x[i],y[i]) for i in range(n)]), max([g(x[i],y[i]) for i in range(n)])-min([g(x[i],y[i]) for i in range(n)])))" +p03699,s033290727,Wrong Answer,"N = int(input()) +ls = [] +f = 0 +for i in range(N): + ls.append(int(input())) +for i in range(N): + if ls[i]%2 != 0: + print(sum(ls)) + f += 1 + break +if f == 0: + print(0) + " +p03371,s955026228,Accepted,"def main(): + a, b, c, x, y = map(int, input().split()) + + ans = 1000000007 + for i in range(100001): + cost = c * i * 2 + a * max(0, x - i) + b * max(0, y - i) + if cost < ans: + ans = cost + + print(ans) + +if __name__ == '__main__': + main() +" +p03136,s870332927,Wrong Answer,"N = int(input()) +l = list(map(int,input().split())) + +S = sum(l) + +for i in range(N): + tmp = S - l[i] + if tmp < l[i]: + print(""No"") + exit() +print(""Yes"")" +p02972,s951895526,Accepted,"import collections +import heapq +n = int(raw_input()) +ais = [0] + map(int, raw_input().split()) +res = [0 for __ in range(n +1)] +used = set([]) +for u in range(n, 0, -1): + c = u*2 + cumul = 0 + for jj in range(u, n+1, u): + cumul += res[jj] + + if ais[u] != (cumul % 2): + res[u] = 1 + used.add(u) +s = sum(res) +print s +if s: + for x in used: print x, + print" +p02813,s124505074,Accepted,"import itertools + +n=int(input()) +data=[x+1 for x in range(n)] +p = [int(_) for _ in input().split()] +q = [int(_) for _ in input().split()] +a=b=-1 +i=0 +for d in itertools.permutations(data): + if list(d)==p: + a=i + if list(d)==q: + b=i + + i+=1 + +print(abs(a-b)) + " +p02963,s436028422,Accepted,"s=int(input()) +x3,y3,x2,y2,y1=0,0,-int(-s**0.5//1),1,-int(-s**0.5//1) +x1=x2*y1-s +if x2*y1-s==0: + x1,y2=0,0 +print(x1,y1,x2,y2,x3,y3)" +p02660,s085885172,Wrong Answer,"N = int(input()) + +result = 0 +n = N +i = 2 +e = 1 +while n%(i**e)==0: + n = n//(i**e) + result += 1 + e += 1 + +for i in range(3,int(N**(1/2)+1),2): + e = 1 + while n%(i**e)==0: + n = n//(i**e) + result += 1 + e += 1 + +if result == 0 and N != 1: + result = 1 + +print(result)" +p03386,s906704077,Wrong Answer,"a, b, k = map(int, input().split()) + +for i in range(k): + if a + i > b: + break + print(a + i) + +for i in range(k): + if b - i < a: + break + print(b-i) +" +p02755,s267110064,Accepted,"a,b =map(int,input().split()) +ans = [] +for i in range(1,10**4+1): + if int(i * (8/100)) == a and int(i*(10/100)) == b: + ans.append(i) +print('-1' if ans == [] else min(ans))" +p03360,s612019697,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Wed May 13 17:23:47 2020 + +@author: shinba +"""""" + +A = list(map(int,input().split())) +k = int(input()) + +A.sort() + +print(A[2]*(2**k)+A[0]+A[1]) + +" +p03371,s590497035,Accepted,"def resolve(): + import math + A, B, C, X, Y = map(int, input().split()) + ans = [] + for i in range(max(X, Y)*2+1): + ans.append(C*i + A*(max(X-i/2, 0)) + B*(max(Y-i/2, 0))) + print(math.floor(min(ans))) +resolve()" +p03243,s397508801,Accepted,"N=int(input()) +if N<=111: + print(111) +elif 112<=N and N<=222: + print(222) +elif 223<=N and N<=333: + print(333) +elif 334<=N and N<=444: + print(444) +elif 445<=N and N<=555: + print(555) +elif 556<=N and N<=666: + print(666) +elif 667<=N and N<=777: + print(777) +elif 778<=N and N<=888: + print(888) +elif 889<=N and N<=999: + print(999)" +p02694,s244938250,Accepted,"import math +X=int(input()) +tmp=100 +t=1 +while tmpM] + +throw=sum(B) + +if H>throw: + + print(math.ceil((H-throw)/M) + len(B)) +else: + B.sort(reverse=True) + for i in range(N-1): + if B[i]>=H: + print(i+1) + break + B[i+1]+=B[i] + else: + print(N) +" +p03274,s072753298,Accepted,"cand_num, tenka = map(int, input().split("" "")) +candles = list(map(int, input().split("" ""))) +mini = 10 ** 9 + +for i in range(cand_num - tenka + 1): + if candles[i] * candles[tenka + i - 1] >= 0: + temp = max(abs(candles[i]), abs(candles[tenka + i - 1])) + else: + temp = min(abs(candles[i]), abs(candles[tenka + i- 1])) * 2 + max(abs(candles[i]), abs(candles[tenka + i - 1])) + mini = temp if mini > temp else mini +print(mini)" +p02989,s892130555,Accepted,"N=int(input()) +d=sorted(list(map(int,input().split()))) +print(d[N//2]-d[N//2-1]) +" +p02987,s549287420,Accepted,"string=input() +list=[] +for i in range(0,len(string)): + if string[i] not in list: + list.append(string[i]) + + if string[i] not in list: + list.append(string[i]) + +if(len(list)==2): + print(""Yes"") +else: + print(""No"") +" +p03481,s081604783,Accepted,"X, Y = map(int, input().split()) + +A = X +ans = 1 + +while 2*A <= Y: + A *= 2 + ans += 1 + +print(ans) +" +p03282,s382345137,Accepted,"S = list(input()) +K = int(input()) + +for i in range(K): + if S[i] != ""1"": + print(S[i]) + exit() + if i + 1 == K: + print(S[i]) + exit() +print(""1"") +" +p03479,s007605415,Accepted,"x, y = map(int, input().split()) + +ans = 0 +while x <= y: + x = x * 2 + ans += 1 +print(ans)" +p03472,s127785031,Accepted,"import sys +import math +n,h=map(int,input().split()) +ab=[list(map(int,input().split())) for i in range(n)] +a=[ab[i][0] for i in range(n)] +A=max(a) +b=[ab[i][1] for i in range(n) if ab[i][1]>A] +b=sorted(b,reverse=True) +cnt=0 +for i in b: + h-=i + cnt+=1 + if h<=0: + print(cnt) + sys.exit() +print(cnt+math.ceil(h/A))" +p02859,s581563071,Accepted,"r = int(input()) +print(r*r)" +p03250,s394817924,Accepted,"a,b,c=sorted(map(int, input().split())) +print(10*c+b+a)" +p03150,s790771992,Accepted,"S = input() +ans = False +for i in range(0, len(S)): + for j in range(len(S)-i+1): + ns = S[:j] + S[j+i:] + if ns == 'keyence': + ans = True + break + if ans: + break +print('YES' if ans else 'NO') +" +p03035,s837336220,Accepted,"def resolve(): + #n=int(input()) + #a,b=map(int,input().split()) + #x=list(map(int,input().split())) + #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)] + a,b=map(int,input().split()) + if a>=13: + print(b) + elif a>=6: + print(b//2) + else: + print(0) + + +if __name__ == '__main__': + resolve() +" +p03030,s572708328,Accepted,"N = int(input()) +rests = [] + +for i in range(1, N+1): + S, P = input().split() + rests.append((S, int(P), i)) + +rests.sort(key=lambda x: x[0]+chr(100-x[1])) +for rest in rests: + print(rest[2])" +p02630,s423924337,Accepted,"from collections import Counter +n=int(input()) +a=list(map(int, input().split())) +q=int(input()) +cou=Counter(a) +arr=list(cou.items()) +dic={} +for item in arr: + dic[item[0]]=item[1] +ans=sum(a) +for _ in range(q): + b,c=map(int,input().split()) + if not b in dic.keys(): + print(ans) + continue + if not c in dic.keys(): + dic[c]=0 + tmpb=dic.pop(b) + tmpc=dic.pop(c) + ans+=(c-b)*tmpb + dic[c]=tmpb+tmpc + print(ans)" +p03105,s259778387,Accepted,"price, poket_money, max_music = map(int, input().split()) + +music_times = -1 +for i in range(0, poket_money + 1, price): + music_times += 1 + if max_music == music_times: + break + +print(music_times)" +p02582,s960282705,Wrong Answer,"#coding:utf-8 + +a = input() + +if a == ""SSS"": + print(""0"") + +elif a == ""RRR"": + print(""3"") + +elif a == ""RRS"" or ""SRR"": + print(""2"") + +else : + print(""1"")" +p03723,s998837470,Wrong Answer,"A, B, C = map(int, input().split()) +count = 0 +if A == B and B == C: + print(-1) + exit() + +while A%2 == 0 and B%2 == 0 and C%2 == 0: + A, B, C = B//2+C//2, A//2+C//2, A//2+B//2 + count += 1 +print(count) + +" +p02664,s963117397,Wrong Answer,"T = input() +lent = len(T) +mlist = [] + +for i in range(lent): + if T[lent - (i+1)] == ""?"": + if i == 0: + mlist.append(""D"") + elif mlist[i-1] == ""D"": + mlist.append(""P"") + else: + mlist.append(""D"") + else: + mlist.append(T[lent - (i+1)]) + +mlist.reverse() +print(''.join(mlist))" +p02628,s248751953,Wrong Answer,"N,K=input().split() +N=int(N) +K=int(K) +a=[] +a=[int(a) for a in input().split()] +a.sort() +print(sum(a[0:K-1]))" +p02699,s940456536,Wrong Answer,"S,W=map(int,input().split()) + +if (W>=(S/2)): + print('unsafe') +else: + print('safe')" +p02571,s609316264,Accepted,"S = str(input()) +T = str(input()) +m = len(S) +n = len(T) +mn = m +for i in range(m-n+1): + sub = S[i:i+n] + counter = 0 + for j in range(n): + if sub[j] != T[j]: + counter += 1 + if mn > counter: + mn = counter +print(mn)" +p02554,s430262909,Accepted,"a=int(input()) + +if a<=1: + print(0) + +else: + n=(10**a)-(9**a)*2+(8**a) + print(n%1000000007)" +p02790,s196263779,Wrong Answer,"a,b=map(int,input().split()) +if a>=b: + print(str(a)*b) +else: + print(str(b)*a)" +p02939,s217379376,Wrong Answer,"s = input() +a = [s[0]] +tmp = """" +cnt = 1 + +for i in range(1, len(s)): + tmp = tmp + s[i] + if s[-1] != tmp: + a.append(tmp) + tmp = """" + cnt += 1 + else: + continue +print(cnt) +" +p03455,s112749742,Accepted,"a, b = map(int, input().split()) +print(""Odd"" if a*b%2 else ""Even"")" +p02861,s820819210,Accepted,"# import bisect +# from collections import Counter, deque +# import copy +# from fractions import gcd +# from functools import reduce +from itertools import permutations + +def resolve(): + N=int(input()) + l=[[0,0] for i in range(N)] + for i in range(N): + x,y=map(int,input().split()) + l[i][0],l[i][1]=x,y + + p=permutations(l) + dist = 0 + for v in p: + for i in range(N-1): + dist+=((v[i][0]-v[i+1][0])**2+(v[i][1]-v[i+1][1])**2)**0.5 + + print(dist/len(list(permutations((l))))) + + +resolve()" +p03261,s363617908,Accepted,"N = int(input()) +W = [input() for _ in range(N)] +sorted_W = sorted(W) +for i in range(len(sorted_W) - 1): + if sorted_W[i] == sorted_W[i + 1]: + print('No') + exit() +for i in range(len(W) - 1): + if W[i][-1] != W[i + 1][0]: + print('No') + exit() +print('Yes') +" +p02753,s636182766,Wrong Answer,"S = input(""S?"") +if S[0] == S[1] and S[0] == S[2]: + print(""No"") +else: + print(""Yes"")" +p02665,s550166704,Accepted,"N = int(input()) +A = [int(i) for i in input().split()] + +total = sum(A) +node = 1 +ans = 0 +for i in range(N+1): + ans += node + total -= A[i] + #print(node, total) + node = min(total, (node - A[i]) * 2) + + if node < 0: + print(-1) + exit() + +print(ans)" +p03435,s540913604,Accepted,"import sys +c=[list(map(int,l.split())) for l in sys.stdin.read().splitlines()] +for i in range(2): + c[2-i]=[x-y for x, y in zip(c[2-i],c[1-i])] +for i in range(2): + for j in range(3): + c[j][2-i]-=c[j][1-i] + +if c[1][1:]==c[2][1:]==[0,0]: + print('Yes') +else: + print('No')" +p03352,s902131770,Accepted,"import math +X = int(input()) + +sq = int(math.sqrt(X)) +m = 1 +for b in range(2, sq+1): # ここで2が1になると1のp乗となり永遠にループが回り続ける + p = 2 + tmp = b ** p + while tmp <= X: + m = max(tmp, m) + p += 1 + tmp = b ** p +print(m)" +p02659,s002479222,Wrong Answer,"a,b=input().split() +a = int(a) +b = int(float(b)*100) +ans = a*b +from math import gcd +n = 100 +g = gcd(ans,n) +while g != 1: + ans //= g + n //= g + g = gcd(ans,n) +print(ans//n) +" +p02676,s515536524,Accepted,"K = int(input()) +S = input() + +if len(S) <= K: + print(S) +else: + print(S[0:K] + ""..."") +" +p02608,s491730690,Accepted,"N = int(input()) +ans = [0]*(1+N) + +for x in range(1, 10**2+1): + for y in range(1, 10**2+1): + for z in range(1, 10**2+1): + v = x*x+y*y+z*z+x*y+y*z+z*x + + if v<=N: + ans[v] += 1 + +for i in range(1, N+1): + print(ans[i])" +p03852,s952665095,Wrong Answer,"s = input() +if s == 'a' or 'i' or 'u' or 'e' or 'o': + print('vowel') +else: + print('consonant')" +p03331,s834599954,Accepted,"n=int(input()) +ans=100000 +for a in range(1,n):##正 + b=n-a + suma=sum(list(map(int, list(str(a))))) + sumb=sum(list(map(int, list(str(b))))) + + ans=min(ans,sumb+suma) +print(ans)" +p02613,s151590598,Wrong Answer,"n = int(input()) +ac = 0 +wa = 0 +tle = 0 +re = 0 +s = """" +for i in range(n): + s = input() + if s == ""AC"": + ac += 1 + elif s == ""WA"": + wa += 1 + elif s == ""TLE"": + tle += 1 + else: + re += 1 +print(f""AC × {ac}\nWA × {wa}\nTLE × {tle}\nRE × {re}"") +" +p02768,s398557760,Accepted,"def cmb(n,r,mod): + if r<0 or r>n:return 0 + return g1[r]*g2[r]%mod + + +mod=10**9+7 +n,a,b=map(int,input().split()) +k=max(a,b) +g1=[1,n] +g2=[1,1] +inverse=[0,1] + +for i,j in enumerate(range(n-1,((n-k+1)-1),-1)): + i=i+2 + g1.append((g1[-1]*j)%mod) + inverse.append((-inverse[mod%i]*(mod//i))%mod) + g2.append((g2[-1]*inverse[-1]%mod)) + +N=pow(2,n,mod)-1 +print((N-cmb(n,b,mod)-cmb(n,a,mod))%mod)" +p03998,s776793459,Accepted,"def solve(sa, sb, sc): + S = {'a': sa, 'b': sb, 'c': sc} + C = {'a': 0, 'b': 0, 'c': 0} + turn = 'a' + while True: + if C[turn] == len(S[turn]): + return turn.upper() + C[turn] += 1 + turn = S[turn][C[turn] - 1] + +_sa, _sb, _sc = [input() for _ in range(3)] +print(solve(_sa, _sb, _sc)) +" +p03625,s372934748,Wrong Answer,"n = int(input().strip()) +a = list(map(int, input().split())) +reps = [] + +a.sort() +for i in range(len(a) - 1): + if a[i] == a[i + 1]: + reps.append(a[i]) +reps = list(set(reps)) +reps.sort(reverse=True) +if len(reps) < 2: + print(0) +else: + print(reps[0] * reps[1]) +" +p02658,s820208779,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = 1 +if A.count(0) >= 1: + print(0) + exit() +for i in A: + ans *= i + if ans > 10 ** 18: + print(-1) + exit() +print(ans)" +p03659,s595323665,Accepted,"import sys +import itertools + +sys.setrecursionlimit(10 ** 8) +ini = lambda: int(sys.stdin.readline()) +inl = lambda: [int(x) for x in sys.stdin.readline().split()] +ins = lambda: sys.stdin.readline().rstrip() +debug = lambda *a, **kw: print(""\033[33m"", *a, ""\033[0m"", **dict(file=sys.stderr, **kw)) + +N = ini() +A = inl() + + +def solve(): + B = list(itertools.accumulate(A, initial=0)) + s = 0 + ans = 10 ** 12 + for i in range(N - 1, 0, -1): + s += A[i] + ans = min(ans, abs(s - B[i])) + + return ans + + +print(solve()) +" +p02690,s671854085,Accepted,"x = int(input()) + +pow_li = [pow(i,5) for i in range(1000)] + +for i in range(1000): + for j in range(1000): + if pow_li[i]-pow_li[j]==x: + print(i,j);exit() + elif pow_li[i]+pow_li[j]==x: + print(i,-j);exit()" +p03486,s480686736,Accepted,"a=sorted(input()) +b=sorted(input())[::-1] + +if a= c: print(""Yes"") + else: print(""No"") + + +if __name__ == ""__main__"": + main() +" +p02791,s056603874,Accepted,"n = int(input()) +p = list(map(int, input().split())) +ans = 0 +min = p[0] + +for i in range(n): + if p[i] <= min: + min = p[i] + ans += 1 + +print(ans)" +p03435,s701834853,Accepted,"l = list(list(map(int,input().split())) for i in range(3)) +first = l[0][0]-l[0][1] +second = l[0][1]-l[0][2] +first1 = l[0][0]-l[1][0] +second2 = l[1][0]-l[2][0] + +for k in range(3): + if (l[k][0]-l[k][1] != first or l[k][1]-l[k][2] != second): + print(""No"") + exit() +for j in range(3): + if (l[0][k]-l[1][k] != first1 or l[1][k]-l[2][k] != second2): + print(""No"") + exit() +print(""Yes"") +" +p03338,s263094321,Accepted,"N = int(input()) +S = input() +C = set(list(S)) +ans = 0 + +for i in range(1,N): + A = 0 + X = S[:i] + Y = S[i:] + for j in C: + if j in X and j in Y: + A += 1 + ans = max(ans,A) +print(ans) + " +p03417,s356773738,Accepted,"N, M = map(int, input().split()) + +ans = 0 +if N==1 and M==1: + ans = 1 +elif N==1: + ans = max(0, M-2) +elif M == 1: + ans = max(0, N-2) +elif N==2 or M==2: + ans = 0 +else: + ans = (M-2)*(N-2) +print(ans)" +p03449,s226554286,Wrong Answer,"n = int(input()) +a1 = list(map(int, input().split())) +a2 = list(map(int, input().split())) +a2_tot = sum(a2) + +if n == 1: + cnt = a1[0]+a2[0] +else: + l = [] + for i in range(n): + x = 0 + for j in range(i): + x += a1[j] + x -= a2[j-1] + x += a2_tot + a2[-1] + l.append(x) + cnt = max(l) + +print(cnt)" +p03943,s612702214,Wrong Answer,"a,b,c = map(int,input().split()) +d = a + b + c +print('Yes' if d % 3 == 0 else 'No')" +p02842,s125232674,Accepted,"n = int(input()) + +xmin = int(n/1.08) +xmax = int((n+1)/1.08) + + +if n%27 == 0: + print(xmax) +elif (n+1)%27 == 0: + print("":("") +elif xmin == xmax: + print("":("") +else: + print(xmax)" +p03035,s831371696,Accepted,"a,b=map(int,input().split()) +if a>=13: + print(b) + +elif a>=6 and a<=12: + print(b//2) + +else: + print(0) + " +p02785,s290026157,Accepted,"n, k = map(int, input().split()) +h = sorted(list(map(int, input().split())), reverse=True) + +if n <= k: + print(0) + exit() +del h[0:k] +print(sum(h)) +" +p02900,s374255358,Accepted,"from fractions import gcd +import math +A, B = map(int, input().split()) +AB = gcd(A, B) + +def prime_factorize(n) : + res = [] + for i in range(2, int(math.sqrt(n))+1) : + if n%i == 0 : + ex = 0 + while (n%i == 0) : + ex += 1 + n //= i + res.append([i, ex]) + if n != 1 : + res.append([n, 1]) + return res + +print(len(prime_factorize(AB))+1) +" +p02717,s267394768,Accepted,"a = input().split() +print(a[2] + "" "" + a[0] + "" "" + a[1])" +p03281,s306795811,Wrong Answer,"from random import*;print(randint(0,5))" +p03795,s751421939,Accepted,"# -*- coding: utf-8 -*- +# A - Restaurant +# 標準入力の取得 +N = int(input()) + +# 求解 +x = 800 * N +y = (N//15) * 200 +print(x - y)" +p03657,s509670901,Wrong Answer,"a,b = map(int, input().split()) +print(""Possible"" if (a+b)%3 == 0 else ""Impossible"")" +p02570,s872337239,Accepted,"d, t, s = map(int, input().split()) + +if (s * t >= d): + print(""Yes"") +else: + print(""No"") +" +p03323,s118263007,Wrong Answer,"D, N = map(int, input().split()) + +if D == 0: + if N == 100: + print(N+1) + else: + print(N) +elif D == 1: + if N == 100: + print(100 * N+1) + else: + print(100 * N) +else: + if N == 100: + print(10000 * N+1) + else: + print(10000 * N)" +p03481,s368644898,Accepted,"x, y = map(int, input().split()) + +left = 0 +right = 10**5 +maxi = y//x +while left+1 < right: + mid = (left+right)//2 + now = 2**mid + if now > maxi: + right = mid + else: + left = mid + +print(left+1)" +p02819,s608031593,Wrong Answer,"import sys +X = int(input()) + +while(True): + flg = True + if X%2 == 0: + X += 1 + continue + + for i in range(3,X): + if X%i == 0: + flg = False + + if flg: + print(X) + sys.exit() + + X += 2" +p03407,s677581448,Wrong Answer,"a, b, c = map(int, input().split()) +print(""Yes"" if c <= (a + b) * 2 else ""No"")" +p03797,s921252444,Accepted,"S, C = map(int, input().split(' ')) + +scc = min(S, C // 2) + +C -= scc * 2 + +print(scc + C // 4) +" +p02970,s443998370,Accepted,"import math +N,D=map(int,input().split()) +print(math.ceil(N/(2*D+1)))" +p03011,s899766935,Accepted,"ls = list(map(int, input().split())) +ls.sort() +print(ls[0] + ls[1]) +" +p03524,s152452513,Wrong Answer,"S=input() +x=dict() +for i in range(len(S)): + s=S[i] + if s in x: + x[s]+=1 + else: + x[s]=1 +l=[] +cnt=0 +for idx in x: + l.append(x[idx]) + cnt+=1 +if cnt!=3: + print(""NO"") + exit() +l.sort() +x=l[0] +y=l[1] +z=l[2] +y=y-x +z=z-x +if y>1 or z>1: + print(""NO"") +else: + print(""YES"")" +p02693,s153080872,Accepted,"k = int(input()) +a, b = map(int, input().split()) # 入力 + +if a % k == 0: + print('OK') +elif b % k == 0: + print('OK') +elif (int(a / k) + 1) * k < b: + print('OK') +else: + print('NG') +" +p03448,s153622414,Accepted,"A, B, C, X = [int(input()) for i in range(4)] +count=0 +for a in range(A+1): + for b in range(B+1): + for c in range(C+1): + if 500*a+100*b+50*c==X: + count+=1 +print(count)" +p03767,s530506651,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a.sort(reverse=True) +print(sum([a[i*2+1] for i in range(n)]))" +p03043,s950723248,Accepted,"import math +N, K = map(int, input().split()) +ans = 0 +for i in range(1, N + 1): + num_success = max(0,math.ceil(math.log2(K / i))) + ans += (1 / 2) ** num_success + +print(ans / N) + +" +p02779,s541829134,Accepted,print('YES' if int(input())==len(set(input().split())) else 'NO') +p02795,s061560836,Wrong Answer,"H = int(input()) +W = int(input()) +N = int(input()) + +i = 0 +j = 0 +if H > W: + while i < N: + j = j + 1 + i = (H * j) + i +elif H < W: + while i < N: + j = j + 1 + i = (W * j) + i +else: + while i < N: + j = j + 1 + i = (H * j) + i +print(j) +" +p03449,s033103604,Accepted,"n = int(input()) +line1 = list(map(int,input().split())) +line2 = list(map(int,input().split())) +sum1 = sum(line1) +sum2 = sum(line2) +count1 = 0 +count2 = 0 +box = [] +for i in range(0,n): + count1 += line1[i] + count2 += line2[i] + totalgap = count2 - line2[i] +sum1 - count1 + box.append(totalgap) +print(sum1 + sum2 - min(box))" +p03644,s912974859,Accepted,"N = int(input()) +for i in range(7): + if 2 ** i <= N < 2 ** (i + 1): + print(2 ** i) + exit()" +p02775,s150236265,Wrong Answer,"S=input() +ans=5*len(S) +ans-=abs(5-int(S[0])) +pre=int(S[0]) +flag=True +for i in range(1, len(S)): + cur=int(S[i]) + ans-=abs(cur-5) + if flag: + if pre<=4 and cur>=6 or pre>=6 and cur<=4: + ans+=1 + flag=False + else: + flag=True + pre=cur +print(ans)" +p02947,s859699442,Wrong Answer,"n = int(input()) +arr = [] +cnt = 0 + +for i in range(n): + s = sorted(list(input())) + arr.append(s) + +for i in range(n): + for j in range(i, n): + if i != j and arr[i] == arr[j]: + cnt += 1 + +print(cnt//2)" +p03137,s913448366,Accepted,"n,m=map(int,input().split()) +a = list(map(int,input().split())) +# if m == 1: +# print(0) +# exit() +a.sort() +# print(a) +b = [] +for i in range(m-1): + b.append(abs(a[i+1]-a[i])) +b.sort() +b.reverse() +# print(b) +ans = sum(b)-sum(b[0:n-1]) +print(ans)" +p03012,s367825367,Accepted,"n = int(input()) +w = list(map(int, input().split())) + +p = sum(w) +sm = 0 +for x in w: + sm += x + if sm*2 > p: + print(min(sm*2-p, p-sm*2+x*2)) + break" +p02744,s390168177,Accepted,"import sys +sys.setrecursionlimit(2147483647) +INF=float(""inf"") +MOD=10**9+7 # 998244353 +input=lambda:sys.stdin.readline().rstrip() +def resolve(): + n = int(input()) + n -= 1 + now = ['a'] + for _ in range(n): + next = [] + for S in now: + d = ord(max(S)) - ord('a') + for i in range(d+2): + next.append(S + chr(i + ord('a'))) + now = next + + now.sort() + for S in now: + print(S) +resolve()" +p02595,s385974398,Wrong Answer,"import math +p, q = map(int, input().split()) +distance = math.sqrt(((p)**2)+((q)**2)) + +print(distance) +" +p03208,s158034012,Accepted,"n,k = map(int,input().split()) + +h = [0]*n + +for i in range(n): + + h[i] = int(input()) + +h.sort() + +ans = float('inf') + +for i in range(n-k+1): + + ans = min(ans,abs(h[i+k-1]-h[i])) + +print(ans) + +" +p03109,s230606861,Accepted,"S = input() +YMD = S.split('/') +MD = int(''.join(YMD[1:])) + +ans = 'Heisei' if MD <= 430 else 'TBD' +print(ans)" +p02645,s243380608,Wrong Answer,"S = input() +ss = str() +for s in S: + if not s in ss: + ss = ss + s + if len(ss)==3: + print (ss) + break" +p02584,s372612783,Accepted,"x, m, d = map(int, input().split()) +x = abs(x) +mn = float('inf') +if x // d > m: + mn = x-m*d +else: + m -= x//d + if m % 2 == 0: + mn = x %d + else: + mn = abs(x%d -d) +print(mn)" +p02910,s655544468,Accepted,"S = input() +N = len(S) + +# 1,3,...文字目が'R'でも'U'でも'D'でもない、または、2,4,...文字目が'L'でも'U'でも'D'でもないとき、'No'を出力する +ans = 'Yes' +for i in range(N): + if (i % 2 == 0 and S[i] != 'R' and S[i] != 'U' and S[i] != 'D') or (i % 2 == 1 and S[i] != 'L' and S[i] != 'U' and S[i] != 'D'): + ans = 'No' + break + +print(ans)" +p02831,s269138642,Accepted,"from fractions import gcd +a,b = map(int, input().split()) +print((a*b)//gcd(a,b)) +" +p02681,s100834089,Accepted,"import sys, random +from bisect import bisect_left, bisect_right +input = sys.stdin.readline + +def main(): + inf = 10 ** 20 + +# t = int(input()) + # t, a, b = map(int, input().split()) + t = 1 + + + for _ in range(1, t+1): + # print(""Case #{}: "".format(_), end = '') + + a, b = [input().strip() for i in range(2)] + + if(a == b[:len(a)]): + print(""Yes"") + else: + print(""No"") + + +main()" +p02947,s458991687,Accepted,"n = int(input()) +S = [''.join(sorted(input())) for _ in range(n)] +cnt = 0 +dic = {} +for s in S: + if s in dic.keys(): + cnt += dic[s] + dic[s] += 1 + else: + dic[s] = 1 +print(cnt)" +p03481,s598703555,Wrong Answer,"X,Y = list(map(int,input().split())) +A = Y//X +B = A//2 +num = 0 +ans = 0 +for i in range(1,10000000): + num += 2**i + if num > B: + ans = i+1 + break +if X*(2**ans) <= Y: + ans += 1 +print(ans)" +p02970,s474904776,Accepted,"n, d = map(int, input().split()) +c = 2 * d + 1 +print((n + c - 1) // c)" +p03385,s307484555,Accepted,"s = str(input()) +a,b,c = 0,0,0 + +for i in s: + if i == ""a"": + a += 1 + if i == ""b"": + b += 1 + if i == ""c"": + c += 1 + +if a == 1 and b == 1 and c == 1: + print('Yes') +else: + print('No')" +p02603,s780492520,Accepted,"n = int(input()) +a = list(map(int,input().split())) +x = 1000 +z = 0 + +if a == sorted(a,reverse=True): + print(x) + +else: + for i in range(n-1): + if a[i] <= a[i+1]: + y = x//a[i] + x = x -y*a[i] + z = z+y + elif a[i] > a[i+1]: + x = z*a[i]+x + z = 0 + x = x + z*a[n-1] + print(x)" +p03309,s231945959,Wrong Answer,"import numpy as np + +n = int(input()) + +a = list(map(int, input().split())) +a = np.array(a) +a -= np.array(range(1,n+1)) + +b = int(np.floor(np.mean(a))) + +ans = min(int(np.sum(abs(a-b))), int(np.sum(abs(a-b-1))), int(np.sum(abs(a-b+1)))) + +print(ans) +" +p02700,s683916289,Wrong Answer,"HPa,ATa,HPb,ATb=map(int,input().split()) +flag = False +for i in range(0,HPa,ATb): + if HPb < 0: + flag = True + HPb = HPb - ATa +if flag: + print(""Yes"") +else: + print(""No"")" +p02795,s993715459,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) + +t=sum(a) +m=10**9 +flag=0 +for i in range(len(a)-1): + t-=2*a[i] + if t<=0 : + if i==0: + print(abs(t)) + flag = 1 + break + else: + print(min(abs(t+2*a[i]),abs(t))) + flag=1 + break +if flag==0: + print(t)" +p03323,s354769815,Accepted,"A,B=map(int, input().split()) +if A > 8 or B > 8 : + print ("":("") +else : + print ( ""Yay!"") + +" +p02785,s164026370,Wrong Answer,"N, K = map(int, input().split(' ')) +H = sorted(map(int, input().split(' '))) +if(K >= N): + print(0) + exit(0) +for j in range(K): + H[K - j - 1] = 0 +print(sum(H))" +p02820,s835742034,Accepted,"# r:グー s:ちょき p:パー +n,k = map(int, input().split()) +r,s,p = map(int, input().split()) +t = input() +point = {""r"":p, ""s"":r, ""p"":s} +d = {""r"":""p"", ""s"":""r"", ""p"":""s""} + +janken = [] +score = 0 +for i in range(n): + if len(janken) < k or d[t[i]]!=janken[-k]: + score += point[t[i]] + janken.append(d[t[i]]) + else: + janken.append("""") +print(score)" +p03001,s868809634,Accepted,"W, H, x, y = list(map(int, input().split())) + +area = W * H / 2 + +checker = 0 + +if(x == W / 2 and y == H / 2): + checker = 1 + +print(area, checker)" +p03211,s950217783,Wrong Answer," +if __name__ == '__main__': + + S = input() + comp_num = 753 + temp = 0 + for i in range(0, len(S)-2): + temp = int (S[i]+S[i+1]+S[i+2]) + min = abs(comp_num - temp) + if temp <= min: + temp = min + print(min) + + + " +p03041,s633787029,Accepted,"# ABC126A + +n, k = map(int, input().split()) +s = input() +a = list(s) +a[k-1] = a[k - 1].lower() +print(''.join(a)) +" +p02691,s761752494,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +print(len([0 for i in range(N) for j in range(i + A[i], N) if j - 1 == A[i] + A[j]]))" +p03494,s480287428,Wrong Answer,"a = int(input()) +lis = list(map(int, input().split())) +for i in range(a): + if lis[i]%2 == 0: + lis[i] = lis[i]/2 + else: + break +print(i)" +p02602,s501394641,Accepted,"import sys +def input(): + return sys.stdin.readline()[:-1] + + +def main(): + N, K = map(int,input().split()) + A = list(map(int,input().split())) + for i in range(N - K): + if A[i] < A[i + K]: + print(""Yes"") + else: + print(""No"") + +if __name__ == ""__main__"": + main()" +p02584,s072500231,Accepted,"def main(): + x, k, d = map(int, input().split()) + y = abs(x) // d + if y == k: + print(abs(x) % d) + elif y < k: + if (k-y) % 2 == 0: + print(abs(x) % d) + else: + print(min(abs(abs(x) % d - d), abs(abs(x) % d + d))) + else: + print(min(abs(abs(x)-d*k), abs(abs(x)+d*k))) + + + + +if __name__ == '__main__': + main() +" +p03761,s958979368,Wrong Answer," + +import sys +from collections import defaultdict + +sys.setrecursionlimit(10 ** 7) +from string import ascii_lowercase +# ---------- + +INF = float(""inf"") +MOD = 10 ** 9 + 7 +# ---------- + + +n = int(input()) +S = [] +for i in range(n): + S.append(input().strip()) + +cmap = defaultdict(lambda :INF) + +for s in S: + for alpha in ascii_lowercase: + cnt = s.count(alpha) + cmap[alpha] = min(cnt, cmap[alpha]) + +ans = '' +for k, v in cmap.items(): + ans += k * v + +print(ans) +" +p02598,s108921571,Accepted,"import numpy as np +import math +N,K = map(int, input().split()) +Logs = np.array([int(x) for x in input().split()]) +ave = sum(Logs)/(N+K) +cut = np.array([max(1,int(x/ave)) for x in Logs]) +chip = Logs/cut +chip=np.sort(chip)[::-1] +print(math.ceil(chip[N+K-sum(cut)]))" +p02613,s574835823,Accepted,"from collections import Counter +N = int(input()) +x = [] +for _ in range(N): + x.append(input()) +c = Counter(x) +print(""AC x {}"".format(c[""AC""])) +print(""WA x {}"".format(c[""WA""])) +print(""TLE x {}"".format(c[""TLE""])) +print(""RE x {}"".format(c[""RE""]))" +p02658,s388656056,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + n=int(input()) + l=list(map(int,input().split())) + ans=1 + if 0 in l: + print(0) + else: + for i in l: + ans*=i + if ans>10**18: + ans=-1 + break + print(ans) +resolve()" +p03773,s154463843,Accepted,"a, b = map(int, input().split()) +print((a + b) % 24)" +p02630,s218688990,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a_dict = {} +s = sum(a) + +for ai in a: + if a_dict.get(ai): + a_dict[ai] += 1 + else: + a_dict[ai] = 1 + +q = int(input()) +for _ in range(q): + b, c = map(int, input().split()) + x = a_dict.get(b, 0) + s += (c - b) * x + if a_dict.get(c): + a_dict[c] += x + else: + a_dict[c] = x + a_dict[b] = 0 + print(s) +" +p03672,s644528649,Accepted,"s = input() +for i in range(2 if len(s) % 2 == 0 else 1, len(s), 2): + t = s[:-i] + mid = len(t) // 2 + if t[:mid] == t[mid:]: + print(len(t)) + break" +p03803,s363323372,Wrong Answer,"a, b = map(int,input().split()) +v = """" +if a == b: + v = ""Draw"" +elif a == 1 or a > b: + v = ""Alice"" +elif b == 1 or a < b: + v = ""Bob"" +print(v) +" +p02600,s726073496,Accepted,"x = int(input()) + +if 400 <= x <= 599: + print(8) +if 600 <= x <= 799: + print(7) +if 800 <= x <= 999: + print(6) +if 1000 <= x <= 1199: + print(5) +if 1200 <= x <= 1399: + print(4) +if 1400 <= x <= 1599: + print(3) +if 1600 <= x <= 1799: + print(2) +if 1800 <= x <= 1999: + print(1) + + +" +p02862,s282384510,Accepted,"import sys +x,y = [int(x) for x in input().split()] +mod = 10**9+7 +if (x+y)%3!=0: + print(0) + sys.exit() +n = (2*y-x)//3 +m = (2*x-y)//3 +if n<0 or m<0: + print(0) + sys.exit() + +a = 1 +for i in range(m+1,n+m+1): + a = a * i % mod +b = 1 +for i in range(1,n+1): + b = b * i % mod +b = pow(b,mod-2,mod) +print(a*b%mod) +" +p02987,s655388074,Accepted,"from collections import Counter + + +def main(): + S = input() + + c = Counter(S) + + if len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2: + ans = ""Yes"" + else: + ans = ""No"" + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03163,s844774326,Wrong Answer,"import sys +input = sys.stdin.readline +I = lambda : list(map(int,input().split())) + +n,we =I() +v=[0]*(n+1);w=[0]*(n+1) +dp=[[0]*(we+1) for i in range(n+1)] +for i in range(1,n+1): + w[i],v[i] = I() +v=[x for _,x in sorted(zip(w,v))] +w.sort() +for i in range(1,n+1): + for j in range(w[i],we+1): + st = dp[i-1][j] + dt=0 + if w[i]<=j: + dt=v[i]+dp[i-1][j-w[i]] + dp[i][j] = max(st,dt) +print(dp[n][we])" +p02761,s463866555,Accepted,"def MI():return map(int,input().split()) +N,M=MI() +sc=[] +for i in range(M): + x,y=MI() + sc.append((x,y)) +for i in range(0,10**3): + h=str(i) + if len(h)==N: + if all([h[s-1]==str(c) for (s,c) in sc]): + print(i) + exit() +print(-1) + " +p02831,s056828898,Accepted,"A, B = map(int,input().split()) +import fractions +print(A * B // fractions.gcd(A, B)) +" +p02946,s583227265,Accepted,"k, x = map(int, input().split()) +l = x - k + 1 +r = x + k - 1 +if l < -1000000: + l = -1000000 +if r > 1000000: + r = 1000000 + +for i in range(l, r+1): + print(i, end="" "")" +p03730,s281169038,Wrong Answer,"a,b,c = map(int,input().split(' ')) +x = a%b +ans = 'No' +i = 1 +while i*x <= c: + if i*x == c: + ans = 'Yes' + break + i += 1 +print(ans)" +p02646,s163638062,Accepted,"a, v= map(int,input().split()) +b, w= map(int,input().split()) +t = int(input()) +if b < a: + a*=-1 + b*=-1 +if a+v*t >= b+w*t: + print('YES') +else: + print('NO')" +p02848,s128816257,Accepted," +N = int(input()) +S = list(input()) + +ans = list(map(ord, S)) +for i in range(len(ans)): + ans[i] = ans[i] + N + if ans[i] > ord(""Z""): + ans[i] = ans[i] - 26 + +for ans in ans: + print("""".join(chr(ans)), end="""")" +p03773,s440951445,Accepted,"a,b=[int(i) for i in input().split()] + + +if a+b<24: + print(a+b) +else: + print(a+b-24) +" +p02629,s413927879,Wrong Answer,"n = int(input()) +pVal = 1 +idx = 0 +res = [] +total = 0 + +while(26 * pVal + total < n): + n -= pVal + total += 26 * pVal + pVal *= 26 + res.append('a') + +res.append('a') +n -= pVal + +while(n > 0): + put = n//pVal + if(put > 0): + res[idx] = chr(put + 97) + + idx += 1 + n -= put * pVal + pVal /= 26 + pVal = int(pVal) + +print(str.join('', res)) +" +p02784,s394301972,Accepted,"H, N = map(int, input().split()) +A = map(int, input().split()) + +attack = sum(A) +if H <= attack: + print(""Yes"") +else: + print(""No"") +" +p02681,s173545013,Accepted,"S = str(input()) +T = str(input()) + +if T[:-1] == S: + print('Yes') + +else: + print('No')" +p02773,s421950795,Accepted,"n = int(input()) +s = {} +for i in range(n): + t = input() + if t in s: + s[t] += 1 + else: + s[t] = 1 +s = sorted(s.items(), key=lambda x:x[1], reverse=True) +vmax = s[0][1] +ans = [] +for si in s: + if si[1] == vmax: + ans.append(si[0]) + else: + break +ans.sort() +for a in ans: + print(a) + + + " +p03011,s640814417,Wrong Answer,"ps = list(map(int, input().split())) + +print(max([p+q for p in ps for q in ps]))" +p02748,s316350680,Wrong Answer,"A, B, M = map(int, input().split()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +x, y, c = [], [], [] +for i in range(M): + x2, y2, c2 = map(int, input().split()) + x.append(x2) + y.append(y2) + c.append(c2) + +a.sort() +b.sort() +no_ticket = a[0] + b[0] + +ticket = 10**5 +for i in range(M): + ticket2 = a[x[i]-1] + b[y[i]-1] - c[i] + ticket = min(ticket, ticket2) + +print(min(no_ticket, ticket)) +" +p03617,s016556427,Accepted,"q, h, s, d = map(int,input().split()) +n = int(input()) +d = min(d,s*2,h*4,q*8) +s = min(s,h*2,q*4) + +ans = n//2 * d + n%2 * s + +print(ans)" +p02584,s427479846,Accepted,"x, k, d = map(int, input().split()) + +def sgn(x): + if x > 0: + return 1 + if x < 0: + return -1 + return 0 + +if x > 0: + x1 = x - k * d +else: + x1 = x + k * d + +if sgn(x) == sgn(x1): + print(abs(x1)) + exit() + +xright = x % d +xleft = x % d - d +#0目前 +xr = (abs(x - xright) // d) % 2 +if k % 2 == xr: + print(abs(xright)) +elif k % 2 != xr: + print(abs(xleft))" +p02570,s308768329,Accepted,"d, t, s = map(int, input().split()) + +if d <= t * s: + print('Yes') +else: + print('No')" +p03059,s257754870,Wrong Answer,"A, B, T = map(int, input().split()) + +print(int(B/A) * T) +" +p02948,s748608878,Wrong Answer,"import heapq + +N, M = map(int, input().split()) +jobs = [[] for i in range(M)] + +for i in range(N): + A, B = map(int, input().split()) + if A - 1 < M: + jobs[A-1].append(B) + +q = [] +heapq.heapify(q) +ans = 0 +for i in range(M): + for j in jobs[i]: + q.append(-j) + if len(q) != 0: + ans += -heapq.heappop(q) + +print(ans)" +p02584,s873569614,Wrong Answer,"X, K, D = map(int, input().split("" "")) +K_s = str(K) +K2 = int(K_s[len(K_s) - 1]) + +if K2 % 2 == 1: + if X < 0: + ans = X + D + else: + ans = X - D +else: + ans = X + +print(ans) +" +p03627,s584937103,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +s = set(sorted(a)) +v = [i for i in s] +v.reverse() +print(v) +b_1 = 0 +b_2 = 0 +for i in v: + n = a.count(i) + if n >= 2 and b_1 != 0 and b_2 == 0: + b_2 = i + if n >= 2 and b_1 == 0: + b_1 = i + if n >= 4 and b_2 == 0: + b_2 = i +print(b_1*b_2)" +p03030,s260363582,Accepted,"n = int(input()) +ans = [] + +for i in range(n): + s, p = map(str, input().split()) + ans.append([s,int(p),i+1]) + + +ans.sort(key = lambda x: x[1], reverse = True) +ans.sort(key = lambda x: x[0]) + +for i in ans: + print(i[2])" +p03657,s739367337,Accepted,"a, b = map(int, input().split()) +if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0: + print('Possible') +else: + print('Impossible') +" +p03131,s857958648,Wrong Answer,"k, a, b = map(int, input().split()) + +if k == 1: + print(2) +elif k < a + 2: + print(1 + k) +else: + cnt = (k - (a - 1)) // 2 + mod = (k - (a - 1)) % 2 + ans_1 = (b - a)*cnt + a + mod + ans_2 = 1 + k + print(int(max(ans_1, ans_2)))" +p02847,s991859021,Wrong Answer,"a = ['MON','TUE','WED','THU','FRI','SAT','SUN'] + +S = input() + +print( 6 - int(a.index(S)))" +p02994,s125547338,Accepted,"n,l = map(int,input().split()) +A = [] +for i in range(1,n+1): + A.append((abs(l+i-1),l+i-1)) +A.sort() +# print(A) +ans = 0 +for i in range(1,len(A)): + ans += A[i][1] +print(ans)" +p03208,s281043834,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 5 + 10) +def input(): return sys.stdin.readline().strip() + +def resolve(): + n,k=map(int,input().split()) + h=sorted([int(input()) for i in range(n)]) + ans=10**20 + for i in range(n-2): + ans=min(ans,h[i+2]-h[i]) + print(ans) + + +resolve()" +p03219,s868957679,Accepted,"x,y = map(int,input().split()) + +print(x+int(y/2))" +p03285,s635491818,Accepted,"n = int(input()) + +can = False +for i in range(26): + for j in range(15): + v = (i*4 + j*7) + if v != 0: + if n % v == 0: + can = True +if can: + print(""Yes"") +else: + print(""No"") +" +p02676,s441143656,Accepted,"k = int(input()) +s = input() + +if len(s) > k : + print(s[:k]+'...') +else : + print(s) +" +p03105,s120430331,Accepted,"#!/usr/bin/env python3 + +A, B, C = map(int, input().split()) + +if B//A >= C: + print(C) +else: + print(B//A)" +p02732,s609498008,Accepted,"import collections + +N = int(input()) +A = list(map(int,input().split())) +c = [0]*N +p = 0 + + +c = collections.Counter(A) + +for i in range(N): + p += (c[i+1])*(c[i+1]-1)//2 + +for i in range(N): + print(p-c[A[i]]+1) +" +p03274,s913475242,Wrong Answer,"N,K = map(int,input().split()) +X = list(map(int,input().split())) +ls = [] +rs = [] +for x in X: + if x < 0: + ls.append(-x) + else: + rs.append(x) +ls.reverse() + +ans = float('inf') +if len(ls) >= K: + ans = min(ans, ls[K-1]) +if len(rs) >= K: + ans = min(ans, rs[K-1]) + +for l in range(1,K): + if l >= len(ls): break + r = K-l + if r >= len(rs): continue + ans = min(ans, ls[l-1]*2 + rs[r-1]) + ans = min(ans, rs[r-1]*2 + ls[l-1]) +print(ans)" +p03627,s476205406,Accepted,"import collections + +n = int(input()) +p = list(map(int,input().split())) +cnt = collections.Counter(p) + +maxs = [] +for k, v in cnt.items(): + if v > 1: + maxs.append(k) + +if len(maxs) > 1: + maxs.sort() + if cnt[maxs[-1]] > 3: + print(maxs[-1] ** 2) + else: + print(maxs[-1] * maxs[-2]) + +else: + print(0)" +p02606,s537242157,Accepted,"L,R,D = list(map(int,input().split())) +ans=0 +for i in range(L,R+1): + if i % D ==0: + ans+=1 +print(ans)" +p02775,s163870516,Wrong Answer,"if __name__ == ""__main__"": + n = '0' + input() + + ans = 0 + flag = 0 + + for i in range(len(n)-1, 0, -1): + if int(n[i]) + flag == 10: + flag = 1 + elif int(n[i]) + flag > 5 or (int(n[i-1]) == 9 and int(n[i]) + flag == 5): + ans += 10 - int(n[i]) + flag = 1 + else: + ans += int(n[i]) + flag + flag = 0 + + if flag == 1: + ans += 1 + + print(ans) +" +p02702,s167291022,Accepted,"from collections import defaultdict +s = input() +mod = 2019 +dct = defaultdict(int) +dct[0] = 1 +x = 0 +d = 1 +for c in s[::-1]: + x = (x+int(c)*d)%mod + d = d*10%mod + dct[x] += 1 +ans = 0 +for v in dct.values():ans += v*(v-1)//2 +print(ans)" +p02725,s990712879,Accepted," +k, n = map(int, input().split()) + +An = list(map(int,input().split())) + +max_diff = 0 +for i in range(1,n): + if i != 0: + max_diff = max(abs(An[i] - An[i-1]), max_diff) + +max_diff = max(max_diff, k-An[n-1] + An[0]) +print(k-max_diff)" +p03086,s679847765,Wrong Answer,"S = input().strip() +L = len(S) +if len(set(list(S+""ATGC""))) == 4: + print(L) + exit() +l = L-1 +while True: + for i in range(L-l): + if len(set(list(S[i:i+l]+""ATGC""))) == 4: + print(l) + exit() + l -= 1 +" +p02939,s477175021,Accepted,"S = input() + +ans = 0 +prev = '' +curr = '' +for s in S: + curr += s + if prev != curr: + ans += 1 + prev = curr + curr = '' +print(ans) +" +p03836,s869239068,Wrong Answer,"a, b, c, d = map(int,input().split()) + +x = c - a +y = d - b + +z = [] +z += y * 'U' +z += x * 'R' +z += y * 'D' +z += (x + 1) * 'L' +z += (y + 1) * 'U' +z += (1 + x) * 'R' +z += 'U' +z += 'R' +z += (y + 1) * 'U' +z += (1 + x) *'L' +z += 'U' + + +print(''.join(z))" +p03721,s304599531,Wrong Answer,"N,K=map(int,input().split()) +num=[list(map(int,input().split())) for _ in range(N)] +for i in range(N): + K -= num[i][1] + if K <= 0: + print(num[i][0]) + exit()" +p02838,s076590188,Accepted,"n=int(input()) +a=list(map(int,input().split())) +mod=10**9+7 +ans=0 +for k in range(60): + t=1< x: + if not(x == 0): + print(""Yes"") + x = i + else: + tf = False + print(""No"")" +p02772,s687818414,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +for x in a: + if not x % 2 and x % 3 and x % 5: + print('DENIED') + break +else: + print('APROAVED')" +p02606,s128415070,Accepted,"a = input("""") +aa = a.split("" "") +aa = [int(s) for s in aa] +L = aa[0] +R = aa[1] +d = aa[2] +aaa = [] +for i in range(L,R+1): + aaa.append(i%d) +print(aaa.count(0))" +p02707,s420634774,Accepted,"import collections + +n = int(input()) +a = list(map(int, input().split())) + +ac = collections.Counter(a) +for i in range(1,n+1): + print(ac[i])" +p02988,s020392348,Wrong Answer,"n = int(input()) +p = list(map(int,input().split())) +seconds = [] +for a in range(0,n-3): + num = [p[a],p[a+1],p[a+2]] + num.sort() + seconds.append(num[1]) + +print(len(set(seconds)))" +p03250,s450916983,Wrong Answer,"S=list(map(int,input().split())) +S.sort() +all=0 +all += (S[2]+10*S[0]+S[1]) +print(all) +" +p03838,s522081663,Accepted,"x, y = map(int, input().split()) +print(min(y-x, abs(y+x)+1) if x B: + print(0) + else: + m = A*(N-1)+B + M = B*(N-1)+A + print(M-m+1) +" +p03013,s731474744,Wrong Answer,"n,m=list(map(int,input().split("" ""))) +a=[] +for i in range(m): + a.append(int(input())) +dp=[float(""inf"") for i in range(n+1)] +dp[0]=1 +if 1 in a: + dp[1]=0 +else: + dp[1]=1 +for i in range(2,n+1): + if i in a: + dp[i]=0 + else: + dp[i]=dp[i-1]+dp[i-2] +print(dp[n]) + +" +p02939,s138732787,Accepted,"import sys +#input = sys.stdin.buffer.readline + +def main(): + s = str(input()) + ans = 1 + now,bef = """",s[0] + l = len(s) + for i in range(1,l): + now += s[i] + if now != bef: + ans += 1 + bef = now + now = """" + + print(ans) + +if __name__ == ""__main__"": + main() +" +p03449,s683514333,Wrong Answer,"n = int(input()) +A = [list(map(int,input().split())) for _ in range(2)] + +ans = 0 +for i in range(n): + cnt = 0 + for j in range(n): + if j <= i: + cnt += A[0][j] + if j >= i: + cnt += A[1][j] + ans = max(ans,cnt) +" +p02819,s271025518,Accepted,"import bisect +#素数リスト +n = 10**5+10 +primes = set(range(2, n+1)) +for i in range(2, int(n**0.5+1)): + primes.difference_update(range(i*2, n+1, i)) +primes=list(primes) + +x = int(input()) +idx = bisect.bisect_left(primes, x) +print(primes[idx])" +p02694,s263052928,Accepted,"X=int(input()) + +x=100 +for i in range(10**4): + x += x//100 + if X <= x: + print(i+1) + break" +p03455,s622814593,Accepted,"a,b=map(int,input().split()) +if a*b%2!=0: + print(""Odd"") +else: + print(""Even"")" +p03433,s835351856,Wrong Answer,"a=input() +n=input() +if a >= n%500: + print ""Yes"" +else: + print""No""" +p02577,s986020027,Accepted,"def solve(ns): + d = 0 + for s in ns: + d += int(s) + d %= 9 + if d == 0: + return 'Yes' + else: + return 'No' + + +def main(): + ns = input() + res = solve(ns) + print(res) + + +def test(): + assert solve(""123456789"") == 'Yes' + assert solve(""0"") == 'Yes' + assert solve(""31415926535897932384626433832795028841971693993751058209749445923078164062862089986280"") == 'No' + + +if __name__ == ""__main__"": + test() + main() +" +p03799,s452695584,Wrong Answer,"import sys +import os + +def file_input(): + f = open('ARC069/input.txt', 'r') + sys.stdin = f + +def main(): + #file_input() + N,M=map(int, input().split()) + + if N*2>=M: + print(str(N)) + else: + M-=N*2 + print(str(N+M//4)) + +if __name__ == '__main__': + main() +" +p02639,s837489800,Accepted,"x = list(map(int,input().split())) +for i in range(5): + if x[i] == 0: + print(i+1) + else: + pass" +p02682,s567843119,Wrong Answer,"a, b, c, k = map(int, input().split()) + + +if k - a <= 0: + print(k) +elif k - a > 0 and k - a - b <= 0: + print(a) +else: + s = k - a + print(s - c) + + " +p03774,s107506721,Wrong Answer,"n,m=map(int,input().split()) +now=[tuple(map(int,input().split())) for i in range(n)] +p=[tuple(map(int,input().split())) for i in range(m)] +for a in now: + ans=10**10 + for c in p: + ans=min(ans,abs(c[0]-a[0])+abs(c[1]-a[1])) + print(ans) +" +p02596,s478046484,Wrong Answer,"k=int(input()) +f=-1 +for i in range(1,1000): + s=k*i + l=len(str(s)) + d=0 + for i in range(l): + if str(s)[i]!=7: + d=d+1 + break + if d<=0: + f=l +print(f)" +p02787,s356092789,Wrong Answer,"h,n = [int(x) for x in input().split()] + +# dp[i] = min magic points to decrease i health points +maxmax = 99999999 +dp = [maxmax for x in range(h+1)] +dp[0] = 0 +for x in range(n): + a,b = [int(r) for r in input().split()] + + for j in range(h): + dp[min(j+a, h)] = min(dp[min(j+a, h)], dp[j]+b) + +print(dp[h]) +" +p02801,s132848972,Wrong Answer,"Alphabet=[""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] +al=input() +for i in Alphabet : + if i==al: + print(Alphabet[+1]) + " +p02933,s107602116,Accepted,"a = int(input()) +s = input() +if a >= 3200: + print(s) +if a < 3200: + print('red')" +p02663,s367183133,Accepted,"import datetime + +if __name__ == ""__main__"": + H1, M1, H2, M2, K = [int(a) for a in input().split()] + dt_start = datetime.datetime(year=2020, month=5, day=30, hour=H1, minute=M1, second=00) + dt_end= datetime.datetime(year=2020, month=5, day=30, hour=H2, minute=M2, second=00) + up_time = dt_end - dt_start + sec = up_time.total_seconds() - K * 60 + print(int(sec/60)) +" +p02777,s263141619,Wrong Answer,"import sys +input = sys.stdin.buffer.readline +def MAP(): return map(int, input().split()) +def LIST(): return list(map(int, input().split())) + +s, t = input().split() +a, b = MAP() +u = input() + +if u == s: + a -= 1 +if u == t: + b -= 1 +print(a, b)" +p03067,s301645150,Accepted,"a,b,c=map(int,input().split()) +print(['No','Yes'][a> j) & 1: + v += np.array(data[j]) + x = min(list(v)[1:]) + if X <= x: + ok = True + ans = min(ans, v[0]) + +if ok == True: + print(ans) +else: + print(-1)" +p02765,s056022557,Accepted,"n,r = map(int, input().split( )) +if n>=10: + print(r) +else: + print(r+100*(10-n)) +" +p02761,s904178326,Wrong Answer,"n,m = map(int,input().split()) +sc = [tuple(map(int,input().split())) for i in range(m)] +l = [0]*n +ans = -1 +for t in sc: + l[t[0]-1] = t[1] +if l[0]==0: + print(-1) +else: + print("""".join([str(s) for s in l]))" +p03030,s897214762,Wrong Answer,"#!/usr/bin/env python +# coding: utf-8 + +# In[6]: + + +N = int(input()) +sp = [] +for i in range(N): + sp.append([i]+input().split()) + + +# In[9]: + + +mylist = sorted(sp, key=lambda x: x[2], reverse=True) +mylist = sorted(mylist, key=lambda x: x[1]) +for i in range(len(mylist)): + print(mylist[i][0]+1) + + +# In[ ]: + + + + +" +p02819,s624534065,Accepted,"X=int(input()) +while True: + for i in range(2,X): + if X%i==0: + X+=1 + break + else: + print(X) + break" +p04019,s539691031,Accepted,"S = input() +count = {s: 0 for s in ""NWSE""} +for s in S: + count[s] += 1 + +if count[""N""] == 0 and count[""S""] >= 1 or count[""N""] >= 1 and count[""S""] == 0: + print(""No"") +elif count[""E""] == 0 and count[""W""] >= 1 or count[""E""] >= 1 and count[""W""] == 0: + print(""No"") +else: + print(""Yes"")" +p02577,s357291623,Accepted,"#!/usr/bin/env python3 +import collections as cl +import sys + + +def II(): + return int(sys.stdin.readline()) + + +def MI(): + return map(int, sys.stdin.readline().split()) + + +def LI(): + return list(map(int, sys.stdin.readline().split())) + + +def main(): + n = input() + ans = 0 + for i in range(len(n)): + ans += int(n[i]) + + if ans % 9 == 0: + print(""Yes"") + else: + print(""No"") + + +main() +" +p02684,s455252299,Accepted,"import sys +n, k = [int(i) for i in sys.stdin.readline().split()] +a_s = [int(i)-1 for i in sys.stdin.readline().split()] +cnt = 0 +ind = 0 +ls = [ind] +last_pos = {0:0} +_set = {ind} +while cnt < k: + ind = a_s[ind] + if ind in _set: + break + _set.add(ind) + ls.append(ind) + cnt += 1 +if cnt == k: + print(ind+1) +else: + start = ls.index(ind) + end = cnt+1 + print(ls[start:][(k - cnt) % (end - start)-1]+1)" +p02790,s637610693,Accepted,"a,b=map(int,input().split()) +ans=0 +l=[] +for i in range(b): + i=a + l.append(str(i)) +ans=','.join(l) +ans_1=ans.replace(',','') + +new_l=[] +for i in range(a): + i=b + new_l.append(str(i)) +new_ans=','.join(new_l) +ans_2=new_ans.replace(',','') + +if a == b: + print(ans_1) + +elif a > b: + print(ans_2) + +else: + print(ans_1) + + " +p02993,s069957993,Accepted,"S = input() +if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]: + print('Bad') +else: + print('Good')" +p03951,s109038873,Accepted,"N=int(input()) +s=input() +t=input() + +ans="""" +for i in range(N): + ans=ans+s[i] + +count=0 + +for i in range(N): + flag=True + for j in range(i+1): + #print(s[N-1-i+j]) + if s[N-1-i+j]==t[j]: + pass + else: + flag=False + if flag: + count=i+1 +#print(count) +for i in range(count,N): + ans=ans+t[i] + +print(len(ans))" +p02823,s842771832,Accepted,"n,a,b = map(int,input().split()) + +check = abs(a-b) + +if check%2 == 0: + print(check//2) + exit() + +temp1 = min(max(a,b) - 1, n - min(a,b)) +temp2 = min(min(a,b) - 1, n - max(a,b)) +ans = min(temp1, temp2 + 1 + (check)//2) + +print(ans)" +p02916,s442728449,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +c = list(map(int,input().split())) +sat = b[a[0]-1] +for i in range(n-1): + sat += b[a[i+1]-1] + if a[i+1] == a[i] + 1: + sat += c[a[i+1]-2] +print(sat)" +p02948,s813027894,Wrong Answer,"N,M = map(int,input().split()) +data = [list(map(int,input().split())) for i in range(N)] + +A = [] +for i in range(N): + A.append((data[i][0],data[i][1])) + +from operator import itemgetter + +A = sorted(A,key = itemgetter(1)) + +ans = 0 +r = M +for i in range(N-1,-1,-1): + if A[i][0] <= r: + ans += A[i][1] + r -= 1 + +print(ans)" +p02631,s560288290,Accepted,"N = int(input()) + +A = list(map(int, input().split())) + +temp = A[0] + +for a in A[1:]: + temp ^= a + +print(*[a^temp for a in A]) +" +p03351,s040542439,Wrong Answer,"import sys + + +stdin = sys.stdin +def ns(): return stdin.readline().rstrip() +def ni(): return int(stdin.readline().rstrip()) +def nm(): return map(int, stdin.readline().split()) +def nl(): return list(map(int, stdin.readline().split())) + + +def main(): + *A, d = nm() + A = sorted(A) + D = [A[i + 1] - A[i] for i in range(2)] + if all([dd <= d for dd in D]): + print('Yes') + else: + print('No') + + +if __name__ == '__main__': + main() +" +p03612,s312367819,Wrong Answer,"def main(): + n, *p = map(int, open(0).read().split()) + res = [] + tmp = False + for i, j in enumerate(p, 1): + b = (i == j) ^ tmp + res.append(b) + tmp = b + + ans = sum(res) + print(ans) + + +if __name__ == '__main__': + main() +" +p03644,s825317047,Accepted,"n = int(input()) + +ans = [] +for i in range(1,n+1): + t = 0 + while i % 2 == 0: + t += 1 + i //= 2 + ans.append(t) +a = ans.index(max(ans)) +print(a+1)" +p02615,s919708069,Accepted,"a=int(input()) +List = list(map(int, input().split())) +List.sort(reverse=True) +res =List[0] +for i in range(1,a-1): + if i%2 ==0: + res += List[int(i/2)] + else: + res += List[int((i+1)/2)] +print(res)" +p03377,s248618168,Wrong Answer,"import math + + +a,b,c=map(int,input().split()) + +print(""Yes"" if a<=c and c<=a+b else ""No"" ) +" +p02647,s569069714,Wrong Answer,"N,K=map(int,input().split()) +A=list(map(int,input().split())) +for i in range(K): + d=[0]*(N+1) + for j,a in enumerate(A): + d[max(0,j-a)]+=1 + d[min(N,j+a+1)]-=1 + b=-1 + for j in range(N): + if b==-1: + b=d[j] + elif b!=d[j] or 1= a and sum <= b: + ans += ni + +print(ans)" +p03251,s413811329,Wrong Answer,"n, m, x, y = map(int, input().split()) +xn = list(map(int, input().split())) +ym = list(map(int, input().split())) + +for z in range(1, 101): + war = False + if x < z and z <= y: + for i in range(n): + for j in range(m): + if xn[i] >= z or ym[j] < z: + war = True + if war == False: + print(""No War"") + exit() +print(""War"")" +p02817,s812927691,Accepted,"s, t = input().split() +print(t+s)" +p03472,s291476406,Accepted,"from math import ceil + +N, H = map(int, input().split()) + +A = [] +B = [] +for _ in range(N): + a, b = map(int, input().split()) + A.append(a) + B.append(b) +else: + a = max(A) + B.sort() + B.reverse() + +ans = 0 +for b in B: + if H <= 0: + print(ans) + break + + if a < b: + H -= b + ans += 1 +else: + print(ans + ceil(H / a))" +p02897,s312369524,Accepted,"N = int(input()) +print(-(-N//2)/N)" +p03262,s245601373,Accepted,"import math +from functools import reduce + +def gcd(list): + return reduce(math.gcd, list) + +n, x = map(int, input().split()) +a = map(lambda b: abs(int(b) - x), input().split()) +print(gcd(a))" +p03494,s823506495,Accepted,"t = 0 +N = int(input()) +a = list(map(int,input().split())) + +while True: + if [i for i in a if i %2 == 1]: + break + a = [i/2 for i in a] + t += 1 +print(t)" +p02571,s696920001,Wrong Answer,"S = input() +T = input() + +cnt = 0 +for i in range(len(S)): + tmp = 0 + for j in range(len(T)): + if i + j < len(S) and S[i + j] == T[j]: + tmp += 1 + else: + cnt = max(cnt, tmp) + tmp = 0 + cnt = max(cnt, tmp) + +print(len(T) - cnt)" +p02792,s873465668,Wrong Answer,"N = int(input()) +ans = 0 +for n in range(1,N+1): + if n%10==0:continue + s = str(n) + if s[0]==s[-1]: + if int(s[0])<=N:ans+=1 + for i in range(10): + a = int(s[-1]+""9""*i+s[0]) + b = int(s[-1]+""0""*i+s[0]) + if a<=N:ans+=pow(10,i) + else: + if b<=N:ans+=(N-a)//10+1 + break +print(ans)" +p02622,s781830480,Wrong Answer,"s=input() +t=input() +ans=0 +for i in range(len(s)): + if s[i]==t[i]: + ans += 1 +print(ans)" +p03971,s580456183,Wrong Answer,"n,x,y=map(int,input().split()) +s= input() +c=0 +d=x+y +f= False +for i in range(n): + if s[i]==""a"": + if c<=d: + f=True + elif s[i]==""b"": + if c<=d and c<=y: + f=True + if f: + print(""Yes"") + c+=1 + else: + print(""No"") + f=False" +p02785,s938196544,Accepted,"a,b=map(int, input().split()) +c=sorted(list(map(int, input().split())),reverse = True) + +ans = 0 + +if b >= a: + c = [0] +if b < a: + for i in range(b): + c[i] = 0 + +print(sum(c)) +" +p03327,s233164989,Accepted,"# 099a +# A - ABD + +N = int(input()) + +if 1 <= N & N <= 999: + print('ABC') +elif 1000 <= N & N <= 1998: + print('ABD')" +p03607,s123845119,Accepted,"import collections,sys +def I(): return int(sys.stdin.readline().rstrip()) +N = I() +A = [I() for _ in range(N)] +count_A = collections.Counter(A) +print(sum([1 for v in count_A.values() if v%2==1])) +" +p02688,s349730762,Accepted,"n,k=map(int, input().split()) +l1=[] +for i in range(k): + x=int(input()) + l=list(map(int, input().split())) + for i in l: + l1.append(i) +s=set(l1) +print(n-len(s))" +p02793,s328292312,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +MOD = 10 ** 9 + 7 + +def gcd(x, y): + return x if y == 0 else gcd(y, x % y) + +def lcm(x, y): + return x * y // gcd(x, y) + +tmp = A[0] +for i in range(1, N): + tmp = lcm(A[i], tmp) +#print(tmp) + +answer = 0 +for a in A: + answer += tmp // a +print(answer % MOD)" +p03611,s695634663,Accepted,"import sys +input = lambda: sys.stdin.readline().rstrip() + +def main(): + n = int(input()) + a = list(map(int, input().split())) + cnt = [0] * (max(a)+3) + + for i in a: + cnt[i-1] += 1 + cnt[i] += 1 + cnt[i+1] += 1 + + print(max(cnt)) + +if __name__ == '__main__': + main()" +p03317,s800829823,Accepted,"n,k=map(int,input().split()) +a=[int(i) for i in input().split()] +x=n-1 +y=k-1 +print((x+y-1)//y)" +p03852,s840360014,Accepted,"#ABC049.A +s = input() +if s == 'a' or s == 'i' or s == 'u' or s == 'e' or s== 'o': + print('vowel') +else: + print('consonant')" +p03087,s421668868,Wrong Answer,"import sys +input = sys.stdin.readline + +def main(): + N, Q = map(int, input().split()) + S = input().rstrip() + ac_flag = [] + for i in range(N-1): + if S[i:i+2] == 'AC': + ac_flag.append(1) + else: + ac_flag.append(0) + for _ in range(Q): + l, r = map(int, input().split()) + print(0) + + +if __name__ == '__main__': + main() +" +p02684,s296831995,Wrong Answer,"# coding: utf-8 +# Your code here! +n,k=map(int,input().split()) + +A=list(map(int,input().split())) +L=[1] +now=1 +for _ in range(n): + now=A[now-1] + if now == L[0]: + break + L.append(now) + +R=k%len(L) +print(L[R])" +p03243,s795255953,Wrong Answer,"n = list(input()) +a = int(''.join(n)) +b = [] +b.append(int(n[0]) * 111) +b.append(int(n[1]) * 111) +b.append(int(n[2]) * 111) +b = sorted(b) +if a % 111 == 0: + print(a) +else: + for i in range(3): + if b[i] > a: + print(b[i]) + exit()" +p02690,s375686076,Wrong Answer,"import math + +x = int(input()) +for i in range(1, 121): + b = x - i**5 + b = b**.2 + if math.ceil(b) - math.floor(b) < 1e6: + print(i, int(b)) + exit(0) +" +p02647,s346147198,Wrong Answer,"n,k = map(int,input().split()) +A=[*map(int,input().split())] +m = min({19,k,n}) +for i in range(m): + B = [0]*n + for j in range(n): + d = A[j] # 強さ + l = max(0, j-d) # 範囲 + r = j+d+1 # 範囲 + B[l] += 1 + if r <= n-1: B[r] -= 1 + for j in range(n-1): + B[j+1] = B[j+1] + B[j] + A = B +print(*B,sep=' ') +" +p02900,s845812531,Accepted,"a,b=map(int, input().split()) + +def primes(m): + pf={} + for i in range(2,int(m**0.5)+1): + while m%i==0: + pf[i]=pf.get(i,0)+1 + m//=i + if m>1:pf[m]=1 + return pf + +A=list(primes(a).keys()) +B=list(primes(b).keys()) +ans=1 +for i in A: + if i in B: + ans+=1 +print(ans)" +p02771,s873718078,Accepted,"a,b,c = map(int,input().split()) +if a == b != c : + print(""Yes"") +elif b == c != a : + print(""Yes"") +elif a == c != b : + print(""Yes"") +else : + print(""No"") +" +p03109,s855978616,Wrong Answer,"s = input() +if int(s[6]) > 4: + print(""TBD"") +else: + print(""Heisei"")" +p03416,s376338373,Wrong Answer,"a, b = map(int, input().split()) +c = 0 +for i in range(a, b+1): + s = str(i) + if s[:len(s)//2] == s[len(s)//2+1:]: + c += 1 +print(c)" +p02598,s721400995,Wrong Answer,"N, K=map(int,input().split()) +A=list(map(int,input().split())) + +def judge(ans,K,A): + cut=0 + for i in range(len(A)): + cut+=int(A[i]/ans) + if cut>K: + return False + else: + return True + +ansp=10**9 +ansm=1 + +while ansp-ansm>0.00001: + ans=((ansp+ansm)/2) + if judge(ans,K,A): + ansp=((ansp+ans)/2) + + else: + ansm=((ans+ansm)/2) + +print(int(ans)+1)" +p02554,s895161871,Accepted,"n = int(input()) +mod = 10**9+7 + +print((10**n-(9**n+9**n-8**n))%mod)" +p03069,s406014647,Wrong Answer,"n = int(input()) +s = input() + +key = [False]*n + +ans1 = 0 +for i in range(1, n): + if (s[i-1] == ""#"" or key[i-1]) and s[i] == ""."" : + ans1 += 1 + key[i] = True + +ans2 = 0 +for i in range(n-1, 0, -1): + if (s[i] == ""."" or key[i]) and s[i-1] == ""#"": + ans2 += 1 + key[i-1] = True + +print(min([ans1, ans2]))" +p03105,s680051007,Accepted,"a,b,c=map(int,input().split()) +if b/a>=c: + print(c) +else: + print(int(b/a))" +p02796,s831321121,Accepted,"N = int(input()) +ABs = [] +for i in range(N): + X, L = map(int, input().split()) + A, B = X-L, X+L + ABs.append((A, B)) +ABs.sort(key=lambda AB: AB[1]) +#print(ABs) +r = 1 +b = ABs[0][1] +for i in range(1, N): + A, B = ABs[i] + if A >= b: + r += 1 + b = B +print(r) +" +p02570,s098589878,Accepted,"d, t, s = map(int, input().split()) + +if d / s > t: + print('No') +else: + print('Yes')" +p03556,s686969871,Accepted,"y = int(input()) +p = (pow(y , 0.5)) +print(pow(int(p) , 2))" +p02957,s779446888,Wrong Answer,"a, b = map(int, input().split()) + +if (a+b)%2 == 0 : + print((a+b)/2) +else : + print(""IMPOSSIBLE"")" +p03681,s760521369,Wrong Answer,"N, M = map(int, input().split()) +MOD = 10**9+7 + +def factorial(n): + ans=1 + for i in range(1, n+1): + ans = (ans * i) % MOD + return ans + +if N == M: + print((2* factorial(N) ** 2) % MOD) +elif N == M + 1: + print(factorial(M)**2*N) +elif M == N + 1: + print(factorial(N)**2*M) +else: + print(0) +" +p02819,s745274041,Accepted,"import math + +X = int(input()) +prime = False +primecheck = True + +if X <= 2: + prime_num = X + +else: + while prime == False: + + for i in range(2, int(math.sqrt(X))): + if X % i == 0: + X += 1 + primecheck = False + break + + if primecheck == False: + primecheck = True + else: + prime = True + prime_num = X + +print(prime_num)" +p02661,s173719957,Accepted,"N=int(input()) +A=[] +B=[] +for i in range(N): + a,b=map(int,input().split()) + A.append(a) + B.append(b) +A.sort() +B.sort() +if N%2==1: + print(B[N//2]-A[N//2]+1) +else: + A_chu=(A[N//2-1]+A[N//2])/2 + B_chu=(B[N//2-1]+B[N//2])/2 + ans=(B_chu-A_chu)*2+1 + print(int(ans))" +p03001,s783840061,Accepted,"w, h, x, y = map(int, input().split()) + +s = w*h/2 + +if w/2 == x and h/2 == y: + t = 1 +else: + t = 0 + +print(s, t)" +p02939,s152648248,Accepted,"def main(): + s = input() + ans = 0 + pre = """" + is_same = False + + for i in range(len(s)): + if is_same: + pre += s[i] + ans += 1 + is_same = False + continue + + if pre != s[i]: + ans += 1 + pre = s[i] + else: + is_same = True + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02720,s751020015,Wrong Answer,"K = int(input()) +count =0 +j =0 +while True: + j+=1 + t = [int(i) for i in list(str(j))] + a = len(t) + for i,v in enumerate(t): + if i < a-1: + if abs(t[i] - t[i+1]) > 1: + break + count += 1 + if count ==K: + print(j) + exit()" +p02957,s947373385,Wrong Answer,"q, r = divmod(sum(map(int, input().split())), 2) +print(q if r else 'IMPOSSIBLE')" +p04034,s631155548,Accepted,"# https://atcoder.jp/contests/agc002/tasks/agc002_b + +n, m = map(int, input().split()) + +xy = [] +for _ in range(m): + x, y = map(int, input().split()) + xy.append((x - 1, y - 1)) + +box = [0] * n +box[0] = 1 +num = [1] * n +for x, y in xy: + if box[x]: + box[y] |= 1 + num[x] -= 1 + num[y] += 1 + if not num[x]: + box[x] = 0 +ans = 0 +for i in range(n): + if box[i] and num[i]: + ans += 1 +print(ans)" +p03494,s614097789,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] + +cnt = 0 +while True: + flag = True + for i in range(n): + if a[i] % 2 == 0: + a[i] //= 2 + else: + flag = False + if flag: + cnt += 1 + else: + break + +print(cnt) + " +p03475,s203348205,Accepted,"N = int(input()) +CSFlist = [tuple(map(int, input().split())) for _ in range(N - 1)] +for i in range(N): + now = 0 + for c, s, f in CSFlist[i:]: + now = max(now, s) + now += (f - now % f) if now % f != 0 else 0 + now += c + print(now) +" +p03360,s154004853,Accepted,"a, b, c = map(int, input().split()) +k = int(input()) +list = [a, b, c] +max = max(list) +if a == max: + print(b+c+a*2**k) +elif b == max: + print(a+c+b*2**k) +else: + print(a+b+c*2**k)" +p02909,s994750148,Accepted,"w = ['Sunny', 'Cloudy','Rainy'] +S = input() +i = w.index(S) +print(w[(i+1) % 3])" +p02690,s124539662,Accepted,"import math + +X=int(input()) + +root = math.floor(X**0.2) +half = root//2 - 5 + +while root > half: + root2 = int((X-root**5)**0.2) + if root**5 + root2**5 == X: + print(int(root),-int(root2)) + exit() + root -= 1 + +root = math.ceil(X**0.2) + +while True: + root2 = int((root**5-X)**0.2) + if root**5 - root2**5 == X: + print(int(root),int(root2)) + exit() + root+=1 " +p02796,s412890775,Accepted,"INF = 1 << 60 + +n = int(input()) +x = [0 for i in range(n)] +l = [0 for i in range(n)] +for i in range(n): + x[i], l[i] = map(int, input().split()) + +itv = [[x[i] - l[i], x[i] + l[i]] for i in range(n)] +itv.sort(key=lambda x:x[1]) +# print(""itv ="", itv) + +ans = 0 +t = -INF +for i in range(n): + if t <= itv[i][0]: + ans += 1 + t = itv[i][1] +print(ans) +" +p03962,s206765415,Wrong Answer,"a,b,c=map(int,input().split()) +if a!=b!=c: + print(3) +elif a==b!=c or a!=b==c or b==a!=c: + print(2) +else: + print(1)" +p02792,s953148035,Accepted,"a=int(input()) + +dp = [[0 for i in range(10)] for j in range(10)] + +for i in range(a+1): + if i%10 == 0: + continue + x = str(i) + dp[int(x[0])][int(x[-1])] += 1 + + +count = 0 + +for i in range(10): + for w in range(10): + count += dp[i][w]*dp[w][i] + +print(count)" +p02859,s670666741,Wrong Answer,"R = int(input()) +print(R*2)" +p02971,s548882249,Wrong Answer,"N = int(input()) +A = [] +for _ in range(N): + A += [int(input())] +Amax = max(A) +Amax2 = sorted(A, reverse=True)[1] +for i in range(N): + print(Amax if i != Amax else Amax2)" +p03261,s804793179,Accepted,"N = int(input()) +W = [input()] +for i in range(1, N): + w = input() + if w not in W and w[0] == W[i-1][-1]: + W.append(w) + else: + print('No') + exit() +print('Yes') +" +p03264,s950992114,Accepted,"k = int(input()) +print(k//2 * ((k+1)//2))" +p02791,s530626327,Accepted,"N=int(input()) +P=map(int, input().split()) +ans=0 +mv=N +for p in P: + if p<=mv: + ans+=1 + mv=p +print(ans)" +p03693,s496214114,Accepted,"a = input().split() +a = """".join(a) +a= int(a) + +if a % 4==0: + print(""YES"") +else: + print(""NO"") + " +p03252,s949284793,Wrong Answer,"s = list(input()) +t = list(input()) +n = len(s) + +s_par = [i for i in range(n + 1)] +t_par = [i for i in range(n + 1)] + +def operation(x, par): + for i in range(n): + for j in range(i): + if x[i] == x[j]: + par[i] = par[j] + return par + +if operation(s, s_par) == operation(t, t_par): + print('Yes') +else: + print('No')" +p03854,s509129875,Accepted,"divide = [""dream"", ""dreamer"", ""erase"", ""eraser""] +S = input()[::-1] +for i in range(4): divide[i] = divide[i][::-1] + +can = True +i = 0 +while i < len(S): + can2 = False + for d in divide: + if S[i:i+len(d)] == d: + can2 = True + break + i += len(d)*(can2) + if not can2: + can = False + break +print(""YNEOS""[~can%2::2])" +p03241,s932540035,Wrong Answer,"def divisore(n): + divisors=[] + for i in range(1,int(n**0.5)+1): + if n%i==0: + divisors.append(i) + if i!=n//i: + divisors.append(n//i) + divisors.sort(reverse=True) + return divisors + +n,m=map(int,input().split()) +l=divisore(m) +print(l) +for i in l: + if m/n>=i: + print(i) + exit()" +p03062,s535415797,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = [abs(a) for a in A] +t = min(B) +fu = 0 +for a in A: + if a < 0: + fu += 1 +print(sum(B)-t if fu%2 else sum(B)) " +p03774,s328402507,Accepted,"n, m = map(int, input().split()) + +s = [] +for i in range(n): + tmp = [int(x) for x in input().split()] + s.append(tmp) + +c = [] +for i in range(m): + tmp = [int(x) for x in input().split()] + c.append(tmp) + +for i in range(n): + d1 = [] + for j in range(m): + d2 = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]) + d1.append(d2) + + print(d1.index(min(d1)) + 1) +" +p02958,s004136363,Wrong Answer,"N=int(input()) +import sys +a=list(input()) +b=a +b.sort() +c=0 +for i in range(N): + if a[i]!=b[i]: + c+=1 + if c>=2: + d='No' + sys.exit() +print('Yes') + + " +p03323,s943195312,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + A, B = map(int, readline().split()) + + if A <= 8 and B <= 8: + print(""Yay!"") + else: + print("":("") + + +if __name__ == '__main__': + main() +" +p03145,s980922652,Wrong Answer,"a,b,c=map(int,input().split()) +print(a*b/2)" +p03645,s553353859,Wrong Answer,"n, m = map(int, input().split()) + +l = list() +la = list() +ln = list() +for i in range(m): + a, b = map(int, input().split()) + l.append([a, b]) + if 1 in [a, b]: + la.append(a*b) + if n in [a, b]: + if a == n: + ln.append(a) + else: + ln.append(b) + +for i in ln: + if i in la: + print(""POSSIBLE"") + exit() + +print(""IMPOSSIBLE"")" +p02842,s588091264,Accepted,"N = int(input()) +X = int(-(-N // 1.08)) +print(X if int(X * 1.08) == N else ':(') +" +p02795,s285836661,Wrong Answer,"h = int(input()) +w = int(input()) +m = int(input()) +total = 0 +if h < w: + h,w = w,h +for i in range(w): + total += h + if total >= m: + print(i+1)" +p02982,s243532079,Accepted,"r=input().split() +N=int(r[0]) +D=int(r[1]) +d=[[int(s) for s in input().split()] for i in range(N)] +ans=0 +for i in range(N-1): + for j in range(i+1,N): + dis=0 + for k in range(D): + dis+=(d[i][k]-d[j][k])**2 + ans_pre=dis**(1/2) + if type(ans_pre)==int or ans_pre.is_integer()==True: + ans+=1 +print(ans)" +p03679,s913404217,Accepted,"x,a,b = map(int,input().split()) + +if a>=b: print('delicious') +elif a+x+1>b: print('safe') +else: print('dangerous')" +p02972,s286008302,Wrong Answer,"import math + +def main(): + N = int(input()) + A = [int(a) for a in input().split("" "")] + B = [0] * N + for i in range(1, N): + for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1): + ball = 0 + for k in range(2 * j, N, j): + if B[k - 1] == 1: + ball += 1 + B[j - 1] = (ball % 2 + A[j - 1]) % 2 + ans = [str(x + 1) for x, v in enumerate(B) if v == 1] + print(len(ans)) + print("" "".join(ans)) + +main() +" +p03607,s580582433,Accepted,"n=int(input()) +s=set() +for i in range(n): + a=int(input()) + if a in s: + s.remove(a) + else: + s.add(a) +print(len(s))" +p02598,s368451478,Accepted,"N,K=[int(s) for s in input().split()] +maruta=[int(s) for s in input().split()] + +def possible(x): + cut=0 + for e in maruta: + if e%x==0: + cut+=(e//x-1) + else: + cut+=e//x + if cut<=K: + return True + else: + return False + +a=1 +b=max(maruta) +while b-a>1: + c=(a+b)//2 + if possible(c): + b=c + else: + a=c + +if possible(1): + print(1) +else: + print(b) +" +p02633,s685774309,Accepted,"x = int(input()) + +from math import gcd + +print(360 // gcd(x, 360))" +p03163,s168382866,Accepted,"n,w = map(int,input().split()) + +items = [list(map(int,input().split())) for i in range(n)] + +dp = [[0]*(w+1) for i in range(n+1)] + +for i in range(n): + for j in range(w+1): + if j >= items[i][0]: + dp[i+1][j] = max(dp[i+1][j], dp[i][j-items[i][0]] + items[i][1]) + + dp[i+1][j] = max(dp[i+1][j], dp[i][j]) + +print(dp[n][w])" +p02723,s475846954,Wrong Answer,"#!python3 + +iim = lambda: map(int, input().rstrip().split()) + +def resolve(): + s = input() + + print(""Yes"" if s[2] == s[3] and s[4] and s[5] else ""No"") + +if __name__ == ""__main__"": + resolve() +" +p02836,s845051184,Accepted,"S = input() +ans = 0 +for a, b in zip(S, S[::-1]): + if a != b: + ans += 1 +print(ans//2) +" +p02866,s117010451,Accepted,"N=int(input()) +D=list(map(int,input().split())) +mod=998244353 + +if D[0]!=0: + print(0) + exit() + + +B=[0]*N +for d in D: + B[d]+=1 +if B[0]!=1: + print(0) + exit() + +ans=1 +total=1 +for i in range(1,N): + if B[i]==0: + if total!=N: + print(0) + exit() + else:break + total+=B[i] + ans*=(B[i-1]**B[i]) + ans%=mod + +print(ans)" +p02983,s722486755,Wrong Answer,"l,r = map(int,input().split()) +i = -(-l//2019) +if 2019*i<=r: + print(0) +else: + if r%2019 str: + pre = H.pop(0) + for h in H: + if(pre > h): + if((pre - h) == 1): + pre = pre - 1 + else: + return ""No"" + else: + pre = h + return ""Yes"" + + +def modelAnswer(): + tmp=1 +def main(): + N = int(input()) + H = list(map(int,input().split())) + print(myAnswer(N,H[:])) +if __name__ == '__main__': + main()" +p02700,s423103324,Wrong Answer,"s = [input() for i in range(1)] +li = list(map(int, s[0].split())) +t = li[0] +a = li[2] +for i in range(0,100): + if i % 2 == 0: + a = a - li[1] + if a <= 0: + print(""Yes"") + break + if i % 2 == 1: + t = t - li[3] + if t <= 0: + print(""No"") + break + + +" +p03210,s495468465,Accepted,"x = int(input()) +if x==7 or x==5 or x==3:print(""YES"") +else:print(""NO"")" +p02791,s597766520,Accepted,"n=int(input()) +p=list(map(int,input().split())) +flag=2*10**5+1 +ans=0 +for i in range(n): + if flag>int(p[i]): + ans+=1 + flag=min(flag,p[i]) +print(ans) +" +p03698,s291358513,Accepted,"from collections import Counter + +s=input() + +n=len(Counter(s)) + +if n==len(s): + ans=""yes"" +else: + ans=""no"" + +print(ans)" +p03761,s315075913,Accepted,"n = int(input()) +s = [input() for _ in range(n)] + +d = [float(""inf"")]*26 +for i in range(n): + e = [0]*26 + for si in s[i]: + e[ord(si) - 97] += 1 + for i in range(26): + d[i] = min(d[i], e[i]) + +ans = """" +for i in range(26): + ans += chr(i + 97) * d[i] + +print(ans)" +p02795,s660961837,Wrong Answer,"H = int(input()) +W = int(input()) +N = int(input()) + +print(min(-(-H//N), -(-W//N)))" +p02696,s484388867,Accepted,"A,B,N=map(int,input().split()) +x=min(B-1,N) +print((A*x)//B-A*(x//B))" +p02909,s668615883,Accepted,"s = input() +if s == ""Sunny"": + print(""Cloudy"") +elif s == ""Cloudy"": + print(""Rainy"") +elif s == ""Rainy"": + print(""Sunny"")" +p04030,s382285410,Accepted,"s = input() + +t = """" +for c in s : + if c != 'B' : + t += c + else : + if t : t = t[0:-1] + +print(t)" +p02835,s314292636,Accepted,"a,b,c = map(int,input().split()) + +if a+b+c>=22: + print(""bust"") +else: + print(""win"")" +p03997,s270724673,Wrong Answer,"a,b,h=map(int,open(0));print(a*b*(h/2))" +p02923,s066117577,Accepted,"n = int(input()) +h_list = list(map(int, input().split())) + +ans = 0 +tmp_ans = 0 +current = h_list[0] +for h in h_list[1:]: + if h <= current: + tmp_ans += 1 + else: + ans = max(tmp_ans, ans) + tmp_ans = 0 + current = h + +ans = max(tmp_ans, ans) +print(ans) +" +p03241,s032403632,Accepted,"# 1 <= N <= 10**5 +# N <= M <= 10**9 +import sys +input = sys.stdin.buffer.readline +N, M = map(int, input().split()) + +V = M // N + +ans = 1 +for i in range(1, V + 1): + if i * i > M: + break + if M % i == 0: + j = M // i + if j <= V: + ans = max(ans, j) + else: + ans = max(ans, i) +print(ans) +" +p02608,s227940524,Accepted,"n=int(input()) +cnt=[0]*(n+1) + +for x in range(1, 101): + for y in range(1, 101): + for z in range(1, 101): + tmp=x*x + y*y + z*z + x*y + y*z + z*x + if tmp <=n: + cnt[tmp]+=1 + + +for i in range(1, n+1): + print(cnt[i])" +p03359,s760188255,Wrong Answer,"a, b = map(int, input().split()) +print(min(a, b))" +p02866,s913078378,Wrong Answer,"from itertools import groupby +inputs = open(0).readlines() +n = int(inputs[0]) +*D, = map(int, inputs[1].split()) +D.sort() +mod = 998244353 + +keys, nodes = [], [] +for k, g in groupby(D): + keys.append(k) + nodes.append(len(list(g))) + +if nodes[0] != 1 or all(i == k for i, k in enumerate(keys)): + print(0) +else: + patterns = [1] + for n0, n1 in zip(nodes, nodes[1:]): + patterns.append(patterns[-1] * pow(n0, n1, mod) % mod) + print(patterns[-1])" +p02697,s974346505,Accepted,"N, M = map(int, input().split()) +if N%2==0: + for i in range(M): + x = 0 + if i>=M/2: + x = 1 + a = 1 + i + b = N - i + print(a+x, b) +else: + n = (N//2)*2 + for i in range(M): + a = 1 + i + b = a + n - (2*i+1) + print(a, b)" +p02973,s140086780,Accepted,"import sys +input = sys.stdin.readline +from collections import deque + +n = int(input()) +a = [int(input()) for _ in range(n)] + +s = deque([a[0]]) + +from bisect import bisect_left + +for i in a[1:]: + if i <= s[0]: + s.appendleft(i) + else: + s[bisect_left(s, i) - 1] = i + +# print(s) +print(len(s)) +" +p03075,s523360413,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) + +if e-a <= k: + print('Yay!') +else: + print(':(')" +p03319,s692734223,Wrong Answer,"n,k = map(int,input().split()) +a = list(map(int,input().split())) + +ni = a.index(1) + +ans = ni//(k-1)+1 +(n-ni-1 + ni%(k-1))//(k-1)+1 +print(ans)" +p03086,s707760618,Wrong Answer,"S = list(input()) +P = set([""A"",""C"",""T"",""G""]) +count = 0 +if P&set(S) == set(): + print(0) + exit() +else: + for i in range(1,len(S)-1): + for j in range(i+1, len(S)): + if set(S[i:j])-P == set(): + count = max(count,j-i) + +print(count)" +p02577,s809515888,Accepted,"# -*- coding: utf-8 -*- +N = input() +ans = 0 +for i in N: + ans += int(i) + ans = ans % 9 +if ans == 0: + print(""Yes"") +else: + print(""No"") +" +p03433,s271297274,Wrong Answer,"N = int(input(""N--->"")) +A = int(input(""A--->"")) + +b = N%500 + +if A > b: + print(""Yes"") +else: + print(""No"")" +p03910,s622790124,Accepted,"n=int(input()) + +ans=[] +s=0 +for i in range(1,n+1): + s+=i + ans.append(i) + if s>=n: + break + +if s==n: + for a in ans: + print(a) +else: + ans.remove((s-n)) + for a in ans: + print(a) +" +p02597,s958469311,Accepted,"#d +n=int(input()) +c=input() +rr=c.count('R') +ans=0 +for i in range(rr): + if c[i]=='W': + ans+=1 +print(ans)" +p03239,s758639779,Accepted,"import sys +input = sys.stdin.readline +N,T = [int(i) for i in input().split()] +minc = 100000 +for i in range(N) : + c,t = [int(i)for i in input().split()] + if t > T : + continue + else : + minc = min(minc,c) +if minc == 100000 : + print(""TLE"") +else : + print(minc)" +p03659,s780058558,Wrong Answer,"# C - Splitting Pile +N = int(input()) +A = list(map(int,input().split())) + +s = [0]*(N+1) +for i in range(N-1): + s[i+1] = s[i] + A[i] +print(s) + +ans = 10**10 +for i in range(1,N): + diff = abs((s[N-1] + A[-1] - s[i]) - s[i]) + ans = min(ans,diff) +print(ans)" +p03720,s288999809,Accepted,"n,m=map(int,input().split()) +List=[] +for i in range(m): + a,b=map(int,input().split()) + List.append([a,b]) + List.append([b,a]) +ans=0 +for i in range(1,n+1): + for j in range(len(List)): + if i==List[j][0]: + ans+=1 + print(ans) + ans=0" +p03951,s109976990,Accepted,"n=int(input()) +s=input() +t=input() +if s==t: + print(n) + exit() +for i in range(n): + if s[i:]==t[:-i]: + print(n+i) + exit() +print(n*2)" +p03835,s658290218,Accepted,"K, S = map(int, input().split()) +a = 0 +for x in range(K+1): + for y in range(K+1): + if 0<=S-x-y<=K : + a+=1 +print(a)" +p03545,s578565408,Accepted,"A = input() + +def bfs(i, f): + if i == 3: + if eval(f) == 7: + print(f+'=7') + exit() + else: + return None + bfs(i+1, f+'+'+A[i+1]) + bfs(i+1, f+'-'+A[i+1]) + return None + +print(bfs(0, A[0]))" +p03994,s323596866,Accepted,"s = list(input()) +k = int(input()) +n = len(s) +for i in range(n-1): + d = (ord('z')-ord(s[i])+1)%26 + if d<=k: + s[i] = 'a' + k -= d + +x = ord(s[-1])+k%26 +if x>ord('z'):x-=26 +s[-1] = chr(x) + + +print(''.join(s)) +" +p03478,s197627063,Accepted,"import math +n,a,b=map(int,input().split()) +ans=0 +for i in range(1,n+1): + s=str(i) + tmp=0 + for k in range(len(s)): + tmp+=int(s[k]) + if tmp>=a and tmp<=b: + ans+=i +print(ans)" +p02958,s825728717,Accepted,"N = int(input()) +P = [ int(s) for s in input().split() ] +P_S = sorted(P) + +if sum(map(lambda x: x[0] != x[1], zip(P,P_S))) <= 2: + print('YES') +else: + print('NO')" +p02701,s560385095,Accepted,"n = int(input()) +gacha = [] + +for i in range(n): + gacha.append(input()) + +import collections +c = collections.Counter(gacha) + +print(len(c))" +p02754,s134366624,Accepted,"N,A,B = map(int,input().split()) +W = N // (A+B) +if N - W*(A+B) <= A: + print(W*A + N-W*(A+B)) +else: + print(W*A + A)" +p03106,s927343353,Wrong Answer,"A, B, K = map(int, input().split()) +limit = min(A, B) +ans = limit +count = 0 + +for i in range(1, limit + 1): + if A % i == 0 and B % i == 0: + count += 1 + if count == K: + ans = i + break + +print(ans)" +p02922,s843759959,Wrong Answer,"a, b = input().split(' ') +c = int(a) +d = int(b) + +if d%c == 0: + print(str(d//c)) +else: + print(str(d//c+1)) +" +p02613,s944807816,Accepted,"from collections import * + +# def solve(): + + +# for _ in range(int(input())): +# solve() +n = int(input()) +l = [] +for i in range(n): + l.append(input()) + +print(""AC x"",l.count(""AC"")) +print(""WA x"",l.count(""WA"")) +print(""TLE x"",l.count(""TLE"")) +print(""RE x"",l.count(""RE"")) +" +p03795,s673021580,Accepted,"a=int(input()) +print(a*800-(a//15)*200)" +p03721,s586474269,Accepted,"N,K = map(int,input().split()) +A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0]) +cnt = 0 +i = 0 +while i= h: + print(""Yes"") +else: + print(""No"") +" +p03449,s044958453,Accepted,"import sys +read_=sys.stdin.buffer.readline + +N=int(read_()) +A=[list(map(int,read_().split())) for _ in range(2)] + +D=[[0]*N for _ in range(2)] + +D[0][0]=A[0][0] +D[1][0]=A[0][0]+A[1][0] + +for i in range(2): + if i==0: + for j in range(1,N): + D[i][j]=D[i][j-1]+A[i][j] + continue + for j in range(1,N): + D[i][j]=max(D[i][j-1],D[i-1][j])+A[i][j] + +print(D[1][N-1])" +p03673,s546315077,Accepted,"n = int(input()) +a = list(map(int, input().split())) +from collections import deque +d = deque() + + +if len(a) %2 == 0: + d.extend(a[::2]) + d.extendleft(a[1::2]) +else: + d.extend(a[1::2]) + d.extendleft(a[::2]) +print(*list(d)) +" +p02939,s344918433,Wrong Answer,"S = list(input()) +s = 0 +num = 0 +ans = 0 +for i in range(len(S)): + if i < num: + continue + for j in range(1,len(S)-i): + if S[i:i+j] != s: + s = S[i:i+j] + num = i+j + ans += 1 + break +print(ans+1)" +p03557,s458228014,Accepted,"import bisect +n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +c=list(map(int,input().split())) +a.sort() +b.sort() +c.sort() +ans=0 +for i in range(n): + temp1=bisect.bisect_left(a,b[i]) + temp2=bisect.bisect(c,b[i]) + ans=ans+temp1*(n-temp2) +print(ans)" +p03555,s246239300,Accepted," +import math + +x=input() +y=input() +flag=True +if(x[0]!=y[2]): + flag=False +elif(x[2]!=y[0]): + flag=False +elif(x[1]!=y[1]): + flag=False +if(flag): + print(""YES"") +else: + print(""NO"")" +p03386,s962037988,Accepted,"a,b,k=map(int,input().split()) +ans=[] +i=0 +while ia[1]: + ans += a[0] + a[0] -= 1 +else: + ans += a[1] + a[1] -= 1 +if a[0]>a[1]: + ans += a[0] +else: + ans += a[1] +print(ans) + +" +p02645,s865809388,Accepted,"from sys import stdin +from sys import setrecursionlimit +setrecursionlimit(10 ** 7) + +s = input() +print(s[:3])" +p04020,s307868386,Accepted,"N=int(input()) +A=[] +for i in range(N): + A.append(int(input())) + +ans=0 +for i in range(N-1): + x=A[i] + ans+=x//2 + if x%2==1 and A[i+1]>=1: + ans+=1 + A[i+1]-=1 + +ans+=A[N-1]//2 +print(ans) +" +p02583,s047216769,Wrong Answer,"n = int(input()) + +l = list(map(int,input().split())) + +l.sort() + +ans = 0 +if n <3: + print(0) +else: + for i in range(n-2): + for j in range(i+1,n-1): + for k in range(j+1,n): + if l[i] + l[j] > l[k]: + ans += 1 + print(ans)" +p02600,s960478667,Accepted,"s = int(input()) +if 400 <= s <= 599: + print(""8"") +elif 600 <= s <= 799: + print(""7"") +elif 800 <= s <= 999: + print(""6"") +elif 1000 <= s <= 1199: + print(""5"") +elif 1200 <= s <= 1399: + print(""4"") +elif 1400 <= s <= 1599: + print(""3"") +elif 1600 <= s <= 1799: + print(""2"") +elif 1800 <= s <= 1999: + print(""1"")" +p03145,s178918429,Accepted,"# ABC 116: A – Right Triangle +ab, bc, ca = [int(s) for s in input().split()] +print(ab * bc // 2)" +p03013,s095143044,Accepted,"import itertools,sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +N,M = LI() +a = set([I() for _ in range(M)]) +dp = [0]*(N+1) #1_indexed +dp[0] = 1 +dp[1] = 0 if 1 in a else 1 +for i in range(N+1): + if i in a: + dp[i] = 0 + continue + if i-2>=0: + dp[i] = (dp[i-1]+dp[i-2])%(10**9+7) +print(dp[-1]) +" +p03779,s756255281,Accepted,"def cin(): + in_ = list(map(int,input().split())) + if len(in_) == 1: return in_[0] + else: return in_ + +X = cin() +cnt = 0 +i = 0 +while(i < X): + cnt += 1 + i += cnt +print(cnt)" +p03795,s062788372,Accepted,"# -*- coding: utf-8 -*- + +def main(): + + N = int(input()) + + x = N * 800 + y = (N // 15) * 200 + + ans = x - y + + print(ans) + + +if __name__ == ""__main__"": + main()" +p02731,s230429736,Wrong Answer,"L = int(input()) +print((L / 2) ** 3) +" +p02627,s628141336,Accepted,"a = str(input()) +alp = 'abcdefghijklmnopqrstuvwxyz' +if a in alp: + print('a') +else: + print('A')" +p02723,s522882795,Accepted,"def main(): + s = input() + + if s[2]==s[3] and s[4]==s[5]: + print('Yes') + else: + print('No') + +if __name__ == ""__main__"": + main()" +p02833,s425200074,Accepted,"N = int(input()) + +def ans(n): + if n % 2 != 0: + return 0 + else: + index,count = 1,0 + while 2 * 5**index <= n: + count += n // (2 * 5**index) + index += 1 + return count + +print(ans(N)) +" +p03761,s872253274,Accepted,"from collections import Counter +n = int(input()) +lists = list(input()) +l = dict(Counter(lists)) +for i in range(n-1): + tmp_l = dict(Counter(list(input()))) + for key in l.keys(): + if key not in tmp_l.keys(): + l[key] = 0 + elif l[key] > tmp_l[key]: + l[key] = tmp_l[key] + +string = """" +for key in l: + string += ''.join([key for _ in range(l[key])]) + +l = list(string) +l.sort() + +string = ''.join(l) +print(string)" +p03645,s690380265,Accepted,"n, m = map(int,input().split()) +data = [list(map(int, input().split())) for _ in range(m)] +start = set(i[1] for i in data if i[0] == 1) +goal = set(j[0] for j in data if j[1] == n) + +if start & goal: + print('POSSIBLE') +else: + print('IMPOSSIBLE')" +p02718,s198134163,Accepted,"import sys +import numpy as np + + +scan = sys.stdin.readline + + +def main(): + n, m = map(int, scan().rstrip().split()) + a = np.array([int(_) for _ in scan().rstrip().split()]) + + votes = np.sum(a) + candidate_num = np.sum(a >= (votes / (4 * m))) + + if candidate_num >= m: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + main() +" +p03001,s082491823,Accepted,"#create date: 2020-06-29 13:35 + +import sys +stdin = sys.stdin + +def ns(): return stdin.readline().rstrip() +def ni(): return int(ns()) +def na(): return list(map(int, stdin.readline().split())) + +def main(): + w, h, x, y = na() + print(""{:.10f} {}"".format(w*h/2, 1 if w/2==x and h/2==y else 0)) + +if __name__ == ""__main__"": + main()" +p03107,s187958382,Accepted,"S = str(input()) +s0 = s1 = 0 +for s in S: + if s == ""1"": + s1 += 1 + else: + s0 += 1 +print(min(s0, s1)*2)" +p03639,s902911832,Accepted,"N=int(input()) +a=list(map(int,input().split())) +odd=0 +four=0 +for i in range(N): + if a[i]%4==0: + four+=1 + elif a[i]%2!=0: + odd+=1 +if four>=odd: + print(""Yes"") +else: + if odd==four+1 and odd+four==N: + print(""Yes"") + else: + print(""No"")" +p03457,s788458101,Wrong Answer,"n = int(input()) +X, Y, T=0, 0, 0 +for i in range(n): + t, x, y = map(int, input().split()) + if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2: + continue + else: + print('No') + quit() + X, Y, T= x, y, T +print('Yes') +" +p03371,s177200981,Wrong Answer,"A, B, C, X, Y = map(int, input().split()) +if C * 2 < A and C * 2 < B: + print(C * max(X, Y) * 2) +elif C * 2 < A + B: + if X < Y: + print(C * X * 2 + B * (Y - X)) + else: + print(C * Y * 2 + A * (X - Y)) +else: + print(A * X + B * Y) +" +p02935,s114386253,Accepted,"N = int(input()) +V = list(map(int,input().split())) + +V.sort() + +T = V[0] +for i in range(1,N): + T = (T+V[i])/2 +print(T) +" +p02988,s323234588,Accepted,"n = int(input()) +p = list(map(int, input().split())) + +cnt = 0 +for i in range(1,n-1): + if (p[i] > p[i-1]) and (p[i] < p[i+1]): cnt += 1 + if (p[i] < p[i-1]) and (p[i] > p[i+1]): cnt += 1 +print(cnt)" +p02910,s119939085,Accepted,"S = input() +print(""No"" if ""L"" in S[::2] or ""R"" in S[1::2] else ""Yes"")" +p02823,s520332887,Accepted,"import sys +input = sys.stdin.readline + + +def main(): + n,a,b = [int(i) for i in input().strip().split()] + if (b-a) % 2 == 0: + print(abs(b - a) // 2) + else: + ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2 + print(ans) + return + + + +if __name__ == ""__main__"": + main()" +p03544,s669170488,Accepted,"n = int(input()) + +l = [2,1] +for i in range(2,n+1): + l.append(l[i-1] + l[i-2]) + +print(l[n])" +p02909,s495347671,Accepted,"s = [""Sunny"", ""Cloudy"", ""Rainy""] +x = input() +print(s[(s.index(x) + 1)%3])" +p03250,s739289444,Wrong Answer,"A,B,C = input().split() +ls = [int(A+B)+int(C),int(A)+int(B+C),int(B)+int(A+C)] +print(max(ls))" +p02791,s168992279,Accepted,"n = int(input()) +list = list(map(int,input().split())) +count = 0 +minimum = list[0] +for i in range(n): + if minimum >= list[i]: + count += 1 + minimum = list[i] + +print(""%d""%(count))" +p03434,s430895822,Accepted,"def main(): + N = int(input()) + a = sorted([int(x) for x in input().split("" "")], reverse=True) + Alice = sum([x for i, x in enumerate(a) if i % 2 == 0]) + Bob = sum([x for i, x in enumerate(a) if i % 2 == 1]) + print(Alice-Bob) + + +if __name__ == '__main__': + main() +" +p03944,s841092364,Accepted,"w,h,n = map(int,input().split()) +x1 = 0 +x2 = w +y1 = 0 +y2 = h +for i in range(n): + x,y,a = map(int,input().split()) + if a == 1: + x1 = max(x1,x) + elif a == 2: + x2 = min(x2,x) + elif a == 3: + y1 = max(y1,y) + else: + y2 = min(y2,y) +if x1 >= x2 or y1 >= y2: + print(0) +else: + print(w*h-h*(x1+w-x2)-(x2-x1)*(y1+h-y2))" +p02727,s896633050,Accepted,"X,Y,A,B,C = map(int,input().split()) +r_l = list(map(int,input().split())) +b_l = list(map(int,input().split())) +n_l = list(map(int,input().split())) + +r_l.sort(reverse=True) +b_l.sort(reverse=True) + +a_l = r_l[:X] + b_l[:Y] + n_l +a_l.sort(reverse=True) +print(sum(a_l[:X+Y]))" +p02717,s521807266,Wrong Answer,"X,Y,Z = map(int,input().split()) +print(Y,Z,X)" +p02791,s529908335,Accepted,"N = int(input()) +ps = list(map(int, input().split())) +m = 10**10 +cnt = 0 +for p in ps: + if p < m: + cnt += 1 + m = p +print(cnt)" +p03323,s830612453,Wrong Answer,"a, b = map(int,input().split()) + +if a <9 and b < 9: + print(""Yay"") +else: + print("":("") +" +p02571,s485522087,Accepted,"s = input() +t = input() +ans = 10000 +if t in s: + print(0) + exit() + +for i in range(len(s)-len(t)+1): + cut = s[i:i+len(t)] + cnt = 0 + for k, j in zip(cut, t): + if k != j: + cnt += 1 + ans = min(ans, cnt) + +print(ans)" +p03556,s508331982,Accepted,"n = int(input()) + +for i in range(n): + if (n-i)**(0.5)==int((n-i)**(0.5)): + print(n-i) + break" +p03471,s288456928,Accepted,"def main(): + n,y = map(int,input().split()) + flag = 0 + for i in range(n + 1): + for j in range(n - i + 1): + if flag == 0 and i * 10000 + j * 5000 + 1000 * (n - i - j) == y: + flag = 1 + print(i,j,n - i - j) + if flag == 0: + print('-1 -1 -1') +main()" +p03427,s137293191,Accepted,"# 3:06 +s = input() +out = True +for c in s[1:]: + if c != '9': + out = False + break + +if out: + print(int(s[0]) + (len(s) - 1) * 9) +else: + print(int(s[0]) - 1 + (len(s) - 1) * 9) +" +p03457,s021591306,Accepted,"N = int(input()) + +old_t = 0 +old_x = 0 +old_y = 0 + +for _ in range(N): + t, x, y = list(map(int, input().split())) + rest_t = t - old_x + diff = abs(x - old_x) + abs(y - old_y) + if (rest_t < diff) or (old_t - t + old_x - x + old_y -y) % 2 != 0: + print(""No"") + exit() + old_t = t + old_x = x + old_y = y + +print(""Yes"") + + +" +p03759,s117127478,Accepted,"a, b, c = map(int, input().split()) + +if b-a == c-b: + print('YES') +else: + print('NO')" +p03481,s122789183,Accepted,"X,Y = map(int,input().split()) +cnt = 0 +while X<=Y: + cnt += 1 + X *=2 +print(cnt) " +p02900,s837994650,Wrong Answer,"import math + +a,b = map(int, input().split()) +gcdab = math.gcd(a,b) + +def soinsu(x): + s = {} + if x % 2 == 0: + t = 0 + while x % 2 == 0: + x //= 2 + t += 1 + s[2] = t + for i in range(3, 10**12, 2): + t = 0 + while x % i == 0: + x //= i + t += 1 + s[i] = t + if x == 1: + break + return s + +ans = len(soinsu(gcdab)) + 1 +print(ans)" +p02842,s835251166,Accepted,"from math import floor + +def main(N, rate=1.08): + ans = -1 + for x in range(1, N+1): + if floor(x * 1.08) == N: + ans = x + return ans + + +if __name__ == ""__main__"": + N = int(input()) + ans = main(N) + print(ans if ans > 0 else ':(') +" +p02664,s399183963,Accepted,"T = input() + +print(T.replace('?', 'D'))" +p03773,s518386667,Wrong Answer,"A,B=map(int,input().split()) +if A+B<=24: + print(A+B) +else: + print(A+B-24)" +p02880,s759087942,Wrong Answer,"n = int(input()) +prime = [2] +for i in range(3, 101): + for j in range(2, i + 1): + if (i % j) == 0: + break + if i == j: + prime.append(i) +pflag = True +for k in prime: + if k >= 10: + if (n % k == 0): + pflag = False +for l in range(50, 101, 10): + if (n % l) == 0: + pflag = False +if(pflag): + print('Yes') +else: + print('No')" +p02988,s168386189,Accepted,"n = int(input()) +p = list(map(int,input().split())) +cnt=0 + +for i in range(1,n-1): + if p[i-1] >p[i] > p[i+1] or p[i-1] sum or mind==-1: + mind=sum + +print(mind) +" +p02935,s744314579,Wrong Answer,"import math + +N = int(input()) +v = list(map(int, input().split())) + +v.sort(reverse=True) + +while len(v) > 1: + v.append((v.pop() + v.pop())/2) + +print(v) + + + + + + +" +p02823,s701244748,Accepted,"N, A, B = map(int, input().split()) + +if (B - A) % 2 == 0: + print((B - A) // 2) +else: + ans = min(A, N - B + 1) + (B - A - 1) // 2 + print(ans) +" +p03836,s719486191,Accepted,"sx, sy, tx, ty = map(int, input().split()) + +dx, dy = tx - sx, ty - sy +print('U' * dy + 'R' * dx + 'D' * dy + 'L' * (dx + 1) + 'U' * (dy + 1) + + 'R' * (dx + 1) + 'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U') +" +p02801,s227006878,Accepted,"c = input() + +print(chr((ord(c) + 1))) +" +p03345,s552362144,Wrong Answer,"#-*-coding:utf-8-*- +import sys +input=sys.stdin.readline + +def main(): + a,b,c,k = map(int,input().split()) + + if a == b == c: + print(0) + elif a*k>10**18 or b*k > 10**18 or c*k > 10**18: + print(""Unfair"") + elif k % 2==0: + print(-1*((b+c)-(a+c))) + else: + print((b+c)-(a+c)) + + +if __name__==""__main__"": + main()" +p02861,s654726937,Accepted,"import math +import itertools +N = int(input()) +x = [] +result = 0 +for _ in range(N): + x.append(list(map(int, input().split()))) +for i in itertools.permutations(list(range(N))): + for j in range(len(i)-1): + result += math.sqrt((x[i[j]][0] - x[i[j+1]][0])**2 + + (x[i[j]][1] - x[i[j+1]][1])**2) +print(result/math.factorial(N)) +" +p02957,s716528346,Accepted,"import os, sys, re, math + +A,B = map(int,input().split(' ')) +ret = max(A,B) + min(A,B) +if ret % 2 == 0: + print(ret // 2) +else: + print('IMPOSSIBLE') +" +p02784,s823205800,Wrong Answer,"h, n = map(int, input().split()) +a = map(int, input().split()) +if h < sum(a): + print('Yes') +else: + print('No')" +p02712,s511441973,Accepted,"a = int(input()) +total = 0 +for i in range(1, a+1): + if i % 5 != 0 and i % 3 != 0: + total += i + +print(total)" +p03699,s022900702,Wrong Answer,"n=int(input()) +dp=[0]*10**5 + +dp[0]=1 + +for _ in range(n): + s=int(input()) + tmp=[0]*10**5 + for i in range(10**4+1): + tmp[i]=dp[i] + if s<=i: + tmp[i]=dp[i-s] + dp=tmp + +for i in range(10**4,0,-1): + if i%10==0: + continue + + if dp[i]: + print(i) + break +else: + print(0)" +p03605,s306990688,Wrong Answer,"N = input() +if N[0] == 9 or N[1] == 9: + print('Yes') +else: + print('No') +" +p02817,s725358982,Accepted,"S, T = input().split() +print (T+S)" +p03206,s129349507,Accepted,"D = int(input()) +a = ""Christmas "" +b = ""Eve "" +print(a+b*(25-D))" +p02843,s969583420,Accepted,"X = list(input()) +if len(X)<=2: + print(0) + exit() +con = X[len(X)-2:len(X)] +kak = X[0:len(X)-2] +kak = int("""".join(kak)) +con = int("""".join(con)) +if con>=5: + imp1 = con//5 + imp2 = con%5 +else: + imp1 = 1 + imp2 = 0 +#print(kak, imp1, imp2) +if kak>=imp1+imp2: + print(1) +else: + print(0)" +p03352,s263220526,Accepted,"X = int(input()) +res = 0 +for i in range(1, 1000): + for j in range(2, 1000): + if i**j <= X: + res = max(i**j, res) + else: + break +print(res)" +p03673,s436186320,Accepted,"from collections import deque + +n = int(input()) +a_L = list(map(int,input().split())) + +ans = deque() + +if n %2 == 0: + for i in range(0,n): + if i %2 != 0: + ans.appendleft(a_L[i]) + else: + ans.append(a_L[i]) +else: + for i in range(0,n): + if i %2 == 0: + ans.appendleft(a_L[i]) + else: + ans.append(a_L[i]) + +print(*ans)" +p03427,s130378784,Wrong Answer,"n = input() +print((len(n) - 1) * 9 - 1 + int(n[0])) +" +p03254,s968461543,Accepted,"n,x = map(int,input().split()) +A = list(map(int,input().split())) +A.sort() +cnt = 0 +if x > sum(A): + print(n-1) +else: + for i in range(n): + if (x - A[i]) >= 0: + x -= A[i] + cnt += 1 + else: + break + print(cnt)" +p02939,s680297503,Accepted,"s=str(input()) +s=list(s) +ans=1 +i=1 +temp=s[0] +while True: + if s[i]!=temp: + ans=ans+1 + temp=s[i] + i=i+1 + elif s[i]==temp and i==len(s)-1: + i=i+1 + else: + temp=s[i]+s[i+1] + i=i+2 + ans=ans+1 + if i>len(s)-1: + break +print(ans)" +p04044,s693567054,Accepted,"N, L = map(int, input().split()) +S = [] +ans = '' + +for i in range(N): + S.append(input()) + +for i in range(N): + ans += min(S) + del S[S.index(min(S))] + +print(ans)" +p02695,s780545886,Accepted,"def rec(L): + return sum([d for a, b, c, d in X if L[b] - L[a] == c]) if len(L) > N else max([rec(L + [i]) for i in range(L[-1], M)]) + +N, M, Q = map(int, input().split()) +X = [] +for _ in range(Q): + a, b, c, d = map(int, input().split()) + X.append((a, b, c, d)) +print(rec([0]))" +p03627,s226614739,Accepted,"import sys +input = sys.stdin.readline +from collections import * + +N = int(input()) +A = list(map(int, input().split())) +cnt = Counter(A) +l = [] + +for k, v in cnt.items(): + if v>=2: + l.append(k) + +l.sort(reverse=True) + +if len(l)==0: + print(0) +elif len(l)==1: + if cnt[l[0]]>=4: + print(l[0]*l[0]) + else: + print(0) +else: + if cnt[l[0]]>=4: + print(l[0]*l[0]) + else: + print(l[0]*l[1])" +p03435,s144609432,Accepted,"import sys +c=list(map(int,input().split())) +diffa=c[1]-c[0] +diffb=c[2]-c[1] + +c=list(map(int,input().split())) +if(diffa!=(c[1]-c[0]) or diffb!=(c[2]-c[1])): + print(""No"") + sys.exit() + +c=list(map(int,input().split())) +if(diffa!=(c[1]-c[0]) or diffb!=(c[2]-c[1])): + print(""No"") + sys.exit() + +print(""Yes"")" +p02918,s602114623,Accepted,"n,k = map(int, raw_input().split()) +s = raw_input() +cd = 0 +d = None +for l in s: + if d != l: + cd +=1 + d = l +score = 0 +for u,v in zip(s,s[1:]): + if u == v: + score +=1 + +while(k and cd > 1): + + if cd > 2: + score += 2 + cd -= 2 + elif cd == 2: + score +=1 + cd -= 1 + k -=1 +print score" +p02705,s733057212,Accepted,"r = int(input()) +pi = 3.14159265358979 + +print(r*2*pi)" +p03073,s943762232,Accepted,"s = list(input()) +c = 0 +for i in range(1,len(s)): + if(s[i] == s[i-1]): + s[i] = str(int(s[i])^1) + c += 1 +print(c)" +p02835,s971621056,Accepted,"a, b, c = map(int, input().split()) + +if a + b + c >= 22: + print(""bust"") +else: + print('win')" +p02555,s497111602,Wrong Answer,"N = int(input()) +if N == 1: + print(0) +else: + print(pow(pow(9,N) - pow(8,N) - pow(8,N) + pow(7,N), 1, 1000000007)) +" +p03251,s414718254,Accepted,"n,m,x,y=map(int,input().split()) +x=list(map(int,input().split()))+[x] +y=list(map(int,input().split()))+[y] +if max(x) 0: + res -= 1 +print(res)" +p02832,s220045392,Accepted,"N = int(input()) +bricks = [int(x) for x in input().split()] + +next_number = 1 +num_broken = 0 + +for brick in bricks: + if brick == next_number: + next_number += 1 + else: + num_broken += 1 + +if next_number == 1: + print(-1) +else: + print(num_broken)" +p02701,s186463367,Accepted,"N=int(input()) +print(len(set([input() for _ in range(N)])))" +p02595,s229033157,Accepted,"N,D=map(int, input().split()) +d=D**2 +ans=0 +for maimelkm in range(N): + x,y=map(int, input().split()) + if x**2+y**2<=d: + ans+=1 + + +print(ans) + + +# 2darray [[0] * 4 for i in range(3)] +# import itertools" +p02642,s020637584,Accepted,"N = int(input()) +A = list(map(int, input().split())) +A.sort() +exist_flags = [0] * (10 ** 6) +for a in A: + if exist_flags[a - 1] > 0: + exist_flags[a - 1] += 1 + else: + # for i in range(a, 25, a): + for i in range(a, 10 ** 6 + 1, a): + exist_flags[i - 1] += 1 + + +ans = 0 +for a in A: + if exist_flags[a - 1] == 1: + ans += 1 +print(ans)" +p02642,s930206474,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) + +MAX_N = max(A)+1 +cnt = [0] * MAX_N + +for a in A: + for i in range(a, MAX_N, a): + if cnt[i] >= 2: break + cnt[i] += 1 + +ans = 0 +for a in A: + if cnt[a] == 1: ans += 1 +print(ans)" +p03633,s940758017,Accepted,"from math import gcd +n = int(input()) + +time = list(int(input()) for _ in range(n)) + +ans = time[0] + +for i in range(1,n): + ans = (ans * time[i]) // gcd(ans, time[i]) + +print(int(ans))" +p03286,s988618122,Wrong Answer,"n=int(input()) +s="""" +while n: + print(n) + s=str(n&1)+s + n=-(n>>1) + print(s) +print(s if s else 0)" +p02959,s803705218,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) +ans=0 +for i in range(N): + if A[i]<=B[i]: + ans+=A[i] + B[i]-=A[i] + if A[i+1]<=B[i]: + ans+=A[i+1] + A[i+1]=0 + else: + ans+=B[i] + A[i+1]-=B[i] + else: + ans+=B[i] +print(ans)" +p02862,s844158504,Accepted,"MOD = 10 ** 9 + 7 + +X, Y = map(int, input().split()) + +if (X + Y) % 3 != 0: + print(0) + exit() + +a = (2 * X + - Y) // 3 +b = ( - X + 2 * Y) // 3 + + +if a < 0 or b < 0: + print(0) + exit() + +#calculate (a+b)!/a!b! + +fac = [1, 1] +for i in range(2, a+b+1): + fac.append(fac[-1] * i % MOD) + +print(fac[a+b] * pow(fac[a] * fac[b], MOD-2, MOD) % MOD)" +p02571,s877960410,Accepted,"S = input() +T = input() + +cnt = [] +for i in range(len(S)-len(T)+1): + unmch = 0 + for j, t in enumerate(T): + if t != S[i+j]: + unmch +=1 + cnt += [unmch] + +print(min(cnt)) +" +p02582,s892015900,Accepted,"S = input() + +if S == ""SSS"": + print(0) +if S == ""RSS"": + print(1) +if S == ""RRS"": + print(2) +if S == ""RRR"": + print(3) +if S == ""SRS"": + print(1) +if S == ""SSR"": + print(1) +if S == ""SRR"": + print(2) +if S == ""RSR"": + print(1)" +p04045,s092919848,Accepted,"n,_=map(int,input().split()) +s=set(input().split()) +while s&set(str(n)): n+=1 +print(n)" +p02900,s669158008,Accepted,"import math +from collections import defaultdict + + +def trial_division(n): + factor = defaultdict(int) + tmp = int(math.sqrt(n)) + 1 + for num in range(2, tmp): + while n % num == 0: + n //= num + factor[num] += 1 + factor[n] += 1 + if 1 not in factor.keys(): + factor[1] += 1 + return factor + + +a, b = map(int, input().split()) +ans = 0 +for i in trial_division(a).keys(): + if i in trial_division(b).keys(): + ans += 1 +print(ans)" +p03524,s623389020,Accepted,"S = input() +M = {'a':0,'b':0,'c':0} +for s in S: + M[s] += 1 +L = sorted(M.values(),key=lambda x: -x) +if len(L) == 1: + if L[0] == 1: + print('YES') + else: + print('NO') +elif len(L) == 2: + print('NO') +else: + if L[0] - L[2] > 1: + print('NO') + else: + print('YES')" +p02951,s081855590,Accepted,"a, b, c = [int(x) for x in input().split()] +print(max(c - a + b, 0)) +" +p02690,s918567230,Wrong Answer,"X=int(input()) +i=1 +while (X+(i**5))**(1/5)-int((X+(i**5))**(1/5))>10**(-8): + i+=1 + if X10**(-8): + i-=1 + break +print(""{} {}"".format(int((X+(i**5))**(1/5)), i))" +p03486,s726657784,Wrong Answer,"s="""".join(sorted(list(input()))) +t="""".join(sorted(list(input()),reverse=True)) + +print(""Yes"" if [s,t]==sorted([s,t]) else ""No"")" +p02973,s814115219,Accepted,"import bisect +n = int(input()) +a = [int(input()) for i in range(n)] +ans = 0 +color = [a[n-1]] +for i in range(n-2,-1,-1): + if a[i]>=color[-1]: + color.append(a[i]) + else: + x = bisect.bisect_right(color,a[i]) + color[x] = a[i] +print(len(color))" +p02848,s976212845,Accepted,"data = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" +#print(ord(""A"")) +#print(ord(""Z"")-65) + +n=int(input()) +a=input() +ans="""" +for i in a: + p = (ord(i)-65+n)%26 + ans+=data[p] +print(ans)" +p03605,s607977959,Wrong Answer,"import random +a=input() +kekka=['Yes','No'] +print(random.choice(kekka))" +p02696,s485317711,Accepted,"import math +a, b, n = map(int, input().split()) +ans = -float('inf') +n = min(b-1, n) +f1 = math.floor(a*n/b) +f2 = math.floor(n/b) +ans = f1-(a*f2) +print(ans)" +p03345,s544607020,Accepted,"A,B,C,K=map(int, input().split()) +print(B-A if K&1 else A-B)" +p02725,s450556412,Wrong Answer,"k, n = map(int, input().split()) +a = list(map(int, input().split())) + +x = 0 +index = 0 + +for i in range(n-1): + if x < a[i+1] - a[i]: + x = a[i+1] - a[i] + index = i + +if x < k-a[-1]+a[0]: + x = k-a[-1]+a[0] + +print(k - x,k, x,k-a[-1]+a[0]) +" +p02711,s551014604,Accepted,"score = int(input()) +answer = 0 +for i in range(3): + if int(score/(10**i))%10 == 7: + answer = 1 + break +if answer == 1: + print('Yes') +else: + print('No')" +p02555,s703247018,Accepted,"s = int(input()) +dp =[0]*2001 +dp[0] = dp[1] = dp[2] = 0 +dp[3] = dp[4] = dp[5] = 1 +dp[6] = dp[3]+1 +for i in range(7,s+1): + dp[i] = dp[i-1]+dp[i-3] +print(dp[s] % (10**9+7)) +" +p03644,s583061806,Accepted,"N = int(input()) +result = [] +for i in range(1, N+1): + bin_i = bin(i) + bin_i_c = bin_i.count(""0"")-1 + result.append(bin_i_c) +sorted_result = sorted(result, reverse = True) +print(2 ** sorted_result[0])" +p03137,s156348062,Accepted,"N,M = map(int,input().split()) +X = list(map(int,input().split())) +X.sort() +index = [] +ans = 0 +s = 0 +for i in range(len(X)-1): + index.append([i,X[i+1]-X[i]]) +index.sort(key=lambda x: x[1],reverse=True) +if N12 and r > 12) or (l == 00 and r > 12) or(l > 12 and r == 00): + print(""NA"") +elif l > 12 and r < 13: + print(""YYMM"") +elif l < 13 and r > 12: + print(""MMYY"") +elif l == 00 and r < 13: + print(""YYMM"") +elif l < 13 and r == 00: + print(""MMYY"") +elif l <= 12 and r <= 12: + print(""AMBIGUOUS"")" +p02911,s025185666,Accepted,"n, k, q = map(int,input().split()) +ls = [0 for i in range(n)] + +for i in range(q): + a = int(input()) - 1 + ls[a] += 1 + +for i in range(n): + if q - ls[i] >= k: + print(""No"") + else: + print(""Yes"") +" +p02607,s366214272,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +O = [i for i in range(N) if(i%2==1 and A[i]%2==1)] +print(len(O))" +p02761,s229572734,Wrong Answer,"n, m = map(int, input().split()) +sc = [list(map(int, input().split())) for _ in range(m)] + +ans = [0 for _ in range(n)] +one = False +for x in sc: + p = x[0]-1 + if p == 0: + one = True + if ans[p] == 0 or ans[p] >= x[1]: + ans[p] = x[1] +if not one: + print(-1) + exit() +num = '' +for x in ans: + num += str(x) +print(int(num) if len(str(int(num))) == n else -1)" +p03146,s091724856,Accepted,"n = int(input()) +l = [0] * 1000001 +count = 1 +while not l[n]: + l[n] = 1 + n = 3 * n + 1 if n & 1 else n >> 1 + count += 1 +print(count)" +p03037,s352349650,Accepted,"def main(): + n,m=map(int,input().split()) + CARD=[0]*(n+1) + for i in range(m): + L,R=map(int,input().split()) + CARD[L-1]+=1 + CARD[R]-=1 + ans=0 + for i in range(n): + if CARD[i]==m:ans+=1 + CARD[i+1]=CARD[i+1]+CARD[i] + + print(ans) + +if __name__=='__main__': + main()" +p02712,s729766802,Wrong Answer,"import sys +sys.setrecursionlimit(1000000) + +N = int(input()) +sum = 0 + +for i in range(N): + if i % 15 != 0 and i % 3 != 0 and i % 5 != 0: + sum += i + +print(sum)" +p02627,s713961218,Accepted,"a = input() + +if ord(a) >= 97: + print(""a"") +else: + print(""A"")" +p03760,s373176128,Wrong Answer,"o=input() +e=input() +print("""".join([o[i]+e[i] for i in range(len(o)-1)]),end="""") +print(o[-1],end="""") +if len(o) != len(e): + print(e[-1])" +p02924,s127625814,Accepted,"n = int(input()) +print(n*(n-1)//2) +" +p03071,s868216872,Accepted,"a,b = map(int, input().split()) +print(max(2*a-1,2*b-1)) if a!=b else print(a+b)" +p03062,s361799258,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +A_plus = [] +A_zero = [] +A_minus = [] + +a_abs_min = 10**10 + +for a in A: + if a > 0: + A_plus.append(a) + elif a == 0: + A_zero.append(a) + else: + A_minus.append(a) + + if abs(a) < a_abs_min: + a_abs_min = abs(a) + +if len(A_minus)%2 == 0: + ans = sum(A_plus)-sum(A_minus) +else: + ans = sum(A_plus)-sum(A_minus) - 2*a_abs_min +print(ans)" +p03150,s503804323,Accepted,"s = list(input()) +for i in range(7): + if """".join(s[:i] + s[-(7 - i):]) == ""keyence"": + print(""YES"") + exit() +print(""YES"" if """".join(s[:7]) == ""keyence"" else ""NO"")" +p03252,s753440037,Accepted,"from collections import Counter +def main(): + S = input() + T = input() + s = sorted(Counter(S).values()) + t = sorted(Counter(T).values()) + return 'Yes' if s == t else 'No' + +print(main()) +" +p03495,s867910211,Accepted,"from collections import Counter +N,K=map(int,input().split()) +A=Counter(input().split()) +print(sum(sorted(A.values(), reverse=True)[K:]))" +p02572,s047397146,Accepted,"import sys + +stdin = sys.stdin +def ns(): return stdin.readline().rstrip() +def ni(): return int(stdin.readline().rstrip()) +def nm(): return map(int, stdin.readline().split()) +def nl(): return list(map(int, stdin.readline().split())) + + +def main(): + n = ni() + A = nl() + mod = 10 ** 9 + 7 + s = sum(A) + q = sum([a ** 2 for a in A]) + ans = (((s * s) - q)) // 2 + print(int(ans % mod)) + + +if __name__ == '__main__': + main() +" +p03105,s488785354,Accepted,"a,b,c = map(int,input().split()) + +print(min(int(b/a),c)) + " +p02641,s838865178,Accepted,"X, N = map(int, input().split()) +P = sorted(list(map(int, input().split()))) +ans = -1 +diff = 100000 +for i in range(-10,110): + if i in P: continue + if diff > abs(i-X): + diff = abs(i-X) + ans = i +print(ans) +" +p02793,s185557466,Wrong Answer,"N = int(input()) +*A, = map(int,input().split()) + +mod = 10**9+7 + +def gcd(x,y): + if y==0: return x + return gcd(y,x%y) + +lcm = A[0] +for a in A[1:]: + lcm = (lcm*a)*pow((gcd(lcm,a)),mod-2,mod) + +ans = 0 +for a in A: + ans += lcm*pow(a,mod-2,mod) + ans %= mod +print(ans)" +p04029,s807017392,Wrong Answer,"def total(n): + return 1/2 * n * (n + 1) + +n = int(input()) +print(total(n))" +p03416,s368715519,Accepted,"A, B = map(int,input().split()) + +count = 0 +for i in range(A,B+1): + if str(i) == str(i)[::-1]: + count += 1 + +print(count)" +p02717,s359603508,Accepted,"a, b, c = [int(w) for w in input().split()] + +print(c, a, b) +" +p02613,s074897592,Wrong Answer,"n= int(input()) +ac=str(""AC X"") +wa=str(""WA X"") +tle=str(""TLE X"") +re=str(""RE X"") +a=0;b=0;c=0;d=0 +for i in range(n): + p=input() + if(p==""AC""): + a+=1 + if(p==""WA""): + b+=1 + if (p == ""TLE""): + c += 1 + if (p == ""RE""): + d += 1 +print(ac,a) +print(wa,b) +print(tle,c) +print(re,d)" +p02572,s905486900,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = sum(A) +cnt = 0 +for i in range(N-1): + B -= A[i] + cnt += A[i]*B + +print(cnt%((10**9)+7))" +p02790,s699443272,Accepted,"a,b=input().split() +A=int(a) +B=int(b) +p=a*B +q=b*A +ans=[p,q] +ANS=sorted(ans) +print(ANS[0])" +p02933,s466117054,Accepted,"a = int(input()) +s = input() +if a >= 3200: + print(s) +else: + print(""red"") +" +p03221,s054765063,Accepted,"import sys +import collections +import bisect as bs +input=sys.stdin.readline +n,m=map(int,input().split()) +d=collections.defaultdict(list) +L=[] +for i in range(m): + a,b=map(int,input().split()) + L.append((a,b)) +for x,y in sorted(L): + d[x].append(y) +for x,y in L: + z=bs.bisect(d[x],y) + print(""%06d%06d""%(x,z))" +p03767,s980469876,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +md = 1000000007 + +num = 0 +a.sort(reverse=True) +for i in range(n, 2*n): + num += a[i] +print(num)" +p03469,s082118557,Accepted,"print(""2018""+input()[4:])" +p03284,s887073912,Accepted,"N, K = map(int, input().split()) +print(0 if N % K == 0 else 1) +" +p03478,s851891273,Accepted,"x, a, b, = map(int, input().split()) + +sum_number = [] + +for i in range(x+1): + if a <= sum(map(int, str(i))) <= b: + sum_number += [i] + +print(sum(sum_number)) + + +" +p03565,s610161215,Wrong Answer,"s = input() +t = input() +ans = 'UNRESTORABLE' +for i in range(len(s)-len(t), -1, -1): + for j in range(len(t)): + if s[i+j] != '?' and s[i+j] != t[j]: + ans = (s[:i] + t + s[i+len(t):]).replace('?', 'a') + break +print(ans)" +p03126,s561088547,Accepted,"n,m = map(int,input().split()) +x = [] +c = 0 +for i in range(n): + a = list(map(int,input().split())) + a.pop(0) + x.extend(a) + +for j in range(1,m+1): + if x.count(j) == n: + c += 1 + +print(c) + +" +p03672,s189931003,Accepted,"s = list(input()) +ll = len(s) +ans = 0 +for i in range(len(s)): + s = s[0: len(s)-1] + if len(s)%2 == 0: + r = s[0:len(s)//2] + l = s[len(s)//2:] + if r == l: + ans = i + 1 + break +print(ll-ans)" +p02613,s747450075,Wrong Answer,"N = int(input()) +a, w, t, r = 0, 0, 0, 0 +for i in range(N): + S = input() + if S == 'AC': + a += 1 + elif S == 'WA': + w += 1 + elif S == 'TLE': + t += 1 + else: + r += 1 +print('AC * ' + str(a)) +print('WA * ' + str(w)) +print('SLE * ' + str(t)) +print('RE * ' + str(r))" +p02570,s927914489,Wrong Answer,"D,T,S = map(int,input().split()) +if D/S 3199: + tmp += 1 + else: + ans[i//400] = True +print(min(sum(ans),1),sum(ans)+tmp)" +p04020,s056731805,Accepted,"import sys +INF = 10 ** 10 +MOD = 10 ** 9 + 7 +from functools import lru_cache +sys.setrecursionlimit(100000000) + +def main(): + n = int(input()) + a = [int(input()) for _ in range(n)] + ans = 0 + for i in range(n): + ans += a[i]//2 + if i != n - 1: + if a[i]%2 == 1 and a[i + 1] > 0: + ans += 1 + a[i + 1] -= 1 + + print(ans) +if __name__ =='__main__': + main() " +p02971,s627883751,Accepted,"n = int(input()) +a = [int(input()) for _ in range(n)] +a_sort = sorted(a,reverse=True) +m1 = a_sort[0] +m2 = a_sort[1] +for i in range(n): + if a[i] == m1: + print(m2) + else: + print(m1)" +p03219,s113144045,Accepted,"x, y = map(int, input().split()) +print(x + y // 2)" +p02911,s442727003,Accepted,"import sys +N,K,Q = map(int,input().split()) +if K > Q: + for i in range(N): + print('Yes') + sys.exit(0) +else: + res = dict() + for i in range(N+1): + res[i] = 0 + for i in range(Q): + answ = int(input()) + if answ not in res: + res[answ] = 0 + res[answ] += 1 +res2 = [answ[0] for answ in res.items() if answ[1] >= (Q-K+1)] +for i in res2: + res[i] = -1 +for i in range(1,N+1): + if (res[i] == -1): + print('Yes') + else: + print('No')" +p03286,s915670854,Wrong Answer,"n=int(input()) +if n==0: + print(0) + exit() +ans='' +for i in range(30): + if n%(2**(i+1))!=0: + n-=(-2)**i + ans='1'+ans + else: + ans='0'+ans + if n==0: + break +if ans[0]!='0': + print(ans) +else: + print(ans[1:])" +p02922,s224931544,Wrong Answer,"a,b = list(map(int,input().split())) +if ab: + print(b) +elif a ==b: + print(b//a)" +p03434,s843259492,Wrong Answer,"def main(): + target_num = input() + target_list = input().split() + + target_list.sort(reverse=True) + + result_a = 0 + result_b = 0 + a_flg = True + for target in target_list: + if a_flg: + result_a += int(target) + a_flg = False + else: + result_b += int(target) + a_flg = True + + print(result_a - result_b) + + +if __name__ == '__main__': + main() +" +p02911,s360973107,Wrong Answer,"N,K,Q = map(int,input().split()) + +correct = [0]*N + +for i in range(Q): + winner = int(input()) - 1 + correct[winner] += 1 + +print(correct) + +for i in range(N): + score = K - (Q-correct[i]) + if score <= 0: + print(""No"") + else: + print(""Yes"")" +p02681,s676018823,Accepted,"s = input() +t = input() +for i in range(len(s)): + if s[i] != t[i]: + print(""No"") + exit() +print(""Yes"")" +p02707,s360768118,Wrong Answer,"n = int(input()) +jyoushis = list(map(int, input().split())) + +nums = 1 +cnt = 0 +top = 1 +for jyoushi in jyoushis: + if top == jyoushi: + cnt+=1 + else: + print(cnt) + top = jyoushi + cnt = 1 + nums+=1 +print(cnt) +if nums < n: + sabun = n - nums + for i in range(sabun): + print(0)" +p03241,s726090833,Accepted,"import sys +input = sys.stdin.readline +N, M = map(int, input().split()) + +def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + + # divisors.sort() + return divisors + +res = 0 +div = make_divisors(M) +for x in div: + if M // x >= N: res = max(res, x) +print(res)" +p02831,s028556953,Accepted,"import fractions +a, b = map(int, input().split()) +print(int(a*b/fractions.gcd(a,b)))" +p02629,s863845777,Accepted,"from collections import defaultdict as dd +from collections import deque +import bisect +import heapq + +def ri(): + return int(input()) + +def rl(): + return list(map(int, input().split())) + + +def solve(): + n = ri() + n -= 1 + out = """" + while n >= 0: + n, r = divmod(n, 26) + n -= 1 + out = chr(ord('a') + r) + out + print (out) + + + + + + +mode = 's' + +if mode == 'T': + t = ri() + for i in range(t): + solve() +else: + solve() +" +p02711,s059589081,Accepted,"N = input() + +if ""7"" in N: + print(""Yes"") +else: + print(""No"") +" +p03328,s214728436,Wrong Answer,"A, B = map(int, input().split()) + +print((B - A )*( B - A +1)/2 - B )" +p02629,s219282339,Wrong Answer,"ans = [] +n = int(input()) +while(n!=0): + x = n % 26 + n //= 26 + ans.append(chr(97+x-1)) + +ans.reverse() +print(''.join(ans))" +p03803,s777916552,Wrong Answer,"a,b=map(int,input().split()) +if a==1 and b!= 1: + a += 13 + if a>b: + print('Alice') + elif b>a: + print('Bob') + else: + print('Draw') +elif b==1 and a!= 1: + a += 13 + if a>b: + print('Alice') + elif b>a: + print('Bob') + else: + print('Draw') +elif a==1 and b== 1: + print('Draw') +else: + if a>b: + print('Alice') + elif b>a: + print('Bob') + else: + print('Draw')" +p02694,s892720452,Wrong Answer,"import math +X=int(input()) + +print(1+math.floor((math.log(X+1, 10)-2)/math.log(1.01, 10))) + +" +p03951,s955433823,Accepted,"def resolve(): + ''' + code here + ''' + N = int(input()) + s = input() + t = input() + + cnt = 0 + for i in range(N): + if i == 0: + if s[-1] == t[0]: + cnt = 1 + else: + if s[-1* (i+1):] == t[:(i+1)]: + cnt = i + 1 + + print(2*N - cnt) + +if __name__ == ""__main__"": + resolve() +" +p03162,s413832876,Accepted,"n = int(input()) +li = [] +for _ in range(n): + li.append([int(i) for i in input().split()]) +dp = [[-1,-1,-1] for x in range(n)] +for i in range(3): + dp[0][i] = li[0][i] + +for i in range(1,n): + for j in range(3): + dp[i][j] = max(dp[i-1][(j+1)%3]+li[i][j],dp[i-1][(j+2)%3]+li[i][j]) + +print(max(dp[n-1]))" +p03067,s669720147,Accepted,"a,b,c=map(int,input().split()) +if a<=b: + if a <= c and c <= b: + print(""Yes"") + else: + print(""No"") +elif b < a: + if b <= c and c <= a: + print(""Yes"") + else: + print(""No"")" +p03632,s280291431,Wrong Answer,"A,B,C,D=list(map(int, input().split())) +ma=max(A,B) +mi=min(C,D) +print(mi-ma)" +p03720,s231754816,Wrong Answer,"import numpy as np +N, M = map(int, input().split()) +c = [] +for _ in range(M): + a, b= map(int, input().split()) + c.append(a) + c.append(b) + +C = np.zeros((N,1),dtype = 'int') +for i in range(len(C)): + C[i,0] = c.count(i+1) +print(C)" +p02970,s000185955,Accepted," +n,d=map(int,input().split()) + +print(-(-n//(2*d+1)))" +p02761,s668718490,Accepted,"N, M = map(int,input().split()) +list1 = [tuple(map(int,input().split())) for _ in range(M)] +list2 = [None for _ in range(N)] +imp = False +for nums in list1: + s, c= nums[0]-1, nums[1] + if list2[s] == c or list2[s] == None: + list2[s] = c + else: + imp = True +if list2[0] == None: + if N ==1: + list2[0] = 0 + else: + list2[0] = 1 + +if (list2[0] == 0 and N != 1) or imp: + print(-1) +else: + for s in list2: + if s == None: + s = 0 + print(""{}"".format(s),end='') + " +p03672,s710699766,Accepted,"s=input() +k=len(s) +for i in range(1,k+1): + s=s[0:-1] + if len(s)%2==0 and s[0:len(s)//2]==s[len(s)//2::]: + print(len(s)) + exit()" +p02678,s141382910,Wrong Answer,"n, m = map(int, input().split()) + +graph = [[] for _ in range(n+1)] + +for i in range(m): + a, b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +# bfs +milestone = [0] * (n+1) +q = [] +q.append(1) +while len(q) != 0: + for i in graph[q[0]]: + if milestone[i] == 0: + milestone[i] = q[0] + q.append(i) + q.pop(0) + +for i in range(2, n+1): + print(milestone[i])" +p03261,s897732777,Accepted,"n=int(input()) +l=[input() for i in range(n)] +if len(set(l))!=n:print(""No"");exit() +h=l[0][0] +for i in l: + if h==i[0]:h=i[-1] + else:print(""No"");exit() +print(""Yes"")" +p03243,s086388366,Wrong Answer,print((int(input())//111+1)*111) +p03324,s832086824,Accepted,"D, N = map(int, input().split()) +ans = 100 ** D * N +if N == 100: + ans += 100 ** D +print(ans)" +p03067,s523974107,Wrong Answer,"a,b,c = map(int, input().split()) + +if a <= c <= b: + print('Yes') +else: + print('No')" +p02681,s620794344,Wrong Answer,"def solve(): + s = input() + t = input() + a = len(s) + b = len(t) + if b > a +1: + print(""NO"") + elif t > s: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + solve() +" +p03386,s867609061,Wrong Answer,"a, b, k = map(int, input().split()) +if k > b-a : + k = b-a + +for i in range(a, a+k): + print(i) + +for i in range(b-k+1 if b-k+1 > a+k else a+k, b+1): + print(i)" +p02773,s037030880,Wrong Answer,"# coding: utf-8 +# Your code here! + +import collections + +n = int(input()) +c = collections.Counter([input() for i in range(n)]) +m = max(c.values()) +k = list(c.keys()) +v = list(c.values()) +for i in range(len(c)): + if v[i] == m: + print(k[i])" +p03351,s240606234,Accepted,"a, b, c, d= map(int,input().rstrip().split()) +if abs(a-c)<=d: + print('Yes') +elif abs(a-b)<=d and abs(b-c)<=d: + print('Yes') +else: + print('No')" +p02747,s332246856,Wrong Answer,"s = list(input()) +c = 0 +for i in range(len(s)-1): + if s[i] == ""h"" and s[i+1] == ""i"": + c += 1 +if c >= 1: + print(""Yes"") +else: + print(""No"")" +p02577,s879943694,Accepted,"n=int(input()) +if(n%9==0): + print(""Yes"") +else: + print(""No"")" +p02639,s951212816,Accepted,"# coding: utf-8 +# Your code here! +line = list(map(int,input().split())) +a=line.index(0) +print(a+1)" +p02622,s684274322,Accepted,"""""""everything has a cost!"""""" + +from math import * +import random, functools, collections, sys + +__author__ = 'p7x' + + +# sys.stdin = open('in.txt', 'r') +# sys.stdout = open('out.txt', 'w') +# sys.stderr = open('err.txt', 'w') + + +if __name__ == '__main__': + s = input() + t = input() + cnt = 0 + for i in range(len(s)): + if (s[i] != t[i]): cnt += 1 + print(cnt) +" +p03814,s455902790,Wrong Answer,"str=input() +ans=[] +head,end=0,0 + +for i,val in enumerate(str): + if val=='A': + head=i + ans.append(val) + continue + elif val is not 'Z': + ans.append(val) + end=i + continue + elif val is 'Z': + break +answer= ''.join(ans) +print(answer[head:end+1])" +p03038,s419538410,Accepted,"from heapq import heappush, heappop + +n,m = map(int,input().split()) +heap = [] + +for i in map(int,input().split()): + heappush(heap,i) + +bc = [list(map(int, input().split())) for _ in range(m)] +bc.sort(key = lambda x: -x[1]) + +for b,c in bc: + for j in range(b): + a = heappop(heap) + if a < c: + heappush(heap,c) + + else: + heappush(heap, a) + break + +print(sum(heap)) + " +p03329,s026613018,Accepted,"import numpy as np +N=int(input()) +six=[1] +nine=[] +for i in range(1,N): + six.append(6**i) + nine.append(9**i) + if 6**i>N: + break +six=np.array(six) +nine=np.array(nine) +L=np.concatenate([six,nine]) +now=N +count=0 +dp=np.ones(N+L.max()+1)*np.inf +dp[1]=1 +dp[0]=0 +#dp[i+1] iをちょうど引き出すのに必要な最小回数 +for i in range(1,N): + dp[i+1]=(dp[i-L+1]+1).min() + + +print(int(dp[N])) +#print(len(L))" +p03011,s481518766,Wrong Answer,"a,b,c=map(int,input().split()) +print(a+b+c-min(a,b,c))" +p03127,s153561108,Accepted,"from fractions import gcd +n=int(input()) +a=list(map(int,input().split())) +g=a[0] +for i in range(1,n): + g=gcd(g,a[i]) +print(g)" +p03061,s264306128,Accepted,"from fractions import gcd +from collections import deque +n = int(input()) +a = list(map(int, input().split())) +l = [0] +r = deque([0]) +g = [] +for i in range(n): + l.append(gcd(l[i], a[i])) + r.appendleft(gcd(r[-(i + 1)], a[-(i + 1)])) +r = list(r) + +for i in range(n): + g.append(gcd(l[i], r[i + 1])) +print(max(g))" +p03324,s100927134,Accepted,"D,N = map(int,input().split()) +#%% +ans = 0 +cur = 0 +for i in range(1,(100**D)*N*10): + a = i + t = 0 + while a%100==0 and a>0: + a//=100 + t+=1 + if t==D: + cur += 1 + if cur == N: + ans = i + break +print(ans) + + " +p03309,s697982265,Wrong Answer,"from functools import lru_cache +import numpy as np + +N = int(input()) +A = np.array(list(map(int, input().split(' ')))) +i = np.arange(1, N + 1) + +right = N * max(A) +left = -1 * right + + +@lru_cache(maxsize=None) +def cost(b): + return np.sum(np.abs(A - (i + b))) + + +while True: + mid = (left + right) // 2 + c_left = cost(left) + c_right = cost(right) + if left == mid or right == mid: + print(min(c_left, c_right)) + break + elif c_left < c_right: + right = mid + else: + left = mid +" +p03779,s068413803,Accepted,"X = int(input()) + +for i in range(X+1): + if (i * (i+1))/2 >= X: + print(i) + break" +p02866,s809165182,Accepted,"def main(): + from collections import Counter + M=998244353 + n,*d=map(int,open(0).read().split()) + e=Counter(d) + a=1if d[0]<1==e[0]else 0 + for i in range(n):a*=pow(e[i],e[i+1],M) + print(a%M) +main()" +p02615,s375785082,Wrong Answer,"# -*- coding: utf-8 -*- + +N, = map(int, input().split()) +A = list(map(int, input().split())) + +A = sorted(A)[::-1] + +ans = 0 +for i, a in enumerate(A): + if i==0: + ans += a + itr = 2 + else: + ans += a + itr += 1 + if itr >= N: + break + ans += a + itr += 1 + if itr >= N: + break + +print(ans) +" +p03838,s238028132,Wrong Answer,"x, y = map(int, input().split()) + +diff_abs = abs(abs(x) - abs(y)) + +if x >= 0 and y >= 0: + ans = diff_abs +elif x < 0 and y < 0: + ans = diff_abs + 2 +else: + ans = diff_abs + 1 + +print(ans)" +p02792,s716552284,Wrong Answer,"n = int(input()) + +c = [[0 for i in range(10)] for j in range(10)] + +for i in range(n): + if i % 10 == 0: + continue + s = str(i) + a = int(s[0]) + b = int(s[-1]) + + c[a][b] += 1 + +ans = 0 + +for i in range(10): + for j in range(10): + ans += c[i][j] * c[j][i] + +print(ans) + +" +p02601,s349845493,Wrong Answer,"X = list(map(int,input().split())) +A = X[0] +B = X[1] +C = X[2] +K = int(input()) +cnt = 0 +if A > B: + for i in range(K): + B = B*2 + cnt = cnt + 1 + if A < B: + break +print(B) +if B > C: + for j in range(K): + C = C*2 + cnt = cnt + 1 + if B < C: + break +print(C) +print(cnt) +if cnt <= K: + print('Yes') +else: + print('No') +" +p03324,s249117255,Accepted,"def resolve(): + D, N = map(int, input().split()) + if D == 0: + if N == 100: + print(""101"") + else: + print(N) + elif D == 1: + if N == 100: + print(""10100"") + else: + print(100*N) + else: + if N == 100: + print(""1010000"") + else: + print(10000*N) +resolve()" +p02972,s773145785,Accepted,"import copy +n = int(input()) +a = list(map(int, input().split())) +b = [0]*n +for i in range(n, 0, -1): + c = 0 + for j in range(i - 1, n, i): + c += b[j] + if c%2 != a[i - 1]: + b[i - 1] = 1 + +if sum(b) == 0: + print(0) +else: + print(sum(b)) + for i in range(n): + if b[i] == 1: + print(str(i + 1), end="" "")" +p03011,s600998771,Wrong Answer,"p,q,r=map(int,input().split()) +if p+q<=q+r and p+qp+q: + print(r+p)" +p02682,s292467520,Accepted,"A,B,C,K = map(int,input().split()) + +if A+B x: + tmp = (A[i] + A[i+1])-x + ans += tmp + A[i+1] -= tmp +print(ans) +" +p02547,s380510734,Accepted,"N = int(input()) + +isDouble = [] + +for i in range(N): + temp = [int(j) for j in input().split("" "")] + if temp[0] == temp[1]: + isDouble.append(1) + else: + isDouble.append(0) + +cnt = 0 +flg = False + +for i in range(len(isDouble)): + if isDouble[i] == 0: + cnt = 0 + else: + cnt += isDouble[i] + if cnt == 3: + flg = True + break + +if flg: + print(""Yes"") +else: + print(""No"")" +p03107,s467380546,Accepted,"def resolve(): + s = input() + one = 0 + zero = 0 + for i in range(len(s)): + if s[i] ==""0"": + zero += 1 + else: + one += 1 + print(2*min(zero, one)) + +resolve()" +p02790,s189672799,Accepted,"a, b = map(int, input().split()) + +c = min(a, b) +d = max(a, b) +print(str(c) * d) +" +p02615,s674102209,Accepted,"n = int(input()) +li = list(map(int,input().split())) +li.sort(reverse=True) +ans = 0 + +for i in range(n//2): + if i == 0: + ans += li[i] + else: + ans += li[i]*2 + +if n%2 == 1: + ans += li[i+1] + +print(ans) +" +p03103,s677143480,Wrong Answer,"n,m=map(int,input().split()) +drink=[list(map(int,input().split())) for i in range(n)] +#print(drink) + +drink.sort() +#print(drink) +money=0 +number=0 +for i in range(n): + if number+drink[i][0]= b or k <= a: + print(k + 1) +else: + print(a + (k - a + 1) // 2 * (b - a) + (k - a + 1) % 2) +" +p03206,s600063117,Accepted,"d = 25 - (int(input())) +answer = ""Christmas"" + +for i in range(d): + answer = answer + "" "" ""Eve"" + +print(answer)" +p02817,s204429300,Wrong Answer,"s,t=input().split() +print(s+t)" +p02730,s919248288,Accepted,"iss = lambda x:x == x[::-1] +S = input() +N = len(S) +S1 = S[:(N-1)//2] +S2 = S[(N+3)//2-1:] +print(""Yes"" if iss(S) and iss(S1) and iss(S2) else ""No"")" +p02791,s361789667,Accepted,"N = int(input()) +P = list(map(int, input().split())) + +min = P[0] +ans = 1 +for i in range(1, N): + if P[i] <= min: + ans += 1 + min = P[i] + +print(ans)" +p02629,s823019398,Accepted,"n = int(input()) +l = [] +while(n > 0): + n -= 1 + l.append(chr(97+(n%26))) + n = n//26 +for i in l[::-1]: + print(i,end="""") +print("""") +" +p03774,s360248555,Accepted,"N,M = map(int,input().split()) +AB = [tuple(map(int,input().split())) for i in range(N)] +CD = [tuple(map(int,input().split())) for i in range(M)] + +for a,b in AB: + ans = -1 + mind = float('inf') + for i,(c,d) in enumerate(CD): + dist = abs(a-c) + abs(b-d) + if dist < mind: + mind = dist + ans = i+1 + print(ans)" +p03327,s725382104,Wrong Answer,"N = int(input()) +if N < 1000: print(""ABC"" + str(N)) +else: print(""ABD"" + str(N)[1:3] + str((N + 1) % 10)) " +p03494,s663537846,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +K=0 +for i in range(1,N): + for j in A: + if j%(2**i)!=0: + break + else: + K+=1 + continue + break + +print(K)" +p03487,s433851065,Wrong Answer,"import collections +n,cc = raw_input(), collections.Counter(map(int, raw_input().split())) +print sum([(k - cc[k] if k <= cc[k] else cc[k]) for k in cc] or [0])" +p02571,s671946354,Accepted,"s= input() +t = input() + +count = len(t) + +for i in range(len(s) - len(t) + 1): + str_ = s[i:i + len(t)] + temp = 0 + for i in range(len(str_)): + #print(str_[i]) + if str_[i] != t[i]: + temp += 1 + count = min(count, temp) + +print(count)" +p03485,s022085058,Wrong Answer,"a,b = input().split() +a = int(a) +b = int(b) +print (int((a+b) / 2) +1)" +p03160,s052808025,Wrong Answer," + +def solution(h): + n = len(h) + INF = float('inf') + dp = [INF]*n + dp[0] = 0 + for i in range(n): + for j in range(i+1,i+3): + if j < n: + dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) ) + print(*dp) + return dp[n-1] + +N = int(input()) +h = list(map(int,input().split())) +res = solution(h) +print(res) +" +p03761,s024580094,Accepted,"n=int(input()) +s=[input() for _ in range(n)] +s=sorted(s,key=lambda x: len(x)) +for i in range(n): + s[i]=sorted(s[i]) +x=''.join(set(s[0])) +x=sorted(x) +for i in range(len(x)): + tmp=s[0].count(x[i]) + for j in range(1,n): + tmp=min(tmp,s[j].count(x[i])) + print(x[i]*tmp,end="""")" +p03000,s162767560,Wrong Answer,"n, x = map(int, input().split()) +l = list(map(int, input().split())) +result = 0 +res = 0 +for i in l: + res+=1 + result += i + if(result > x): + break + + +print(res)" +p02801,s787290829,Accepted,"C = input() + +alp = ""abcdefghijklmnopqrstuvwxyz"" +alp = list(alp) + +print(alp[alp.index(C)+1])" +p02744,s776651850,Accepted,"n = int(input()) +res = [-1] * n +def do(a, b): + #print(""do"",a,b) + if a >= n: + return + res[a] = b + if a == n - 1: + print("""".join(list(map(lambda x: chr(ord(""a"") - 1 + x), res)))) + return + for i in range(1, max(res[0:a+1])+2): + do(a + 1, i) +do(0, 1) +" +p03545,s805269942,Wrong Answer,"#引数としてopを追加 +#opには計算で用いた演算子が文字列として格納されている +def func(i,x,op): + #ベースケース + if i == 4: + if x == 7: return op + else: return """" + + #足す場合 + opP = func(i+1, x + int(S[i]), op+""+"") + if opP != """": return opP + + #引く場合 + opM = func(i+1, x - int(S[i]), op+""-"") + if opM != """": return opM + + return """"" +p02833,s625692644,Wrong Answer,"import sys +sys.setrecursionlimit(20000000) + +def fx(X, n): + if (int(X/n)): + return fx(int(X/n), n)+int(X/n) + return 0 + +N=int(input()) +if N%2==1: + print(0) +else: + print(fx(N//2,5))" +p02935,s960823620,Accepted,"ii = lambda:int(input()) +mi = lambda:list(map(int,input().split())) +mix = lambda x:list(li() for _ in range(x)) +iix = lambda x:list(int(input()) for _ in range(x)) +########## +def main(n,v): + v = sorted(v) + res = (v[0]+v[1])/2 + for i in range(2, n): + res = (res + v[i]) / 2 + print(res) + +n = ii() +v = mi() +main(n,v)" +p03854,s216998796,Accepted,"import re +print(""YES"" if re.match(""^(dream|dreamer|erase|eraser)+$"",input()) else ""NO"")" +p02818,s544244717,Accepted,"# import math +# import bisect +# import heapq +# from copy import deepcopy +# from collections import deque +# from collections import Counter +# from itertools import accumulate +# from itertools import permutations +# import numpy as np + + +a,b,k = map(int, input().split()) +# n = int(input()) +# p = list(map(int, input().split())) + +if a < k and b > k-a: + print(0,a+b-k) +elif a >= k: + print(a-k,b) +else: print(0,0)" +p02791,s687362156,Wrong Answer,"n = int(input()) +s = input().split() + +min_s = s[0] +count = 0 + +for num in s: + if min_s >= num: + count += 1 + if min_s > num: + min_s = num + +print(count)" +p03386,s761073838,Accepted,"a, b, k = map(int, input().split()) +ll = [] +for i in range(k): + if a+i <= b: + ll.append(a+i) +for j in range(k): + if not b-k+j+1 in ll and b-k+j+1>=a: + ll.append(b-k+j+1) +for k in ll: + print(k) +" +p03076,s251271317,Accepted,"import math + +dishes=[int(input()) for _ in range(5)] +#print(dishes) + +remain=[val%10 for val in dishes if val%10!=0] +up=[math.ceil(val/10)*10 for val in dishes] +#print(remain) +#print(up) +if not remain: + print(sum(up)) +else: + print(sum(up)-10+min(remain)) +" +p02761,s710221496,Wrong Answer,"n, m = map(int, input().split()) + +l = [-1] * n + +for _ in range(m): + s, c = map(int, input().split()) + s -= 1 + + if l[s] == -1: + l[s] = c + + elif l[s] != c: + print(-1) + exit() + +if n > 1 and l[0] == 0: + print(-1) + exit() + +if l[0] == -1: + l[0] = 1 + +for i in range(n): + if l[i] == -1: + l[i] = 0 + +print(*l, sep='')" +p02642,s362448102,Accepted,"from collections import Counter, defaultdict + +N = int(input()) +A = [int(x) for x in input().split()] +A.sort() + +C = Counter(A) +D = defaultdict(bool) +for key in C.keys(): + D[key] = True + +B = [True] * N +ans = 0 +for i in range(N): + if not D[A[i]]: continue + if C[A[i]] > 1: + D[A[i]] = False + + for a in range(2 * A[i], A[-1] + 1, A[i]): + D[a] = False + +ans = 0 +for key in D: + if D[key]: + ans += 1 +print(ans) +" +p02753,s810352780,Accepted,"# coding: utf-8 +S = input() +if (S[0] == S[1]) & (S[1] == S[2]): + print('No') +else: + print('Yes')" +p03251,s135037880,Wrong Answer,"N,M,X,Y = map(int,input().split()) +x = list(map(int,input().split())) +y = list(map(int,input().split())) + +if min(y) < max(x): + print (""War"") +else: + if X < max(x) < Y or X < min(y) <= Y: + print (""No War"") + else: + print (""War"") +" +p03360,s934841233,Wrong Answer,"a, b, c = map(int, input().split()) +k = int(input()) +list = [a, b, c] +max = max(list) +if a == max: + print(b+c+(a*2*k)) +elif b == max: + print(a+c+(b*2*k)) +else: + print(a+b+(c*2*k))" +p03760,s818161280,Accepted,"a,b=input(),input();n=[i+j for i,j in zip(a,b)] +print(*[n,n+[a[-1]]][len(a)-len(b)],sep='')" +p02618,s746429791,Accepted,"D=int(input()) +for i in range(D): + print((25-i)%26+1)" +p03624,s782390353,Accepted,"s = input() +x = ""abcdefghijklmnopqrstuvwxyz"" +ans = ""None"" +for i in x: + if i in s: + pass + else: + ans = i + break +print(ans)" +p03037,s162693694,Accepted,"N, M = map(int, input().split()) +keys = [list(map(int, input().split())) for _ in range(M)] + +left = 1 +right = N +for key in keys: + if left < key[0]: + left = key[0] + if key[1] < right: + right = key[1] +if right < left: + print(0) +else: + print(right - left + 1)" +p02780,s662374583,Accepted,"N, K = map(int, input().split()) +*P, = map(int, input().split()) +expectations = [(p + 1) / 2 for p in P] +ans = 0 +S = sum(expectations[:K]) +for i in range(N - K): + ans = max(ans, S) + S = S - expectations[i] + expectations[i + K] +ans = max(ans, S) +print(ans)" +p02613,s207857312,Accepted,"N=int(input()) +L=[] +for i in range(N): + L.append(input()) +C=[] +W=['AC', 'WA', 'TLE', 'RE' ] +Q=[0,0,0,0] +for i in range(N): + for j in range(4): + if L[i]==W[j]: + Q[j]=Q[j]+1 + break +print('AC x '+str(Q[0])) +print('WA x '+str(Q[1])) +print('TLE x '+str(Q[2])) +print('RE x '+str(Q[3]))" +p03943,s995710386,Accepted,"A,B,C = list(map(int,input().split())) +if A+B==C or A+C==B or B+C==A: + print(""Yes"") +else: + print(""No"")" +p03136,s569674651,Wrong Answer,"n = int(input()) +l = input().split("" "") +for i in range(len(l)): + l[i] = int(l[i]) + +l.sort() +sum = 0 +for i in range(1, n): + sum += l[i] + +if sum > l[0]: + print(""Yes"") +else: + print(""No"") +" +p03723,s625091782,Accepted,"A, B, C = map(int, input().split()) +S = A+B+C + +k = 0 +flag = 0 +while k<100: + if A%2==1 or B%2==1 or C%2==1 or min([A,B,C])<1: + flag = 1 + break + An = (B + C)//2 + Bn = (A + C)//2 + Cn = (B + A)//2 + A = An + B = Bn + C = Cn + k += 1 + +if not flag: + k = -1 + +print(k)" +p02847,s686364902,Accepted,"import sys +row = sys.stdin.readline +def read_string(row): + return row().rstrip() + +S = read_string(row) +dic = {""SUN"": 7, + ""SAT"":1, + ""FRI"":2, + ""THU"":3, + ""WED"":4, + ""TUE"":5, + ""MON"":6} +print(dic[S])" +p02725,s233011141,Accepted,"K,N = map(int, input().split()) +As = list(map(int, input().split())) +Bs = As + [K+As[0]] +diff = [abs(Bs[i+1]-Bs[i]) for i in range(N)] +# print(diff) +mx = 0 +print(sum(diff) - max(diff))" +p02726,s492826743,Wrong Answer,"N, X, Y = map(int, input().split()) +ans = [0]*(N-1) + +def cal_dis(i, j): + return min(j-i, abs(i-X)+abs(j-Y)+1) + +for i in range(1, N+1): + for j in range(i+1, N+1): + k = cal_dis(i, j) + ans[k] += 1 + +print('\n'.join(map(str, ans))) + + +" +p03637,s469551826,Accepted,"n = int(input()) +a = list(map(int, input().split())) +o = 0 +t = 0 +f = 0 +for i in a: + if i % 4 == 0: + f += 1 + elif i % 2 == 0: + t += 1 + else: + o += 1 +if t > 0: + print(""Yes"" if f >= o else ""No"") +else: + print(""Yes"" if f >= o - 1 else ""No"")" +p03693,s265074204,Accepted,"r,g,b, = map(str, raw_input().split()) +s = int(r+g+b) +print 'YES' if s % 4 == 0 else 'NO' +" +p02971,s662100266,Accepted,"N = int(input()) +A = [] +for _ in range(N): + A.append(int(input())) +Af = sorted(A, reverse=True) +for a in A: + if a == Af[0]: + print(Af[1]) + else: + print(Af[0])" +p02594,s399356626,Accepted,"temp=int(input()) +if(temp>=30): + print(""Yes"") +else: + print(""No"")" +p03761,s734434105,Wrong Answer,"import string +from collections import Counter + +ans = """" +dic = {} + +for a in string.ascii_lowercase: + dic[a] = 51 + +N = int(input()) +for _ in range(N): + S = list(input()) + S = Counter(S) + + for l, c in dic.items(): + if dic[l] > S[l]: + dic[l] = S[l] + +for k, v in dic.items(): + if v != 51: + ans += k * v + +print(ans)" +p03605,s127540935,Accepted,"n = int(input()) + +m = n%10 +l = n // 10 + +if m==9 or l==9: + print(""Yes"") +else: + print(""No"")" +p02831,s771958791,Wrong Answer,"a,b=map(int,input().split()) +flag = True +res = 0 +if a % b == 0 or b % a ==0: + flag = False +if flag: + res = a*b +else: + res = max(a,b) +print(res)" +p03309,s583563069,Accepted,"n = int(input()) +A = list(map(int, input().split())) +B = sorted([a-i-1 for i, a in enumerate(A)]) +m = B[n//2] +print(sum(abs(b-m) for b in B))" +p02818,s159786761,Wrong Answer,"# coding: utf-8 + + +def main(): + + takahashi, aoki, action_count = map(int, input().split(' ')) + + if action_count < takahashi: + takahashi = action_count - takahashi + aoki = aoki + elif action_count <= (takahashi + aoki): + aoki -= (action_count - takahashi) + takahashi = 0 + else: + takahashi = 0 + aoki = 0 + + print(takahashi, aoki) + + return 0 + + +if __name__ == '__main__': + main() +" +p03778,s484301328,Wrong Answer,"W,a,b=map(int, input().split()) +if a c: + plus += (math.floor(j/c)) + +print(len(a) + plus)" +p02775,s702238131,Wrong Answer,"n = int(input()) +ans = 100000000 +for i in range(n,n+10000): + cnt = 0 + s = str(i) + for j in range(len(s)): + cnt += int(s[j]) + s2 = str(i-n) + for j in range(len(s2)): + cnt += int(s2[j]) + if ans > cnt: + ans = cnt + #print(cnt) +print(ans)" +p02676,s381559976,Accepted,"k = int(input()) +s = input() +if len(s)<=k: + print(s) +else: + print(s[:k]+'...')" +p03644,s774227565,Accepted,"N=int(input()) + +X=[] + + +for i in range(1,N+1): + count=0 + while i%2==0: + i//=2 + count+=1 + X.append(count) + +print(X.index(max(X))+1) +" +p02689,s628158284,Accepted,"import sys +stdin = sys.stdin +sys.setrecursionlimit(10 ** 7) + +def LI(): return list(map(int, stdin.readline().split())) +def LS(): return list(stdin.readline()) + +n,m = LI() +h = LI() +high = [0]*n + +for i in range(m): + a, b = LI() + if h[a-1]>h[b-1]: + high[b-1] += 1 + elif h[a-1]==h[b-1]: + high[a-1] += 1 + high[b-1] += 1 + else: + high[a-1] += 1 +print(high.count(0))" +p03479,s446964540,Accepted,"X, Y = map(int, input().split()) + +cnt = 0 +while X <= Y: + cnt += 1 + X *= 2 +print(cnt)" +p03106,s991133156,Accepted,"#x=int(input()) +a,b,k=map(int,input().split()) +#xl=list(map(int,input().split())) +#l=[list(map(int,input().split())) for i in range(n)] + +ansl=[] + +for i in range(1,min(a,b)+1): + if a%i==0 and b%i==0: + ansl.append(i) + +ansl.sort(reverse=True) + +print(ansl[k-1]) + +" +p03486,s799357371,Wrong Answer,"s = sorted(input()) +t = sorted(input(), reverse=True) + +ans = ""Yes"" +if s == t: + ans = ""No"" +else: + for i in range(len(s)): + if i == len(t): + break + elif s[i] == t[i]: + continue + elif s[i] < t[i]: + break + else: + ans = ""No"" + break + +print(ans)" +p02792,s171503427,Accepted,"N = int(input()) + +cnt = [[0]*10 for i in range(10)] +# 先頭がi, 末尾がjであるような数の個数を計算 +for n in range(1, N+1): + n = str(n) + i = int(n[0]) + j = int(n[-1]) + cnt[i][j] += 1 + +ans = 0 +for i in range(10): + for j in range(10): + ans += cnt[i][j]*cnt[j][i] + +print(ans)" +p02973,s741514468,Accepted,"import heapq +from bisect import bisect_left, bisect_right + +n = int(input()) +a = int(input()) +q = [a*(-1)] +# ans = 1 + +for _ in range(n-1): + a = int(input()) + # bより大きい最小要素のindex/value + ind = bisect_right(q, a*(-1)) + ind = ind if 0 <= ind < len(q) else None + if ind is None: + q.append(a*(-1)) + else: + q[ind] = a*(-1) + +print(len(q))" +p02682,s296738446,Accepted,"a,b,c,k=map(int,input().split()) +if a>=k: + print(k) +elif b>=k-a: + print(a) +else: + print(a-(k-a-b))" +p03438,s383308817,Wrong Answer,"N = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +ans = False +rule1 = sum(a) <= sum(b) +rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a) +rule3 = sum([bi - ai for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a) +if rule1 and rule2 and rule3: + ans = True + +text = ""Yes"" if ans else ""No"" +print(text) +" +p03434,s776767324,Accepted,"n = int(input()) +a = sorted(list(map(int, input().split())),reverse = True) +Alice = 0 +Bob = 0 +count = 0 + +while True: + Alice += a[count] + count += 1 + if count == n: + print(Alice - Bob) + exit() + Bob += a[count] + count += 1 + if count == n: + print(Alice - Bob) + exit()" +p02994,s580039332,Accepted,"N, L = (int(x) for x in input().split()) +A = [] +for i in range(N): + A.append(L+i) +s = sum(A) +m = 1000 +ans = 0 +for i in range(N): + t = A.pop(i) + if abs(sum(A)-s) <= m: + m = abs(sum(A)-s) + ans = sum(A) + A.insert(i,t) +print(ans)" +p02843,s406959778,Accepted,"import itertools +a = [0, 1, 2, 3, 4, 5] +x = int(input()) +n = x // 100 +m = x % 100 +for c in itertools.combinations_with_replacement(a, n): + if sum(c) == m: + print(1) + break +else: + print(0)" +p03345,s136226183,Accepted,"a,b,c,k = map(int,input().split()) +if k%2 == 0 and a-b <= 10**18: + print(a-b) +elif k%2 != 0 and a-b <= 10**18: + print(b-a) +else: + print(""Unfair"")" +p02866,s626121941,Accepted,"N=int(input()) +*D,=map(int,input().split()) +M=max(D) +from collections import* +C=Counter(D) + +ans=1 +now=C[1] +for i in range(2,M+1): + ans*=pow(now,C[i],998244353) + ans%=998244353 + now=C[i] + +if D[0]!=0: + ans=0 +if 0 in D[1:]: + ans=0 +print(ans)" +p03067,s688396129,Accepted,"A,B,C=map(int,input().split()) + +if A b: + a, b = b, a +print(max(0, b - (a + W)))" +p03106,s170085282,Accepted,"a, b, k = map(int, input().split()) +t = 100 +cnt = 0 +while t > 0: + if a%t == 0 and b%t == 0: + cnt+=1 + if cnt == k: break + t-=1 +print(t)" +p03565,s638508685,Accepted,"s=input() +t=input() +ans=""UNRESTORABLE"" +for i in range(len(s)-len(t),-1,-1): + ss=s[i:i+len(t)] + flag=0 + for j in range(len(t)): + if ss[j]==""?"": + ss=ss[0:j]+t[j]+ss[j+1:] + if ss[j]!=t[j]: + flag=1 + break + if flag==0: + ans=s[0:i].replace(""?"",""a"")+ss+s[i+len(t):].replace(""?"",""a"") + break +print(ans) +" +p03478,s120806863,Accepted,"input_num = input().split() +N = int(input_num[0]) +A = int(input_num[1]) +B = int(input_num[2]) + +result = 0 + +for num in range(1, N+1): + str_num = str(num) + cur_sum = 0 + for i in range(len(str_num)): + cur_sum += int(str_num[i]) + if cur_sum >= A and cur_sum <= B: + result += num + +print(result)" +p02548,s844103530,Accepted,"N = int(input()) +ans = 0 +for i in range(1, N): + ans += (N-1) // i +print(ans)" +p02701,s982423675,Accepted,"n=int(input()) +s=[input() for i in range(n)] +a=set() +for i in range(n): + a.add(s.pop()) +print(len(a)) +" +p03013,s611490511,Accepted,"N,M = map(int, input().split()) +a_list = [int(input()) for _ in range(M)] + +MOD = 10**9+7 + +dp = [0] * (10**5 + 3) +dp[1] = 0 +dp[2] = 1 +dp[3] = 2 +for i in range(3, len(dp)): + dp[i] = dp[i-1] + dp[i-2] + +res = 1 +bef = -1 +if M > 0: + for a in a_list: + res *= dp[a-bef] + res %= MOD + bef = a +res *= dp[N-bef+1] +res %= MOD + +print(res)" +p03338,s897184247,Accepted,"n = int(input()) +s = input() + +num = 0 +for i in range(n-1): + x = s[:i+1] + y = s[i+1:] + + setx = {i for i in x} + sety = {i for i in y} + common = setx & sety + + num = max(num, len(common)) + +print(num)" +p02582,s686682069,Accepted,"s = input() +for i in range(5): + if ""R""*i not in s: + print(i-1) + break" +p02835,s047835450,Wrong Answer,"a, b, c = [ int(i) for i in input().split("" "")] +sum = a + b + c +print(sum) +if sum >= 22: + print(""bust"") +else: + print(""win"")" +p02923,s173795699,Accepted,"n=int(input()) +h=list(map(int,input().split())) +cnt=0 +a=0 +for i in range(n-1): + if h[i]>=h[i+1]: + a+=1 + else: + a=0 + cnt=max(cnt,a) +print(cnt)" +p03377,s413782694,Wrong Answer,"a, b, x =map(int, input().split()) + +if 0 <= x-a and x-a <= b: + print('Yes') +else: + print('No') +" +p03012,s654348653,Accepted,"n = int(input()) +w = list(map(int, input().split())) + +ans = float('inf') +for i in range(n-1): + weight = abs(sum(w[:i+1]) - sum(w[i+1:])) + ans = min(ans, weight) + +print(ans) +" +p03986,s482171656,Accepted,"s = input() +count = 0 +sc = 0 +for c in s: + if c=='S': + sc+=1 + else: + if sc > 0: + sc -= 1 + count += 1 + +print(len(s) - count*2)" +p03485,s878090431,Accepted,"import math +a, b = map(int, input().split()) +print(math.ceil((a + b) / 2)) +" +p03221,s147189206,Wrong Answer,"import sys + +input = sys.stdin.readline +N,M = map(int,input().split()) +PY = {n: [] for n in range(N + 1)} +for i in range(M): + p,y = map(int,input().split()) + PY[p].append((y, i)) +print(PY) +for p,y in PY.items(): + y.sort() + for j, (z, i) in enumerate(y): + top_number = '0'*(6-len(str(p)))+str(p) + under_number = '0'*(6-len((str(j+1))))+str(j+1) + print(top_number + under_number)" +p03627,s440416678,Accepted,"import sys +import heapq +import math +import fractions +import bisect +import itertools +from collections import Counter +from collections import deque +from operator import itemgetter +def input(): return sys.stdin.readline().strip() +def mp(): return map(int,input().split()) +def lmp(): return list(map(int,input().split())) + +n=int(input()) +a=sorted(lmp(),reverse=True) +a.append(0) +i=0 +ans=[] +while i MAX: + print(-1) + exit(0) + + #exit(0) +print(ans)" +p02959,s100656008,Accepted,"n=int(input()) +a=[int(i) for i in input().split()] +b=[int(i) for i in input().split()] +first=a.pop(0) +ans=0 +for i in range(n): + if first+a[i]-b[i] <= 0: + ans+=first+a[i] + first=0 + elif first-b[i]>=0: + ans+=b[i] + first=a[i] + else: + ans+=b[i] + first=a[i]-(b[i]-first) +print(ans) " +p02570,s428726997,Wrong Answer,"import math +a,b,c=[int(i) for i in input().split()] +e=math.floor(a/c) +if(e<=b): + print('Yes') +else: + print('No')" +p02606,s224436391,Accepted,"l,r,d=map(int,input().split()) +if l%d==0 and r%d==0: + print(r//d-l//d+1) +else: + print(r//d-l//d)" +p03836,s038180152,Wrong Answer,"sx,sy,tx,ty = map(int,input().split()) + +dx=tx-sx +dy=ty-sy + +s=""U""*dy+""R""*dx+""D""*dy+""L""*(dx+1)+""U""*(dy+1)+""R""*(dx+1)+""D""+""R""+""D""*(dy+1)+""L""*(dx+1) + +print(s)" +p02743,s246318962,Accepted,"from decimal import Decimal +import math +a, b, c = map(int, input().split()) + +A = Decimal(str(a))**Decimal('0.5') +B = Decimal(str(b))**Decimal('0.5') +C = Decimal(str(c))**Decimal('0.5') +if A + B < C: + print('Yes') +else: + print('No')" +p04012,s975996785,Accepted,"from collections import Counter + + +w = input().strip() +c = Counter(list(w)) + +result = True +for i in c.values(): + if i % 2 == 1: + result = False + break + +if result: + print('Yes') +else: + print('No') + + + + + +" +p02618,s988918722,Accepted,"import random + +d = int(input()) # 365 +c = list(map(int, input().split())) + +# 最低限のポイントを確認? +for i in range(d): + s = list(map(int, input().split())) + print(random.randint(1, 26)) +" +p02862,s662601638,Accepted,"inp=list(map(int,input().split())) +x=inp[0] +y=inp[1] +if (x+y)%3!=0: + print (0) +else: + flag=0 + z=(x+y)//3 + n=x-z + m=y-z + if m<0 or n<0: + print (0) + flag=1 + else: + arr=[1] + v=pow(10,9)+7 + for i in range(1,m+n+1): + arr.append((arr[-1]*i)%v) + a=arr[m+n] + b=(arr[m]*arr[n])%v + print ((a*pow(b,v-2,v))%v)" +p02995,s358780241,Accepted,"from math import * +a,b,c,d = map(int,input().split()) +f =(c*d)//gcd(c,d) +r = f +rock = 2 +compteur= (b//f)-(a//f) +if a%f==0: + compteur +=1 +div1 = ((b//c)-(a//c)) +div2 = ((b//d)-(a//d)) +if a%c == 0: + div1+=1 +if a%d ==0: + div2 +=1 +roger =(div1+div2)-compteur +mm = (b-a)+1 +print(mm-roger) +" +p03077,s019074879,Accepted,"import math +n=int(input()) +l=[int(input()) for i in range(5)] + +mini=min(l) +ans=4+math.ceil(n/mini) +print(ans)" +p03474,s576032608,Accepted,"import re +a, b = input().split() +s = input() + +if re.fullmatch(""\d{%s}-\d{%s}"" % (a, b), s): + print(""Yes"") +else: + print(""No"") +" +p02948,s324557065,Accepted,"import heapq +n,m = map(int,input().split()) +B = [[] for _ in range(m)] +for i in range(n): + a,b = map(int,input().split()) + if 1 <= a <= m: + B[a-1].append(b) +task = [] +heapq.heapify(task) +ans = 0 +for i in range(m): + for t in B[i]: + heapq.heappush(task,-t) + if task: + ans += heapq.heappop(task) +print(-ans) +" +p02730,s004467666,Wrong Answer,"s = input() +n = len(s) +ans = ""No"" + +sa = s[:(n-1)//2] +sb = s[((n+3)//2)-1:] + +if sa == sa[::-1] and sb == sb[::-1]: + ans = ""Yes"" + +print(ans) +" +p03720,s099609980,Accepted,"N, M = map(int, input().split()) +R = [0] * N +for _ in range(M): + a, b = map(int, input().split()) + R[a-1] += 1 + R[b-1] += 1 +for r in R: print(r)" +p03328,s415510903,Wrong Answer,"a, b = map(int, input().split()) +i = 1 +c = 2 +while i <= a: + i += c + c += 1 +print(b-i)" +p03251,s502929463,Wrong Answer,"n, m, x, y = map(int, input().split()) +a, b = [list(map(int, input().split())) for i in range(2)] + +for i in range(x + 1, y + 1): + if all(j < i for j in a) and all(k >= i for k in b): + print(""No War"") +else: + print(""War"")" +p03437,s721847949,Accepted,"x,y=map(int,input().split()) + +if x%y==0: + print(-1) +else: + print(x) +" +p03329,s884382186,Accepted,"def main(): + n = int(input()) + money = sorted([6 ** i for i in range(7)] + [9 ** i for i in range(1, 6)], reverse=True) + dp = [0] + [1000000] * n + for i in range(1, n + 1): + dp[i] = min(dp[i], *[dp[i - j] + 1 for j in money if i - j >= 0]) + print(dp[n]) + +if __name__ == '__main__': + main()" +p03145,s494376756,Wrong Answer,"a,b,c = list(map(int, input().split())) +print((a + b) / 2)" +p03617,s767224440,Wrong Answer,"Q, H, S, D = map(int, input().split()) +N = int(input()) + +A = min(Q*4, H*2, S) +if N % 2 == 0: + print(min(A*N, D*N//2)) +else: + if N == 1: + print(A) + else: + print(min(A*N, D*(N+1)//2, D*(N//2)+A)) +" +p02661,s561420849,Wrong Answer,"n = int(input()) +min_s = [] +max_s = [] +for i in range(n): + a, b = map(int, input().split()) + min_s.append(a) + max_s.append(b) + +min_s.sort() +max_s.sort() +if n % 2 == 0: + min_med = (min_s[n//2-1] + min_s[n//2])/2 + max_med = (max_s[n//2-1] + max_s[n//2])/2 + print(int(max_med-min_med)*2+1) + +else: + min_med = min_s[(n+1)//2-1] + max_med = max_s[(n+1)//2-1] + print(int((max_med-min_med)+1))" +p02947,s022390281,Accepted,"from collections import Counter +import math + +def combinations_count(n, r): + return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) + +n=int(input()) +l=["""".join(sorted(input())) for i in range(n)] +c=Counter(l).most_common() +ans=0 +for i in range(len(c)): + if c[i][1]>=2: + ans+=combinations_count(c[i][1],2) +print(ans)" +p04045,s121366656,Accepted,"n,k = map(int,input().split()) #入力 +a = list(map(int,input().split())) #使用不可の数字 +b = {0,1,2,3,4,5,6,7,8,9}-set(a) #使用可能な数字の集合 +while set([int(i) for i in list(str(n))])-b !=set() : # 使用可能な数字のみでなければ + n += 1 +print(n) +" +p02693,s258849908,Accepted,"import sys + +K = int(input()) +A, B = map(int, input().split()) +ans = 0 +while True: + ans += K + if A <= ans <= B: + print(""OK"") + sys.exit() + elif ans > B: + print(""NG"") + sys.exit() + else: + pass +" +p02677,s377292924,Wrong Answer,"import math +a,b,h,m=map(int,input().split()) + +t=60*h+m + +d=(t%60)*b +e=0.5*(h*60) + +f=abs(d-e) + +if f>=180: + f=f-180 + +theta=math.radians(f) +print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta)))" +p02690,s261725404,Accepted,"X = int(input()) +k = list(range(0,100000)) +k5 = [] +for i in k: + k5.append(i**5) +for j in k5: + if X + j in k5: + print(k[k5.index(X+j)],k[k5.index(j)]) + exit() + elif X - j in k5: + print(k[k5.index(X-j)],-k[k5.index(j)]) + exit()" +p03797,s629321338,Accepted,"N,M = map(int,input().split()) +ans = 0 + +if 2*N >= M: + ans = M//2 +else: + ans += N + C = M-2*N + ans += C//4 + +print(ans)" +p03449,s885178727,Wrong Answer,"def main(): + n = int(input()) + a_lst1 = list(map(int, input().split())) + a_lst2 = list(map(int, input().split())) + candies_lst = [] + + tmp = 1 + while tmp <= 7: + a1_tmp = a_lst1[:tmp] + a2_tmp = a_lst2[tmp-1:] + a1 = sum(a1_tmp) + a2 = sum(a2_tmp) + + tmp += 1 + candies = a1 + a2 + candies_lst.append(candies) + + maximum = max(candies_lst) + print(maximum) + + +if __name__ == '__main__': + main()" +p02641,s320676711,Wrong Answer,"def main(): + X,N = map(int, input().split()) + c=list(map(int, input().split())) + XY = [True]*(101) + + for i in range(len(c)): + XY[c[i]]=False + + ans = 0 + sa = 10000 + + for i in range(1,101): + if XY[i]: + if sa > abs(X-i) : + ans = i + sa = abs(X-i) + print(ans) + + +if __name__ == '__main__': + main()" +p03624,s185446041,Wrong Answer,"S = list(input()) + +S.sort() + +for i in range(len(S)-1): + if ord(S[i+1]) - ord(S[i]) == 0 or ord(S[i+1]) - ord(S[i]) == 1: + pass + else: + res = ord(S[i]) + 1 + print(chr(res)) + exit() + +res = ord(S[-1]) + 1 + +if S[0] == 'a' and S[-1] == 'z': + print('None') +elif S[0] != 'a': + print('a') +else: + print(chr(res)) +" +p03565,s538175958,Accepted,"s,y=(input() for i in range(2)) +ans=""{""*len(s);pa=ans +for i in range(len(s)-len(y)+1): + for j in range(len(y)): + if s[i+j]!='?' and s[i+j]!=y[j]:break + else:ans=min(ans,s[:i].replace(""?"",""a"")+y+s[i+len(y):].replace(""?"",""a"")) +if pa==ans:print(""UNRESTORABLE"") + +else:print(ans) +" +p03067,s097750539,Accepted,"import sys +import copy +import math +import bisect +import pprint +import bisect +from functools import reduce +from copy import deepcopy +from collections import deque + +def lcm(x, y): + return (x * y) // math.gcd(x, y) + +if __name__ == '__main__': + a = [int(i) for i in input().split()] + + if (a[0] < a[1] and a[0] a[1] and a[0]>a[2] and a[2] >a[1]): + print(""Yes"") + else: + print(""No"") +" +p03659,s578911819,Accepted,"n=int(input()) +a=list(map(int,input().split())) +temp=sum(a) +temp1=a[0] +ans=abs(temp-temp1*2) +for i in range(1,n-1): + temp1=temp1+a[i] + ans=min(ans,abs(temp-temp1*2)) +print(ans)" +p03250,s309045577,Accepted,"def main(): + numbers = list(map(int, input().split("" ""))) + numbers.sort(reverse=True) + print(numbers[0] * 10 + numbers[1] + numbers[2]) + + +if __name__ == '__main__': + main()" +p03493,s832059539,Accepted,"s = input() +a = [int(c) for c in s] + +print(sum(a))" +p02772,s506124041,Accepted,"N = int(input()) +a = list(map(int, input().split())) +el = [] +for i in a: + if i % 2 == 0: + el.append(i) + +for i in range(len(el)): + if el[i] % 3 == 0 or el[i] % 5 == 0: + el[i] = True + else: + el[i] = False + +if el.count(False): + print(""DENIED"") +else: + print(""APPROVED"") +" +p04034,s213590679,Wrong Answer,"n,m=map(int,input().split()) +xy=[list(map(int,input().split())) for i in range(m)] +num=[1]*n +red=[False]*n +red[1]=True +for i in range(m): + x,y=xy[i] + if red[x-1]: + red[y-1]=True + num[x-1]=num[x-1]-1 + num[y-1]=num[y-1]+1 + if num[x-1]==0: + red[x-1]=False +print(red.count(True))" +p03797,s777038414,Wrong Answer,"N,M = map(int,input().split()) + +tmp = M - N*2 +print(tmp//4+N)" +p03331,s531951923,Accepted,"def calc(a): + ret = 0 + while a != 0: + ret += a % 10 + a //= 10 + return ret + +def resolve(): + n = int(input()) + ans = 1000000000 + for a in range(1, n): + b = n - a + ans = min(ans, calc(a) + calc(b)) + print(ans) + return + +if __name__ == ""__main__"": + resolve() +" +p02660,s359504161,Accepted,"N = int(input()) + + +hash = {} +end = int(N ** (1/2)) +for i in range(2, end + 1): + while N % i == 0: + hash[i] = hash.get(i, 0) + 1 + N = N // i +if N != 1: + hash[i] = hash.get(i, 0) + 1 + + +count = 1 +res = 0 +for i in hash.values(): + count = 1 + while i >= count: + res += 1 + i -= count + count += 1 + +print(res)" +p02744,s750623915,Accepted,"N, = list(map(int, input().split())) + + +def gen(path, maxOrd): + if len(path) == N: + print("""".join(chr(ord(""a"") + x) for x in path)) + else: + for x in range(maxOrd + 2): + path.append(x) + gen(path, max(maxOrd, x)) + path.pop() + + +gen([], -1) + +" +p02836,s387221703,Wrong Answer,"S = input() +len = len(S) +ans = 0 +for i in range(len//2): + if S[i] != S[len-i-2]: + ans = ans + 1 +print(ans)" +p02705,s022014325,Accepted,"R = float(input()) +l = 3.14159*R*2 +print(l)" +p03645,s109368146,Accepted,"n, m = map(int, input().split()) +ab = set() +bn = set() +for i in range(m): + a, b = map(int, input().split()) + if a==1: ab.add(b) + if b==n: bn.add(a) +print('POSSIBLE' if bn&ab else 'IMPOSSIBLE') +" +p03327,s552415150,Wrong Answer,"N = int(input()) +if N < 1000: + print('ABC' + str(N // 100) + str(N // 10)[-1] + str(N // 1)[-1]) +else: + print('ABD' + str((N - 999) // 100) + str((N - 999) // 10)[-1] + str((N - 999) // 1)[-1])" +p02688,s439856795,Wrong Answer,"N,K = map(int,input().split()) +sunuke_dict = {} +for i in range(K): + d = int(input()) + sunuke_dict[d] = list(map(int,input().split())) +ans = [1]*(N+1) +ans[0] =0 +for v in sunuke_dict.values(): + for v_ in v: + if ans[v_] == 1: + ans[v_] =0 +print(sum(ans))" +p02731,s596188198,Wrong Answer,"L = int(input()) + +ans = 0 +for i in range(1, 1001): + for j in range(1, 1001): + if i + j > 1000 or i + j > L: + break + for k in range(1, 1001): + if i + j + k > 1000 or i + j + k > L: + break + ans = max(ans, i * j * k) +print(ans)" +p03013,s615417426,Wrong Answer,"n,m=map(int,input().split()) +lst=[int(input()) for i in range(m)] +DP=[0]*(n+1) +temp=0 +DP[0]=1 +for i in range(1, n+1): + if i==1 and i not in lst: + DP[i]=1 + elif i==1 and i in lst: + DP[i]=0 + elif i in lst: + DP[i]=0 + else: + DP[i]=(DP[i-1]+DP[i-2])%(10*9+7) +print(DP[n])" +p02797,s430758862,Accepted,"N,K,S = map(int,input().split()) +t = [999999999]*N +for i in range(K): + t[i] = S +print(*t)" +p02958,s459221865,Wrong Answer,"n = int(input()) +ns = list(map(int, input().split())) +count = 0 +for i in range(n): + if ns[i] != sorted(ns)[i]: + count += 1 +if count <= 2: + print('YES') +else: + print('No')" +p02917,s085339868,Accepted,"def myAnswer(N:int,B:list) -> int: + total = B[0]+B[-1] + pre = B.pop(0) + for b in B: + total += min(pre,b) + pre = b + return total + +def modelAnswer(): + tmp=1 +def main(): + N = int(input()) + B = list(map(int,input().split())) + + print(myAnswer(N,B[:])) + +if __name__ == '__main__': + main()" +p04020,s582532123,Accepted,"N = int(input()) + +ans = 0 +n = 0 +for i in range(N): + a = int(input()) + if(a != 0 and n > 0): + ans += 1 + a -= 1 + n = 0 + elif(a == 0): + n = 0 + + if(a > 1): + ans += a//2 + n = a%2 + +print(ans)" +p03386,s819034646,Accepted,"a, b, k = map(int, input().split()) +n = b - a + 1 + +if n > k * 2: + for i in range(k): + print(a+i) + for i in range(k): + print(b-(k-i-1)) +else: + for i in range(a, b+1): + print(i)" +p03971,s105989328,Accepted," +N, A, B = list(map(int,input().split())) +S = input() +AB = A+B + +pass_student = 0 +B_pass_student = 0 +for i in range(N): + if S[i] == ""a"" and pass_student < AB: + print(""Yes"") + pass_student +=1 + elif S[i] ==""b"" and pass_student < AB and B_pass_student < B: + print(""Yes"") + pass_student += 1 + B_pass_student += 1 + else: + print(""No"")" +p02755,s845560426,Accepted,"a,b=map(int, input().split()) + +xa=int(12.5*a-0.0001)+1 +xb=10*b +x=max(xa,xb) +ra=int(x*0.08) +rb=int(x*0.1) + +if ra==a and rb==b: + print(x) +else: + print(-1)" +p02553,s164076393,Wrong Answer,"a,b,c,d=map(int,input().split()) +x=[] +x.append(max(a,b)*max(c,d)) +x.append(max(a,b)*min(c,d)) +x.append(min(a,b)*max(c,d)) +x.append(min(a,b)*max(c,d)) +print(max(x))" +p02624,s708302234,Wrong Answer,"n = int(input()) +ans = 0 +for i in range(1,n+1): + y = (n // i) + ans += (1 + y)*y*i/2 +print(ans) +" +p03838,s625869908,Accepted,"x,y=list(map(int,input().split())) +if x>=0 and y>0: + if x>y: + print(2+x-y) + else: + print(y-x) +elif x<0 and y>0: + print(abs(x+y)+1) +elif x>=0 and y<0: + print(abs(x+y)+1) +elif x<0 and y<0: + if x>y: + print(2+x-y) + else: + print(y-x) +elif y==0: + if x<=0: + print(abs(x)) + else: + print(x+1)" +p02677,s880627718,Accepted,"import math +A, B, H, M = map(int, input().split()) + +a = (H / 6 + M / 360) * math.pi +ax = math.cos(a) * A +ay = math.sin(a) * A + +b = M / 30 * math.pi +bx = math.cos(b) * B +by = math.sin(b) * B + +print(math.sqrt((ax - bx)**2 + (ay - by)**2)) +" +p02608,s493420894,Wrong Answer,"n = int(input()) + +ans = 0 +ans1 = [0] * n +for i in range(1,n): + for j in range(1,n): + for k in range(1,n): + ans = i**2 + j**2 +k**2 + i*j + j*k + k*i + for l in range(6,n-1): + if(l+1 == ans): + ans1[l] += 1 +for i in range(n): + print(ans1[i])" +p03943,s293109907,Accepted,"a,b,c = map(int, input().split()) +if a + b == c or a + c == b or b + c == a: + print(""Yes"") +else: + print(""No"")" +p03012,s695767995,Wrong Answer,"n=int(input()) +w=list(map(int,input().split())) +sum=sum(w) +sum1=0 +for i in range(len(w)): + sum-=w[i]*2 #総和をw[0]から引いて + if sum<0: #マイナスになったらグループの分かれ目 + sum1=sum+w[i] + if abs(sum)<=abs(sum1): #分かれ目のw[i]で比較 + print(sum) + else: + print(sum1) +" +p03633,s812869669,Wrong Answer,1000000000000000000 +p02947,s271132059,Accepted," +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) + +def main(): + mod=10**9+7 + N=I() + from collections import defaultdict + dd = defaultdict(int) + + for _ in range(N): + s=list(input()) + s.sort() + s=''.join(map(str, s)) + dd[s]+=1 + + ans=0 + + for k,v in dd.items(): + ans+=(v*(v-1))//2 + + print(ans) + +main() +" +p03804,s522810004,Accepted,"N,M=map(int,input().split()) +A=[input()for i in range(N)] +B=[input()for i in range(M)] +b='' +a='no' +for i in range(M): + b+=B[i] +for i in range(N-M+1): + if B[0]in A[i] : + for j in range(N-M+1): + a='' + for k in range(M): + a+=A[i+k][j:j+M] + if a==b: + print(""Yes"") + exit() +print(""No"") +" +p02760,s818462997,Accepted,"a = [list(map(int,input().split())) for _ in range(3)] + +n = int(input()) + +ans = ""No"" + +for i in range(n): + b = int(input()) + for j in range(3): + for k in range(3): + if a[j][k] == b: + a[j][k] = -1 + +for i in range(3): + if a[i][0] == a[i][1] == a[i][2] == -1:ans = ""Yes"" + if a[0][i] == a[1][i] == a[2][i] == -1:ans = ""Yes"" +if a[0][0] == a[1][1] == a[2][2] == -1:ans = ""Yes"" +if a[0][2] == a[1][1] == a[0][2] == -1:ans = ""Yes"" +print(ans) + + + +" +p02596,s464645782,Wrong Answer,"import sys + +n=int(input()) + +if n%2 ==0: + print(-1) + sys.exit() + +Ai=[7%n] +for i in range(1,n+1): + res=(Ai[i-1]*10 + 7)%n + if res ==0: + print(i+1) + sys.exit() + Ai.append(res) +print(-1)" +p02691,s263700695,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +sa = [0]*n +wa = [0]*n + +ans = 0 +for i in range(n): + sa[i] = a[i]-i + wa[i] = a[i]+i +b = Counter(wa) +c = Counter(sa) + +for i in b: + ans += b[i]*c[-i] + +print(ans)" +p03854,s216206146,Wrong Answer,"s = input() +s=s[::-1] +A=[""dream"",""dreamer"",""erase"",""eraser""] +for i in range(len(A)): + A[i]=A[i][::-1] + +i=0 +ans=""Yes"" +while True: + if len(s)==i: + break + elif s[i:i+5]==A[0]: + i+=5 + elif s[i:i+7]==A[1]: + i+=7 + elif s[i:i+5]==A[2]: + i+=5 + elif s[i:i+6]==A[3]: + i+=6 + else: + ans=""No"" + break +print(ans)" +p02924,s598357612,Wrong Answer,"n=int(input()) + +print(n//2*n) " +p03761,s823414131,Accepted,"n = int(input()) + +ss = [] +mins = 'a'*100 +for _ in range(n): + s = str(''.join(sorted(input()))) + ss.append(s) + if len(mins) > len(s): + mins = s + +ans = '' +for w in mins: + ok = True + for i, s in enumerate(ss[:]): + if w in s: + wi = s.find(w) + ss[i] = s[:wi] + s[wi+1:] + else: + ok = False + if ok: + ans += w +print(ans)" +p03106,s656214092,Accepted,"A, B, K = map(int, input().split()) +chk = 0 +for x in range(min(A, B), 0, -1): + if A % x == 0 and B % x == 0: + chk += 1 + if chk == K: + print(x) + exit()" +p03555,s418423205,Accepted,"c1=input() +c2=input() +if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0]: + print('YES') +else: + print('NO')" +p03427,s425487357,Accepted,"N = input() +ans = sum(int(c) for c in N) + +for i in range(1,len(N)): + t = sum(int(c) for c in N[:i]) - 1 + 9 * (len(N) - i) + ans = max(ans, t) +print(ans)" +p03485,s055905852,Wrong Answer,"a,b=map(int,input().split()) +print((a+b)//2)" +p03997,s771774864,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) + +area = (a + b)*h/2 + +print(int(area))" +p02972,s303149133,Wrong Answer,"N = int(input()) +A = [0] +A.extend(list(map(int, input().split()))) + +for i in range(N//2 + 1)[::-1]: + wa = 0 + for j in range(2, N+1): + if i * j > N: + break + wa += A[i*j] + wa %= 2 + if A[i] != wa: + A[i] = (A[i] + 1) % 2 + +A = A[1:] + +print(A.count(1)) +for i in A: + if i == 1: + print(i, end=' ') +" +p02695,s862898022,Wrong Answer,"import itertools +N, M, Q = map(int, input().split()) +P = [[int(x) for x in input().split()] for _ in range(Q)] + +li = [x for x in range(1, M+1)] +Com = itertools.combinations(li, N) + +ans=0 +for com in Com: + reg=0 + for a,b,c,d in P: + if com[b-1] - com[a-1] == c: + reg += d + ans = max(reg, ans) +print(ans)" +p02795,s771007882,Wrong Answer,"H=int(input()) +W=int(input()) +N=int(input()) + +if W>H : + k=int(N/W)+1 +else: + k=int(H/W)+1 + + +print(k)" +p02630,s047577518,Accepted,"n=int(input()) +A=list(map(int,input().split())) +q=int(input()) +dic={i+1:0 for i in range(10**5)} +for a in A: + dic[a]+=1 + +s=sum(A) + +for i in range(q): + b,c=map(int,input().split()) + nom=dic[b] + dic[c]+=nom + dic[b]=0 + s+=nom*(c-b) + print(s) + " +p02761,s132979076,Accepted,"import sys +N, M = map(int, input().split()) +l = [] +for i in range(M): + l.append(list(map(int, input().split()))) + +ans = -1 + +if N == 1: + start, stop = 0, 10 +elif N == 2: + start, stop = 10, 100 +else: + start, stop = 100, 1000 + +for i in range(start, stop): + temp = list(str(i)) + for j in range(N): + temp[j] = int(temp[j]) + flag = 1 + for j in range(M): + if temp[l[j][0]-1] != l[j][1]: + flag = 0 + if flag == 1: + ans = i + break +print(ans)" +p02708,s672099316,Accepted,"#abc163 Sum of Large Numbers +n, k = map(int, input().split()) +def Funmy(a, N): + return (8+3*a*N + 3*N -2*a*a)*a/6 + +total =Funmy(n+1,n) -Funmy(k-1,n) +m = 7 + 10**9 +output = (total)%m +print(int(output))" +p03210,s057182889,Accepted,"X = int(input()) + +if X == 3 or X == 5 or X == 7: + print(""YES"") +else: + print(""NO"")" +p02602,s381113694,Accepted,"N, K = map(int,input().split()) +A = list(map(int,input().split())) +for i in range(N - K): + if A[i] < A[i + K]: print(""Yes"") + else: print(""No"") +" +p03281,s279803920,Accepted,"def yakusuu(n): + cnt = 0 + for i in range(1,n+1): + if n % i == 0: + cnt += 1 + return cnt + + +N = int(input()) +ans = 0 +for i in range(1,N+1): + if i % 2 != 0: + if yakusuu(i) == 8: + ans += 1 +print(ans) +" +p02618,s625668963,Wrong Answer,"# シンプル貪欲 + +d=int(input()) +c= list(map(int, input().split())) +D= [list(map(int, input().split())) for i in range(d)] + +ans=[0]*d +for i in range(d): + x=D[i].index(max(D[i])) + ans[i]=x +for i in range(d): + print(ans[i])" +p02606,s291321651,Wrong Answer,"def countDivisibles(A, B, M): + if (A % M == 0): + return ((B / M) - (A / M)) + 1 + return ((B / M) - (A / M)) + +l,r,d = [int(x) for x in input().split()] +print(countDivisibles(l,r,d))" +p03698,s529739075,Wrong Answer,"N=input() +if N==set(N): + print(""yes"") +else: + print(""no"")" +p02647,s357592484,Accepted,"import copy +N, K = map(int, input().split()) +A = list(map(int, input().split())) +lights = [0] * N + +for _ in range(min(K, 42)): + lights = [0] * N + for i, flash in enumerate(A): + lights[max(0, i-flash)] += 1 + if i+flash < N-1: + lights[i+flash+1] -= 1 + for i in range(1, N): + lights[i] += lights[i-1] + A = copy.deepcopy(lights) + +for i in A: + print(int(i),end=' ') +print()" +p03475,s622382272,Accepted,"N = int(input()) +A = [0 for _ in range(N)] +for i in range(N-1): + c, s, f = map(int, input().split()) + for j in range(i+1): + if A[j] < s: + A[j] = s + c + else: + d = (A[j] - s) // f + if (A[j] - s) % f != 0: + d += 1 + A[j] = s + f * d + c +for i in range(N): + print(A[i]) +" +p03220,s122731108,Wrong Answer,"N = int(input()) +T,A = map(int,input().split()) +H = list(map(int,input().split())) + +a_meter = (12-A*1000)//6 + +ans = -1 +diff = 10**9 +for i in range(N): + d = abs(1000*T-6*H[i]-1000*A) + if d < diff: + d = diff + ans = i + 1 +print(ans)" +p03385,s174929273,Accepted,"s=''.join(sorted(input())) +if s=='abc': + print('Yes') +else: + print('No') +" +p03612,s000849918,Accepted,"from itertools import groupby + +n = input() +li = list(map(int, input().split())) +lii = [val == (itr + 1) for itr, val in enumerate(li)] +gbli = [[key, len(list(group))] for key, group in groupby(lii)] + +ans = 0 +for key, val in gbli: + if key: + ans += (val - 1) // 2 + 1 + +print(ans) +" +p02862,s524244980,Accepted,"def comb_mod(n,r,m): + ans = 1 + for i in range(1,r+1): + ans *= (n-i+1) % m + ans *= pow(i,m-2,m) % m + ans = ans % m + return ans +x,y = map(int,input().split()) +m = 10**9+7 +n = (x+y)//3 +c = 0 +if x*0.5 <= y <= 2*x and (x+y)%3 == 0: + r = x - n + c = comb_mod(n,r,m) +else: + ans = 0 +print(c) +" +p03385,s924851114,Wrong Answer,"print('YES' if len(set(input())) == 3 else 'No') +" +p03795,s610363464,Accepted,"n=int(input()) +print(800*n-200*(n//15))" +p02866,s398112640,Accepted,"n=int(input()) +d=list(map(int,input().split())) +if d[0] != 0: + print(0) + exit() +d.sort() +if d[1] == 0: + print(0) + exit() +cnt = 1 +pre = 1 +ans =1 +i = 1 +mod = 998244353 +while i < n: + if d[i]-1 != d[i-1]: + ans = 0 + while i!=n-1 and d[i+1] == d[i]: + i+=1 + cnt+=1 + ans *= pow(pre,cnt,mod) + ans %= mod + pre =cnt + cnt = 1 + i+=1 +print(ans)" +p02833,s699768862,Accepted,"def count_0(n): + if n%2 == 1: + return 0 + div_10 = n//10 + sum = div_10 + for i in range(1, 50): + sum += div_10//(5**i) + return sum +N = int(input()) +print(count_0(N))" +p02791,s664224201,Accepted,"N=int(input()) +P=list(map(int,input().split())) +min_p=P[0] +cnt=0 +for i in range(N): + if min_p>=P[i]: + min_p=P[i] + cnt+=1 +print(cnt)" +p03543,s342251324,Wrong Answer,"s = input() +count=0 +for i in range(3): + if s[i]==s[i+1]: + count+=1 + else: + count==0 + + if count==2: + print(""Yes"") + exit() +print(""No"") +" +p02718,s473546869,Wrong Answer,"N,M = map(int,input().split()) +A = list(map(int,input().split())) + +def vote(a,m): + a.sort(reverse=True) + for i in range(m): + if a[i] >= sum(a)/(4*m): + return True + else: + return False + +ans = ""Yes"" if vote(A,M) else ""No"" +print(ans) +" +p03274,s474910746,Wrong Answer,"#coding: utf-8 +import math +import heapq +import bisect +import numpy as np +from collections import Counter +#from scipy.misc import comb + +N,K = map(int, input().split()) + +# 複数個の数値を、intの配列として取得 +X = list(map(int, input().split())) + +ans = 2*(10**8) +for i in range(N-K+1): + tmp = min(abs(X[i])+abs(X[i+K-1]-X[i]), abs(X[i+K-1])*abs(X[i+K-1]-X[i])) + ans = min(ans,tmp) + +print(ans)" +p02631,s763903144,Accepted,"bitsum = 0 +ans = [] +N = int(input()) +num = list(int(x) for x in input().split()) +for i in num: + bitsum = bitsum ^ i +for i in num: + ans.append(bitsum ^ i) +print(' '.join(map(str, ans))) +" +p02630,s513381286,Accepted,"N = int(input()) +A = [int(x) for x in input().split()] +ans = sum(A) +l = [0] * 100000 +for i in A: + l[i-1] += 1 +Q = int(input()) +for i in range(Q): + B, C = map(int, input().split()) + ans += l[B-1] * (C - B) + l[C-1] += l[B-1] + l[B-1] = 0 + print(ans)" +p02675,s724870825,Accepted,"n=input() + +if n[-1] == '3': + print('bon') +elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8': + print('pon') +else: + print('hon')" +p03457,s441802368,Accepted,"N = int(input()) +T = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)] +normal = True +def judge(a, b): + m = b[0]-a[0]-abs(b[1]-a[1])-abs(b[2]-a[2]) + if m>=0 and m%2==0: + return True + else: + return False +for i in range(N): + if judge(T[i], T[i+1]): + pass + else: + normal = False + break +print(""Yes"" if normal else ""No"")" +p02597,s757250118,Wrong Answer,"n = int(input()) +C = input() +chk = 0 +for i in range(n): + if C[n-1-i] == 'R': + chk = n-1-i + break +cnt = 1 +for i in range(chk): + if C[i] == 'R': + cnt += 1 +ans = 0 +for i in range(cnt): + if C[i] == 'W': + ans += 1 +print(ans)" +p04012,s874733897,Wrong Answer,"#!/usr/bin/env python3 +from collections import defaultdict + +w = input() +d = defaultdict(int) +for i in w: + d[w] += 1 +print(""YNeos""[any(i % 2 > 0 for i in d.values())::2]) +" +p03986,s632795886,Accepted,"from collections import deque +S=list(map(lambda x: 1 if x==""T"" else 0,input())) + +q=deque() + +for i in S: + + if i: + if (not q) or q[-1]!=0: + q.append(i) + elif q and q[-1]==0: + q.pop() + else: + q.append(i) +print(len(q))" +p03815,s323223112,Accepted,"import math +x = int(input()) +Su = math.floor(x/11) +M = x%11 +if x < 11: + if x <=6: + print(1) + else: + print(2) +else: + if M ==0: + print(Su*2) + else: + if M <= 6: + print(Su*2+1) + else: + print(Su*2+2)" +p02754,s994330900,Wrong Answer,"n, a, b = map(int, input().split()) +if a == 0: + print(0) +elif a+b >= n: + print(a) if a <= n else print(n) +else: + ab = a + b + ans = n // ab * a + n % ab + print(ans)" +p02952,s012282912,Wrong Answer," +def fn(i): + return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999) + + +def main(): + # n = int(input()) + n = 124 + x = range(n + 1)[1:] + x = tuple(filter(fn, x)) + + print(len(x)) + + +if __name__ == '__main__': + main() +" +p02571,s290568928,Accepted,"t = input() +s = input() + +mxscore = -1 +beststr = '' +for i in range(len(s),len(t)+1): + check = t[i-len(s):i] + now = 0 + for j in range(len(check)): + if s[j] == check[j]: + now += 1 + if now > mxscore: + mxscore = now + +print(len(s)-mxscore) + +" +p02689,s868550457,Accepted,"N, M = map(int, input().split()) +height = list(map(int, input().split())) +judge = N*[1] +for i in range(M): + A, B = map(int, input().split()) + if(height[A-1]>=height[B-1]): + judge[B-1] = 0 + if(height[A-1]<=height[B-1]): + judge[A-1] = 0 + +ans = 0 +for i in range(N): + if judge[i]==1: + ans += 1 +print(ans)" +p02730,s134520824,Wrong Answer,"S = input() +N = len(S) +a = S[0:(N-1)//2] +b = S[(N+3)//2-1:] + +def kaibun(l): + for i in range(len(l)): + if l[i] != l[len(l)-1-i]: + return(False) + return(True) + +print(kaibun(S)) +print(a) +print(kaibun(a)) +print(b) +print(kaibun(b)) + +if kaibun(S) & kaibun(a) & kaibun(b): + print(""Yes"") +else: + print(""No"") + " +p02748,s455211030,Accepted,"a,b,m = map(int,input().split()) +price_a = list(map(int,input().split())) +price_b = list(map(int,input().split())) + +minPrice = min(price_a) + min(price_b) + +for i in range(m): + x,y,c = map(int,input().split()) + price = price_a[x-1] + price_b[y-1] -c + if price < minPrice: + minPrice = price + +print(minPrice)" +p03730,s885761475,Accepted,"a,b,c = map(int,input().split()) +if any(a*i%b==c for i in range(1,b)): + print('YES') +else: + print('NO')" +p03637,s307514495,Accepted,"N = int(input()) +A = map(int, input().split()) +var0 = 0 +var1 = 0 +var2 = 0 + +for a in A: + if a % 4 == 0: + var2 += 1 + elif a % 2 == 0: + var1 += 1 + else: + var0 += 1 + +var1 %= 2 +ans = 'Yes' if var2 >= var1 + var0 - 1 else 'No' +print(ans) +" +p03767,s680666395,Accepted,"n = int(input()) +a_li = list(map(int,input().split())) +a_li.sort() +ans = 0 +for i in range(1,n+1): + ans += a_li[3*n-1-(i*2-1)] +print(ans)" +p02663,s181373822,Wrong Answer,"h1, m1, h2, m2, k = map(int,input().split()) +x = 60*max(0, h2-h1-1) +x += (60-m1 + m2) +if x%k == 0: + print((x//k - 1)*k) +else: + print((x//k)*k)" +p02684,s984466044,Accepted,"N,K = map(int,input().split()) +A = list(map(int,input().split())) +s = 1 +B = [] +set_ = set() +for i in range(N): + if A[s-1] not in set_: + set_.add(A[s-1]) + B.append(A[s-1]) + s = A[s-1] + + else: + e = i + break +idx = B.index(A[s-1]) +if K-1=2: + ans += m*(m-1)//2 + +print(ans) " +p02583,s493441208,Accepted,"n = int(input()) +l = [int(i) for i in input().split()] +ans = 0 +for i in range(n): + for j in range(i+1,n): + for k in range(j+1,n): + if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]: continue + if l[i] >= l[j] + l[k]: continue + if l[j] >= l[i] + l[k]: continue + if l[k] >= l[i] + l[j]: continue + ans += 1 +print(ans)" +p02719,s387201301,Accepted,"n,k=map(int,input().split()) + +if n%k<=abs(n%k-k): + print(n%k) +else: + print(abs(n%k-k))" +p03804,s749913095,Wrong Answer,"# ABC 054: B – Template Matching +n, m = map(int, input().split()) +a = [input() for _ in range(n)] +b = [input() for _ in range(m)] + +isIncluding = 'No' + +for p in a: + for q in b: + if q not in p: + break + else: + isIncluding = 'Yes' + break + +print(isIncluding)" +p03162,s255102417,Accepted,"n=int(input()) +dp=[[0]*3 for _ in range(n)] +dp[0]=list(map(int,input().split())) +for i in range(1,n): + a,b,c=map(int,input().split()) + dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]) + dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]) + dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]) +print(max(dp[n-1]))" +p03220,s126674882,Accepted,"n=int(input()) +t,a=map(int,input().split()) +H=list(map(int,input().split())) + +m=float('inf') +for i in range(n): + if abs(a-t+0.006*H[i])= C : + print(""Yes"") +else : + print(""No"") +" +p02912,s536787498,Accepted,"#!/usr/bin/env python3 +import heapq +# import bisect + +n, m = list(map(int, input().split())) +a = list(map(lambda x: int(x)*(-1), input().split())) + +heapq.heapify(a) +for i in range(m): + value = heapq.heappop(a) + value = (value+1)//2 + heapq.heappush(a, value) + +# print(a) +print(-sum(a)) +" +p03087,s904260507,Accepted,"n, m = map(int, input().split()) +graph = list(input()) +ans = [0] * n +sans = [0] * n +for i in range(n-1): + if graph[i] == ""A"" and graph[i+1] == ""C"": + ans[i] += 1 +for j in range(n-1): + sans[j+1] = sans[j] + ans[j] + +for _ in range(m): + j, k = map(int, input().split()) + print(sans[k-1] - sans[j-1]) + " +p02598,s900624354,Accepted,"(N,K) = map(int,input().split()) +l = input().split() +max = 0 +for i in range(N): + l[i]= int(l[i]) + if max <= l[i]: + max = l[i] + +lb = 0 +ub = max + +def cut(m): + k = 0 + for i in range(N): + k += -((-1*l[i])//m)-1 + return k + +while ub - lb > 1: + if cut((ub+lb)//2)>K: + lb = (ub+lb)//2 + else: + ub = (ub+lb)//2 + +print(ub) + + +" +p02759,s914189385,Wrong Answer,"N = int(input()) +print(N//2+1)" +p03565,s691181915,Accepted,"import re +Sp = input().replace('?','.') +T = input() +flag = 0 +for i in range(len(Sp)-len(T),-1,-1): + if re.match(Sp[i:i+len(T)],T): + Sp = Sp[:i]+T+Sp[i+len(T):] + flag = 1 + break +if flag == 1: + print(Sp.replace('.','a')) +else: + print('UNRESTORABLE') +" +p02725,s506820127,Accepted,"K, N = map(int, input().split()) +A_i = list(map(int, input().split())) + + +# 20 3 20メートルで3件の家 +# 0 5 15 + +# [5, 10] + [0 + (20 -15)] +# [5, 10, 5] +# max([5, 10, 5]) => 10 +# 20 - 10 + +D_i = [] +D_i.append(A_i[0] + K - A_i[-1]) + + +for i in range(N-1): + D_i.append(A_i[i+1] - A_i[i]) + +print(K - max(D_i)) +" +p02795,s671114293,Accepted,"H = int(input()) +W = int(input()) +N = int(input()) +print((N + max(H, W) - 1) // max(H, W))" +p03745,s530010862,Accepted,"N=int(input()) +A=list(map(int,input().split())) +counter=1 +res=0 +for i in range(len(A)-1): + if (A[i+1]0) or (A[i+1]>A[i] and res<0): + counter+=1 + res=0 + elif A[i+1]!=A[i]: + res=A[i+1]-A[i] + + +print(counter) +" +p03548,s501145607,Wrong Answer,"X,Y,Z = map(int,input().split()) +cnt = 0 + +while (X-1) >= (Z+Y): + X -= (Z+Y) + cnt += 1 +print(cnt)" +p02909,s361901654,Accepted,"dic = { + ""Sunny"":""Cloudy"", + ""Cloudy"":""Rainy"", + ""Rainy"":""Sunny"" +} + +print(dic[input()])" +p02621,s161813098,Accepted,"a = int(input()) +print (a + a ** 2 + a ** 3) " +p02802,s732369686,Wrong Answer,"N, M = map(int, input().split()) +AC = [0]*N +WA = [0]*N + +for i in range(M): + p, S = input().split() + p = int(p) + + if S == ""AC"": + AC[p-1] = 1 + elif S == ""WA"": + if not AC[p-1]: + WA[p-1] = 1 + +for j in range(N): + if AC[j]==0: + WA[j]==0 + +print(sum(AC), sum(WA)) + +" +p02705,s800138661,Wrong Answer,"validation=False +Answer=() + + +while validation == False: + R=float(input(""Enter a number for the radius of the circle :"")) + if R>=1 and R<=100: + validation = True + else: + break + + +Answer=((R*2)*3.14159) + +print(Answer)" +p02612,s854526953,Accepted,"n = int(input()) +if n %1000 == 0: + print(0) +else: + print(1000-n%1000)" +p02773,s636216984,Accepted,"import sys +stdin = sys.stdin +from collections import defaultdict + +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(ns()) +na = lambda: list(map(int, stdin.readline().split())) + +n = ni() +d = defaultdict(int) +for _ in range(n): + s = ns() + d[s] += 1 +d = sorted(d.items(), key = lambda x:x[1], reverse=True) +ki, vi = d[0] +k = [ki] +for ki, v in d[1:]: + if v == vi: + k.append(ki) +k.sort() +for ki in k: + print(ki) +" +p03061,s394934928,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +import math +L = [0] * (N + 1) +R = [0] * (N + 1) + +for i in range(N): + L[i + 1] = math.gcd(L[i], A[i]) + R[N - i - 1] = math.gcd(R[N - i], A[N - i - 1]) + +ans = 0 +for i in range(N): + ans = max(ans, math.gcd(L[i], R[i+1])) + +print(ans)" +p02786,s186220217,Wrong Answer,"n = int(input()) +a = 1 + +if n % 2 == 1: + n -= 1 + +if n % 2 == 0: + for i in range(int(n/2)): + a = 2*a + 1 + +print(a)" +p02618,s975935972,Wrong Answer,"#!/usr/bin/env python3 +# input +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +D = int(input()) +C = list(map(int, input().split())) +S = [] +for i in range(D): + a = list(map(int, input().split())) + S.append(a) +for i in range(D): + idx = 1 + tmp_max = 0 + for j in range(26): + if tmp_max <= S[i][j]: + tmp_max = S[i][j] + idx = j + 1 + # print(""a"", idx) + print(idx + 1) + +" +p02659,s803421391,Accepted,"import decimal + +a,b = map(str, input().split()) + +A=decimal.Decimal(a) +B=decimal.Decimal(b) + +print(decimal.Decimal(A*B).quantize(decimal.Decimal('1.'), rounding=decimal.ROUND_DOWN))" +p03285,s956456171,Accepted,"# -*- coding: utf-8 -*- +n = int(input()) + +flag = 0 +for cake in range(100): + for donuts in range(100): + if 4 * cake + 7 * donuts == n: + flag = 1 + +if flag == 1: + print(""Yes"") +else: + print(""No"") +" +p03469,s592581994,Accepted,"s=list(input()) +s[3]=8 +for i in s: + print(i,end="""") +" +p02695,s614676326,Accepted,"from itertools import combinations_with_replacement as comb + +n, m, q = map(int, input().split()) +queries = [tuple(map(int, input().split())) for _ in range(q)] +ans = 0 + +def calc_score(p): + score = 0 + for a, b, c, d in queries: + if p[b-1] - p[a-1] == c: + score += d + return score + +for p in comb(range(1, m+1), n): + ans = max(ans, calc_score(p)) + +print(ans) +" +p02814,s703541750,Accepted,"from fractions import gcd +n,m = map(int,input().split()) +A = list(map(int,input().split())) + +l = 1 +cnt = -1 +for a in A: + l = l*a//gcd(l,a) + i = 0 + while a%2 == 0: + a = a//2 + i += 1 + if cnt == -1: + cnt = i + elif cnt != i: + print(0) + exit(0) + +ans = 1 + (m - l//2)//l +print(ans) +" +p03385,s347044023,Accepted,"if ''.join(sorted(input())) == 'abc': + print('Yes') +else: + print('No')" +p04034,s210962915,Accepted,"n, m = map(int, input().split()) +ball = [1]*n +flg = [False]*n +flg[0] = True + +for _ in range(m): + x, y = map(int, input().split()) + if flg[x-1]: + flg[y-1] = True + if ball[x-1] == 1 and flg[x-1]: + flg[x-1] = False + ball[y-1] += 1 + ball[x-1] -= 1 + # print(x, y, ball, flg) + +ans = flg.count(True) +print(ans) +" +p02813,s805080080,Wrong Answer,"import itertools +n=int(input()) +p=list(map(int,input().split())) +q=list(map(int,input().split())) +nums = list(range(1,n+1)) +d= [ list(i) for i in itertools.permutations(nums)] +a=0 +b=0 +for i in range(len(d)): + if p==d[i]: + a=i + elif q==d[i]: + b=i +print(abs(a-b))" +p02603,s768735267,Wrong Answer,"n = int(input()) +a_list = list(map(int, input().split())) +money = 1000 +stock = 0 +for i in range(n-1): + if a_list[i+1] < a_list[i]: + money += stock*a_list[i] + stock = 0 + elif a_list[i+1] > a_list[i]: + stock += money//a_list[i] + money -= stock*a_list[i] + +print(money+stock*a_list[n-1]) +" +p02861,s154288588,Accepted,"n = int(input()) +pos = [] +for _ in range(n): + x,y = map(int,input().split()) + pos.append((x,y)) + +import math +def distance(p1,p2): + x1,y1 = p1 + x2,y2 = p2 + return math.sqrt((x1-x2)**2 + (y1-y2)**2) + +ans = 0 +for i in range(n): + for j in range(n): + ans += distance(pos[i],pos[j]) +print(ans/n) + +" +p02918,s287020169,Accepted,"n,k = map(int,input().split()) +s = input() + +ans = 0 +for i in range(n-1): + if s[i] == s[i+1]: + ans += 1 + +print(min(ans + 2*k , n-1))" +p02912,s529500142,Accepted,"import heapq + +N, M = map(int, input().split()) +A = list(map(lambda x: (-1)*int(x), input().split())) +heapq.heapify(A) + +for _ in range(M): + t_min = heapq.heappop(A) + heapq.heappush(A, (-1)*(-t_min//2)) + +print(-sum(A))" +p02699,s211469289,Wrong Answer,"S, W = list(map(int, input().split())) +if S < W: + print(""unsafe"") +else: + print(""safe"")" +p04011,s176010603,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +if n <= k: print(n * x) +else: print(k * x + (n-k) * y)" +p03086,s996733254,Accepted,"S=input() +agct='AGCT' +ans=0 +for i in range(len(S)): + cnt=0 + j=i + while j 0: + cnt += 1 + K -= 1 + if visited[pos] == 0: + visited[pos] = cnt + elif not flag: + K %= cnt-visited[pos] + flag = True + pos = A[pos]-1 +print(pos+1)" +p02706,s084344475,Accepted,"def main(): + n,m = tuple([int(t)for t in input().split()]) + a = tuple([int(t)for t in input().split()]) + + ans = n-sum(a) + if ans>=0: + print(ans) + else: + print(-1) + +if __name__ == ""__main__"": + main()" +p03380,s570890050,Accepted,"n = int(input()) +a_l = list(map(int,input().split())) + +a_l.sort(reverse=True) +ans_n = a_l[0] +a_l2 = [] +for i, val in enumerate(a_l): + a_l2.append((abs(val-float(ans_n)/2),i)) +a_l2.sort() + +if a_l2[0][1] == 0: + ans_r_index = a_l2[1][1] +else: + ans_r_index = a_l2[0][1] +ans_r = a_l[ans_r_index] +print(ans_n, ans_r)" +p03077,s393805400,Accepted,"import math +from math import gcd +INF = float(""inf"") + +import sys +input=sys.stdin.readline +sys.setrecursionlimit(500*500) +import itertools +from collections import Counter,deque + +def main(): + n = int(input()) + a = int(input()) + b = int(input()) + c = int(input()) + d = int(input()) + e = int(input()) + + ans = (math.ceil(n/min(a,b,c,d,e)))+4 + print(ans) + + +if __name__==""__main__"": + main() +" +p03627,s241068971,Accepted,"from collections import Counter + +n = int(input()) +A = list(map(int,input().split())) + +cnt = Counter(A) + +parts = [] +for k in sorted(cnt.keys(),reverse=True): + if cnt[k] >= 4: + parts += [k,k] + elif cnt[k] >= 2: + parts.append(k) + +if len(parts) >= 2: + print(parts[0]*parts[1]) +else: + print(0)" +p03416,s623847923,Accepted,"A, B = map(int, input().split()) +ans = 0 +for i in range(A, B + 1): + if str(i) == str(i)[::-1]: + ans += 1 +print(ans)" +p03408,s512613630,Accepted,"s, t = [], [] +for i in range(int(input())): + s.append(input()) +for i in range(int(input())): + t.append(input()) + +profit = 0 +for i in s: + temp = s.count(i) - t.count(i) + if profit < temp: + profit = temp + +print(profit) +" +p03627,s604382483,Accepted,"import math +import collections +import fractions +import itertools + +def solve(): + n = int(input()) + a = list(map(int, input().split())) + c = collections.Counter(a) + box = [] + for i in c: + if c[i] >= 2: + for _ in range(c[i]//2): + box.append(i) + if len(box) < 2: + print(0) + else: + box.sort(reverse=True) + print(box[0]*box[1]) + return 0 + +if __name__ == ""__main__"": + solve()" +p02705,s750413700,Accepted,"def resolve(): + pi = 3.14159265 + r = int(input()) + print(2*r*pi) +resolve()" +p03434,s343661709,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +a.sort(reverse=True) +Alice = list() +Bob = list() +print(a) +for i in range(n): + if i % 2 == 0: + Alice.append(a[i]) + else: + Bob.append(a[i]) + +print(sum(Alice) - sum(Bob)) +" +p02623,s769103397,Accepted,"N, M, K = map(int, input().split()) + +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +a, b = [0], [0] +for i in range(N): + a.append(a[i] + A[i]) +for i in range(M): + b.append(b[i] + B[i]) + +res = 0 +j = M +for i in range(N+1): + if a[i] > K: + break + while b[j] > K - a[i]: + j -= 1 + res = max(res, i+j) +print(res)" +p03997,s262331569,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) + +print(((a + b) * h) / 2)" +p02765,s898400632,Wrong Answer,"a = input().split() +print(int(a[1]) + 100*(10-int(a[0])))" +p02813,s773101195,Accepted,"import itertools +n = int(input()) +p = list(map(int, input().split())) +q = list(map(int, input().split())) +permutations_lis = itertools.permutations(range(1,n+1))# 全ての場合のリストを生成 +dis_list = [] +for i,case in enumerate(permutations_lis): + if list(case) == p : + a = i + if list(case) == q : + b = i +print(abs(a-b))" +p03035,s709623345,Accepted,"import sys + +A, B = map(int, sys.stdin.readline().split()) +if A <= 5: + print(0) +elif A <= 12: + print(B // 2) +else: + print(B)" +p02922,s352178101,Accepted,"# -*- coding: utf-8 -*- + +A, B = map(int, input().split()) + +k = 1 +count = 0 +while k < B: + k = (k - 1) + A + count = count + 1 + +print(count) +" +p03323,s514738524,Accepted,"a,b=map(int,input().split()) +if a<=8 and b<=8: + print('Yay!') +else: + print(':(') +" +p04034,s964644551,Wrong Answer,"n,m=map(int,input().split()) +arr=[list(map(int,input().split())) for _ in range(m)] +count=[1]*(n+1) +flag=[False]*(n+1) +flag[1]=True +for a,b in arr: + count[b]+=1 + count[a]-=1 + if flag[a]==True: + flag[b]==True + if count[a]==0: + flag[a]==False +print(flag.count(True))" +p02690,s435851539,Accepted,"a5=[i**5 for i in range(300)] +x=int(input()) +flag=0 +for i in range(300): + for j in range(300): + if flag==0 and a5[i]-a5[j]==x: + print(str(i)+"" ""+str(j)) + flag=1 + if flag==0 and a5[i]+a5[j]==x: + print(str(i)+"" -""+str(j)) + flag=1 + " +p02832,s666803282,Accepted,"n=int(input()) +A=list(map(int,input().split())) +cnt=1 +ans=0 +for i in range(len(A)): + if A[i]==cnt: + cnt+=1 + else: + ans+=1 +if ans==len(A): + print(-1) +else: + print(ans)" +p04045,s886212902,Wrong Answer,"m,n = list(map(int,input().split("" ""))) +l = list(map(str,input().split("" ""))) + +a = m + +while 1: + for i in str(a): + if i in l: + a += 1 + break + else: + print(a) + exit()" +p02664,s999836757,Wrong Answer,"import numpy as np + +a = input() +s = list(a) + +index = [] +index.append(a.find('?')+1) + +i = 0 +while a.find('?',index[i]) != -1: + tmp = a.find('?',index[i]) + index.append(tmp + 1) + i = i + 1 + +score = a.count('D') + a.count('PD') + +for i in range(len(index)): + s[index[i]-1] = 'D' + score = score + 1 + +s = """".join(s) +print(s)" +p03494,s373770059,Wrong Answer,"N=int(input()) +x=list(map(int,input().split())) + +for i in range(N): + count=0 + while x[i]%2==0: + x[i]/=2 + count+=1 + +print(count)" +p03665,s783662133,Accepted,"n,p = map(int,input().split()) +a = list(map(int,input().split())) + +# dp[i][p]:i番目まで見たとき、余りがpとなる選び方 +dp = [[0 for _ in range(2)] for _ in range(n+1)] +dp[0][0] = 1 +for i in range(n): + if a[i]%2 == 0: + dp[i+1][0] = dp[i][0]*2 + dp[i+1][1] = dp[i][1]*2 + else: + dp[i+1][0] = dp[i][0]+dp[i][1] + dp[i+1][1] = dp[i][0]+dp[i][1] +print(dp[n][p]) +#print(dp)" +p03804,s631748902,Accepted,"N, M = map(int, input().split()) +if N < M: + print('No') +else: + A = [input() for _ in range(N)] + B = '' + cnt = 0 + for _ in range(M): + B += input().rstrip() + for i in range(N-M+1): + if cnt==1: + break + for j in range(N-M+1): + judge = '' + for k in range(M): + judge += A[i+k][j:j+M] + if judge == B: + cnt += 1 + break + if cnt == 1: + print('Yes') + else: + print('No')" +p03239,s093072491,Wrong Answer,"N,T = map(int,input().split()) +CT = [] +for n in range(N): + c,t = map(int,input().split()) + CT.append([c,t]) +sorted(CT,key=lambda x: x[0]) +for ct in CT: + if ct[1] <= T: + print(ct[0]) + break" +p03607,s091334381,Wrong Answer,"N=int(input()) +p=[] +count=0 +for i in range (N): + a=int(input()) + p.append(a) +list.sort(p) +flag=1 +for j in range (N-1): + if p[j]==p[j+1]: + flag*=-1 + else: + if flag>0: + count+=1 + flag=1 +if flag<0: + count+=1 +print(count)" +p03474,s908043723,Accepted,"# -*- coding: utf-8 -*- + +a,b=map(int,input().split()) +s=input() + +if s[:a].isdecimal() and s[a]=='-' and s[a+1:].isdecimal(): + print(""Yes"") +else: + print(""No"") +" +p02621,s393200354,Accepted,"a = int(input()) +print((a**3)+(a**2)+a)" +p03639,s601709201,Accepted,"#30 C - 4-adjacent +N = int(input()) +A = list(map(int,input().split())) + +multiple4 = 0 +multiple2 = 0 +for a in A: + if a%4 == 0: + multiple4 += 1 + elif a%2 == 0: + multiple2 += 1 + +odd = N - (multiple4 + multiple2) +result = 'No' +if odd <= multiple4: + result = 'Yes' +elif ((odd - 1) <= multiple4) and (multiple2%2 == 0): + result = 'Yes' +print(result)" +p03210,s344741207,Wrong Answer,"print(""Yes"" if int(input()) in [7, 5, 3] else ""No"")" +p03799,s088484479,Accepted,"s, c = map(int, input().split()) +print(min(s, c // 2) + max(0, c - 2 * s) // 4) +" +p03657,s330233907,Wrong Answer,"a, b = list(map(int, input().split())) +print(""Possible"") if (a + b) % 3 == 0 else print(""Impossible"")" +p03163,s595767722,Accepted,"n,W = map(int,input().split()) +w = [] +v = [] +dp = [[0]*(W+1) for _ in range(n+1)] +for _ in range(n): + w1,v1 = map(int,input().split()) + w.append(w1) + v.append(v1) + +for i in range(n): + for sumw in range(W+1): + if sumw -w[i]>=0: + dp[i+1][sumw] = max(dp[i+1][sumw],dp[i][sumw-w[i]]+v[i]) + dp[i+1][sumw] = max(dp[i][sumw],dp[i+1][sumw]) +print(dp[n][W])" +p02729,s517507672,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import math +def nC2(n): + # n = 0 -> 0 + # n = 1 -> 0 + if n<2: + return 0 + return math.factorial(n) // (math.factorial(n - 2) * 2) +n,m = map(int, input().split()) +# 135 3C2 +# 2468 4C2 +# nC2 +r=nC2(n)+nC2(m) +print(r)" +p02842,s541517868,Wrong Answer,"import math +n = int(input()) +print(math.ceil(n/1.08)*(math.ceil(n/1.08) == math.floor(-~n/1.08)) or "":("")" +p03659,s333446549,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +x = A[0] +y = sum(A[1:]) +ans = abs(y - x) +for i in range(1, N - 1): + x += A[i] + y -= A[i] + ans = min(ans, abs(y - x)) +print(ans) +" +p03997,s646472471,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) +print((a+b)*h//2)" +p02989,s873594306,Accepted,"N = int(input()) +d_list = list(map(int, input().split())) +d_list.sort() +mid_1 = d_list[len(d_list) // 2 - 1] +mid_2 = d_list[len(d_list) // 2] +ans = mid_2 - mid_1 +print(ans)" +p02647,s964990325,Accepted,"import numpy as np + +N, K = map(int, input().split(' ')) +A = tuple(map(int, input().split(' '))) +indexes = np.arange(0, N) + +dp = np.zeros(shape=N + 1, dtype=np.int64) + +for k in range(K): + np.add.at(dp, np.maximum(0, indexes - A), 1) + np.add.at(dp, np.minimum(N, indexes + A + 1), -1) + A = dp.cumsum()[:-1] + if np.all(A == N): + break + dp *= 0 + +print(' '.join(map(str, A))) +" +p03817,s116808927,Accepted,"x=int(input()) +a=x//11 +b=((x-1)%11)//6+1 if x%11!=0 else 0 +print(a*2+b)" +p02916,s134675556,Wrong Answer,"N = int(input()) +eat_list = list(map(int, input().split())) +manzok_list = list(map(int, input().split())) +add_manzok_list = list(map(int, input().split())) + +manzok = 0 + +for i in range(N): + manzok += manzok_list[eat_list[i]-1] + if(i > 0 and (eat_list[i] - eat_list[i-1]) == 1): + print(i) + manzok += add_manzok_list[eat_list[i-1]-1] + +print(manzok)" +p03617,s783463463,Accepted,"q, h, s, d = map(int, input().split()) +n = int(input()) +print((n//2) * min(2*min(4*q, 2*h, s), d) + (n%2) * min(4*q, 2*h, s))" +p02645,s401435394,Wrong Answer,"a=input() +print(a[3:])" +p02996,s287844923,Accepted,"import numpy as np +N = int(input()) +li = [] +for n in range(N): + li.append([int(i) for i in list(input().split())]) +arr = np.array(li) +ruiseki = 0 +for a in arr[np.argsort(arr[:,1], axis=0)]: + if ruiseki + a[0] > a[1]: + yn = ""No"" + break + else: + yn = ""Yes"" + ruiseki+=a[0] +print(yn)" +p03861,s827462343,Wrong Answer,"a,b,x = map(int,input().split()) +num = a +cnt = 0 + +while a <= num <= b and num % x == 0: + cnt += 1 + num += x +print(cnt)" +p03944,s941080647,Accepted,"W,H,N = map(int, input().split()) +w=[0]*W +h=[0]*H +for i in range(N): + x,y,a = map(int, input().split()) + if a==1: + for i in range(x): + w[i]=1 + if a==2: + for i in range(x,W): + w[i]=1 + if a==3: + for i in range(y): + h[i]=1 + if a==4: + for i in range(y,H): + h[i]=1 + +print(w.count(0)*h.count(0))" +p03328,s058208622,Accepted,"a,b=map(int,input().split()) +n=b-a +summy=((n+1)*n)/2 +print(int(summy-b))" +p02601,s650486777,Accepted,"a, b, c = map(int, input().split()) +k = int(input()) + +for i in range(k): + if a >= b: + b *= 2 + elif b >= c: + c *= 2 + else: + c *= 2 + +if a < b and b < c: + print(""Yes"") +else: + print(""No"")" +p03281,s496723634,Wrong Answer,"N = int(input()) + +cnt=0 +ans=0 + +for i in range(1,N+1): + if N%i ==0: + cnt+=1 + if cnt ==8: + ans+=1 + +print(ans)" +p02775,s075340024,Accepted,"import sys +input = sys.stdin.readline + +Num_str = list(input().rstrip()) +L = len(Num_str) +Num = [] + +for n in reversed(Num_str): + Num.append(int(n)) + +S = 0 +up = False +for i, n in enumerate(Num): + if up: + n += 1 + if n < 5: + S += n + up = False + elif n == 5: + S += 5 + up = (i != L-1 and Num[i+1] >= 5) + else: + S += 10 - n + up = True +if up: + S += 1 +print(S)" +p02618,s727127895,Accepted,"D=int(input()) +c=list(map(int,input().split())) +last=[0 for i in range(26)] +cost=[0 for i in range(26)] +degree=[0 for i in range(26)] +s=[] +for _ in range(D): + s.append(list(map(int,input().split()))) + +for d in range(D): + for i in range(26): + cost[i]=c[i]*(d-last[i]) + degree[i]=s[d][i]-cost[i] + k=degree.index(max(degree)) + last[k]=d + print(k+1)" +p02743,s116993166,Accepted,"a,b,c= map(int,input().split()) +if c>a+b and 4*a*b<(c-a-b)*(c-a-b): + print('Yes') +else: + print('No')" +p02989,s643372359,Accepted,"n = int(input()) +d = sorted([int(i) for i in input().split()]) +print(d[n // 2] - d[n // 2 - 1])" +p03672,s059645657,Accepted,"s = input() +if len(s)%2 == 0: + s = s[:-2] +else: + s = s[:-1] + +for i in range(len(s)//2): + if s[:len(s)//2] == s[len(s)//2:]: + print(len(s)) + break + else: + s = s[:-2] +" +p03145,s769996679,Wrong Answer,"import sys + +def I(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LI(): return list(map(int, sys.stdin.readline().split())) +def main(): + a, b, c = MI() + ans = a*b*0.5 + print(ans) + +if __name__ == '__main__': + main()" +p03385,s343345687,Accepted,"S = set(input()) + +if len(S) == 3: + print('Yes') +else: + print('No')" +p03059,s817752653,Accepted,"import sys + +stdin = sys.stdin +def ns(): return stdin.readline().rstrip() +def ni(): return int(stdin.readline().rstrip()) +def nm(): return map(int, stdin.readline().split()) +def nl(): return list(map(int, stdin.readline().split())) + + +a, b, t = nm() +print(int(((t + 0.5) // a) * b)) +" +p02882,s568808280,Wrong Answer,"import math + +a, b, x = map(int, input().split()) + +y = (a ** 2) * b / 2 +if x == a**2*b/2: + print(0) +elif x <= a**2*b/2: + z = a*b**2 / (2*x) + print(math.degrees(math.atan(z))) +else: + z = 2 * (a ** 2 * b - x) / a ** 3 + print(math.degrees(math.atan(z)))" +p02796,s357379365,Accepted,"N = int(input()) + +ST = [] +for i in range(N): + X, L = map(int, input().split()) + ST.append((X - L, X + L)) + +ST.sort(key=lambda x: x[1]) + +ans = 0 +cur = -1e9 +for i in range(N): + S, T = ST[i] + if cur <= S: + ans += 1 + cur = T +print(ans) +" +p02624,s013191499,Accepted,"# -*- coding: utf-8 -*- + +N, = map(int, input().split()) + +ans = 0 + +ans = 0 +for k in range(N, 0, -1): + mi = int(N/k) + sum_num = (1+mi) * (mi//2) if mi%2==0 else mi * ((mi-1)//2) + mi + ans += k * sum_num + +print(ans) +" +p02719,s262438856,Wrong Answer,"N, K = map(int, input().split()) + +cnt = int(N / K) + 1 + +print(min(abs(N - (K * cnt)), abs(N - (K * (cnt-1))), N))" +p03852,s320580212,Accepted,"print(('consonant','vowel')[input()in'aiueo'])" +p02633,s015027701,Wrong Answer,"import math + +k = 1 +x = float(input()) +while x*k%360 == 0: + k += 1 +print(k) +" +p02707,s077413100,Accepted,"def main(): + n = int(input()) + a = list(map(int, input().split())) + + ans = [] + for i in range(n): + ans.append(0) + for x in a: + ans[x-1] += 1 + + for x in ans: + print(x) + +if __name__ == '__main__': + main() +" +p03779,s076168127,Accepted,"x = int(input()) + +t = 0 +while True: + if not (t*(t+1))/2 >= x: + t += 1 + else: + break +print(t) +" +p02570,s384544171,Wrong Answer,"d,t,s = map(int, input().split()) +print('Yes' if d//s <= t else 'No')" +p02773,s600797974,Accepted,"n = int(input()) +s = [] +while True: + try: + s.append(input()) + except EOFError: + break + +word_counter = {} +for word in s: + if word in word_counter: + word_counter[word] += 1 + else: + word_counter[word] = 0 + +results = sorted(word_counter.items(), key=lambda x: x[1], reverse=True) +max_v = results[0][1] + +pick_ups = [result[0] for result in results if result[1] == max_v] +sorted_pick_ups = sorted(pick_ups) +print(*sorted_pick_ups, sep='\n')" +p02848,s917539299,Accepted,"n = int(input()) +s = input() + +for i in s: + if ord(i) + n > 90: + print(chr(ord(i) + n - 91 + 65), end='') + else: + print(chr(ord(i) + n), end='')" +p03328,s550497520,Accepted,"icase=0 +if icase==0: + a,b=map(int,input().split()) + n=b-a-1 + print(n*(n+1)//2-a) + " +p03281,s871708013,Wrong Answer,"N = int(input()) + + +## 約数の列挙O(√N) +def divisor(n): #nの約数を全て求める + i = 1 + table = [] + while i * i <= n: + if n%i == 0: + table.append(i) + table.append(n//i) + i += 1 + table = list(set(table)) + return len(table) + +i = 1 +answer = 0 +while i < N: + if divisor(i) == 8: + answer += 1 + i += 2 +print(answer) + " +p03759,s246943569,Wrong Answer,"a, b, c = map(int,input().split()) +print('YES') if a == b == c else print('NO') +" +p03624,s760573446,Wrong Answer,"import collections +S=sorted(str(input())) +#print(*S) +A=[] +L = collections.Counter(S) +values, counts = zip(*L.most_common()) +for i in range(len(values)): + A.append(values[i]) +A.sort() + +x=0 +for i in range(len(A)): + if ord(A[i])!=i+97: + x=i+97 + break + +print(chr(i+97) if x!=0 else ""None"")" +p03711,s798764168,Wrong Answer," +x,y = map(int,input().split()) + +a = [1,3,5,7,8,10,12] +b = [4,6,9,11] + +if x in a and y in a: + print(""Yes"") +elif x in b and y in a: + print(""Yes"") +else: + print(""No"") +" +p04029,s943332556,Accepted,"n = int(input()) +if n == 1: + print(n) +else: + print(int(n * (n + 1) / 2)) +" +p02725,s561776317,Wrong Answer,"K,N = map(int,input().split()) +li = list(map(int,input().split())) +le = [] +for i in range(N): + if i==N-1: + le.append(K-li[i]) + else: + le.append(abs(li[i]-li[i+1])) +print(sum(le)-max(le))" +p03778,s415227911,Accepted,"w,a,b = map(int, input().split()) +print(max(0,b-(a+w),a-(b+w)))" +p02596,s208299747,Accepted,"K = input() +K = int(K) + +def seven(): + seven_i = 0 + count = 0 + for i in range(K): + seven_i = ((10*seven_i) + 7) % K + count += 1 + if seven_i % K == 0: + return count + return -1 + +print(seven())" +p03386,s681870316,Accepted,"a, b, k = map(int,input().split()) +ans = [] +if 2*k >= b-a+1: + ans = list(range(a,b+1)) + +else: + for i in range(k): + ans.append(a+i) + for i in range(k): + ans.append(b-k+i+1) + +for i in range(len(ans)): + print(ans[i])" +p03779,s865946248,Accepted,"import sys +input = sys.stdin.readline + + +def main(): + x = int(input()) + total = 0 + i = 1 + cnt = 0 + while total < x: + total += i + i += 1 + cnt += 1 + print(cnt) + +if __name__ == '__main__': + main()" +p03323,s866182729,Wrong Answer,"a,b=map(int,input().split()) +if a-b<=1: + print('Yay!') +else: + print(':(')" +p02598,s644552955,Wrong Answer,"n,k=map(int,input().split()) +a=list(map(int,input().split())) +a.sort() +l=1 +r=a[-1] +while r-l>1: + cnt=0 + m=(l+r)//2 + #print(""l,m,r"",l,m,r) + for i in a: + cnt+=(i-1)//m + if cnt<=k: + r=m + else: + l=m +print(r)" +p03624,s421406013,Accepted,"import string +alphabet = set(list(string.ascii_lowercase)) +s = set(input()) +rest = sorted(alphabet - s) + +ans = rest[0] if rest else 'None' + +print(ans)" +p03557,s504529097,Wrong Answer,"N = int(input()) +A = [int(i) for i in input().split()] +B = [int(i) for i in input().split()] +C = [int(i) for i in input().split()] + + +A.sort() +B.sort() +C.sort() + +import bisect +ans = 0 + +a2b = [] +b2c = [] +for c in C: + b_bisect = bisect.bisect_right(B, c) + a2b.append(b_bisect) + +for b in B: + a_bisect = bisect.bisect_right(A, b) + b2c.append(a_bisect) + +for i, j in zip(a2b, b2c): + ans += i*j +print(ans)" +p02688,s612978709,Accepted,"N, K = map(int, input().split()) +A = [] + +for _ in range(K): + d = input() + tmp = list(map(int, input().split())) + for i in tmp: + A.append(i) + +B = set(A) +print(N - len(B))" +p03543,s320998246,Wrong Answer,"N = input() +cnt =0 +for i in range(3): + if N[i]==N[i+1]: + cnt += 1 + +if cnt>=2: + print('Yes') +else: + print('No')" +p03435,s372320717,Accepted,"with open(0) as f: + C = [list(map(int, line.split())) for line in f.readlines()] +b = [(C[i][1]-C[i][0], C[i][2]-C[i][1]) for i in range(3)] +a = [(C[1][j]-C[0][j], C[2][j]-C[1][j]) for j in range(3)] +print('Yes' if a[0]==a[1]==a[2] and b[0]==b[1]==b[2] else 'No')" +p02783,s195533536,Wrong Answer,"h , a = map(int , input().split()) + +print(h // a + 1)" +p03071,s140174258,Accepted,"A, B = map(int, input().split()) + +list = [(2*A-1), (A+B), (2*B-1)] + +print(max(list))" +p02989,s652657535,Wrong Answer,"n = int(input()) +d = sorted(list(map(int, input().split()))) + +print(d) + +if d[n//2-1] == d[n//2]: + print(0) +else: + print(d[n//2] - d[n//2-1])" +p02912,s140529367,Accepted,"import heapq + +n, m = map(int, input().split()) +a = list(map(int, input().split())) +a = list(map(lambda x: x * (-1), a)) + +heapq.heapify(a) +for i in range(m): + x = heapq.heappop(a) + heapq.heappush(a, (-1) * (-x // 2)) + +print(-sum(a))" +p02688,s916737479,Wrong Answer,"whatMan = [] + +N, K = input().split() +for i in range(int(K)): + print(input().split())" +p03474,s289951606,Accepted,"A, B = map(int, input().split()) +S = input() + +match = True +for i in range(A+B+1): + if i == A: + if S[i] != ""-"": + print(""No"") + match = False + break + else: + if S[i] not in [""1"", ""2"", ""3"", ""4"", ""5"", ""6"", ""7"", ""8"", ""9"", ""0""]: + print(""No"") + match = False + break + +if match: + print(""Yes"")" +p02600,s364150124,Accepted,"#!/usr/bin/env python3 + +def rating(X): + if X <= 599: return 8 + if X <= 799: return 7 + if X <= 999: return 6 + if X <= 1199: return 5 + if X <= 1399: return 4 + if X <= 1599: return 3 + if X <= 1799: return 2 + if X <= 1999: return 1 + + assert(False) + + +X = int(input()) +print(rating(X))" +p03371,s375802187,Accepted,"a,b,c,x,y=map(int,input().split()) +r=float('inf') +for i in range((10**5)+1): + r=min(r,i*2*c+max(0,x-i)*a+max(0,y-i)*b) +print(r)" +p02631,s254984085,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=[] +s=0 +for aa in a: + s^=aa +for aa in a: + b.append(s^aa) +print(*b)" +p02922,s812973401,Accepted,"A, B = map(int,input().split()) +out = 1 +ans = 0 + +while out < B: + out += A-1 + ans += 1 + +print(ans)" +p03324,s238260990,Accepted,"def main(): + import sys + input = sys.stdin.readline + D, N = map(int, input().split()) + if N != 100: + print(N, end="""") + for i in range(D): + print(""00"", end="""") + print("""") + else: + print(100 ** (D+1) + 100 ** D) + +if __name__ == '__main__': + main()" +p03544,s206833643,Accepted,"N = int(input()) + +L0 = 2 +L1 = 1 +if N == 1: + print(L1) + exit() +for _ in range(N - 1): + L = L0 + L1 + L0 = L1 + L1 = L + +print(L)" +p03319,s825922980,Accepted,"def main(): + from math import ceil + + N, K = map(int, input().split()) + *a, = map(int, input().split()) + + ans = ceil((N - K) / (K - 1)) + 1 + print(ans) + + +if __name__ == '__main__': + main() + +# import sys +# +# sys.setrecursionlimit(10 ** 7) +# +# input = sys.stdin.readline +# rstrip() +# int(input()) +# map(int, input().split()) +" +p03289,s328372341,Accepted,"s = input() +if s[0]==""A"": + checker = 0 + for i in range(2, len(s)-1): + if s[i] ==""C"": + checker += 1 + if checker == 1: + checker = 0 + for i in range(len(s)): + if ord(s[i])<97: + checker += 1 + if checker == 2: + print(""AC"") + else: + print(""WA"") + else: + print(""WA"") +else: + print(""WA"")" +p03286,s247647501,Wrong Answer,"n = int(input()) + +s = '' +while(n != 0): + s = str(n % 2)+s + n = -(n//2) +print(s) +" +p02860,s544576556,Wrong Answer,"N = int(input()) +S = input() +n = int(N/2) - 1 +if len(S) % 2 == 1: + print('No') +else: + for i in range(n): + if S[i] == S[i + int(N/2)]: + print('Yes') + exit(0) + print('No')" +p03607,s629210255,Accepted,"def main(): + n=int(input()) + a=sorted([int(input()) for _ in [0]*n]) + a.append(0) + a=tuple(a) + cnt,x,ans=0,a[0],0 + for i in a: + if x==i: + cnt+=1 + else: + ans+=1 if cnt%2==1 else 0 + cnt,x=1,i + print(ans) +if __name__=='__main__': + main()" +p02706,s976408912,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) + +total = sum(A) +if N < total: + print(-1) +else: + print(N-total)" +p03433,s740516520,Accepted,"n = int(input()) +a = int(input()) +if n%500 <= a: + print(""Yes"") +else: + print(""No"")" +p03408,s307641398,Wrong Answer,"N = int(input()) +ls1 = [] +ls2 = [] +ls3 = [] +ans = [] +for i in range(N): + s = input() + ls1.append(s) + ls3.append(s) +M = int(input()) +for j in range(M): + t = input() + ls2.append(t) + ls3.append(t) +k = set(ls3) +p = list(k) +for i in range(len(p)): + ans.append(ls1.count(p[i])-ls2.count(p[i])) +print(max(ans))" +p02838,s562929689,Accepted,"import sys,math,collections,itertools +input = sys.stdin.readline + +N = int(input()) +A = list(map(int,input().split())) +m = 10**9+7 +sumA = 0 +for i in range(60): + cnt1 = 0 + for a in A: + if a>>i & 1: + cnt1 += 1 + sumA += (cnt1*(N-cnt1)*2**i)%m +print(sumA%m) +" +p03419,s568232104,Accepted,"N, M = map(int, input().split()) + +def solve(N,M): + if N==1 and M==1: + return 1 + if N==1: + return M-2 + if M==1: + return N-2 + ans = (N-2)*(M-2) + return ans +print(solve(N,M))" +p03286,s068001254,Accepted,"N = int(input()) +ans = [] +while N != 0: + if N % 2 != 0: + N -= 1 + ans.append(""1"") + else: + ans.append(""0"") + N //= -2 + +if ans: + print("""".join(reversed(ans))) +else: + print(""0"")" +p02612,s189286708,Wrong Answer,"n = int(input()) +print(n%1000)" +p02660,s628744994,Accepted,"import collections +def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + +N = int(input()) + +if N == 1: + print(0) + exit() + +c = collections.Counter(prime_factorize(N)) + +ans = 0 +for m in c.values(): + n = 1 + while (n*(n+1))//2 <= m: + ans += 1 + n += 1 +print(ans) +" +p03637,s829424109,Accepted,"N = int(input()) +nums = list(map(int, input().split())) + +d4 = 0 +d2 = 0 +d0 = 0 +for n in nums: + if n % 4 == 0: + d4 += 1 + elif n % 2== 0: + d2 += 1 + else: + d0 += 1 + +if d2 > 0 and d0 <= d4: + print('Yes') +elif d2 == 0 and d0 <= d4+1: + print('Yes') +else: + print('No')" +p02659,s310587797,Accepted,"in_ = list(input().split()) +A = int(in_[0]) +B = int(in_[1].replace(""."", """")) +ans = A * B +ans = ans // 100 +print(ans)" +p03043,s805305051,Wrong Answer,"import math +n,k = list(map(int, input().split())) +print(sum([(1/2)**math.ceil(math.log2(k/(i+1)))/n for i in range(n)]))" +p03943,s337867644,Accepted,"def main(): + import sys + input = sys.stdin.readline + sys.setrecursionlimit(10**7) + from collections import Counter, deque + #from collections import defaultdict + from itertools import combinations, permutations, accumulate, groupby, product + from bisect import bisect_left,bisect_right + from heapq import heapify, heappop, heappush + from math import floor, ceil + #from operator import itemgetter + + #inf = 10**17 + #mod = 10**9 + 7 + + a,b,c = map(int, input().split()) + if max(a,b,c) == a+b+c-max(a,b,c): + print('Yes') + else: + print('No') + +if __name__ == '__main__': + main()" +p03493,s341988613,Wrong Answer,"import numpy as np + +s_list = [int(i) for i in list(input())] +ans = np.count_nonzero(s_list!=0) + +print(ans)" +p03210,s218091971,Accepted,"x = int(input()) + +if x == 3 or x == 5 or x == 7: + print(""YES"") +else: + print(""NO"")" +p02665,s903742884,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = [0 for i in range(N+1)] +S = sum(A) +B[0]=1 +flag=1 +if A[0]>1 : + flag=0 +if A[0]>0 and N>0: + flag=0 + +for i in range(N): + if flag==0: + break + + S = S-A[i] + + if 2*(B[i]-A[i])=z[0]: + print(""YES"") +else: + print(""NO"") + + +" +p03387,s935441729,Accepted,"a, b, c = map(int, input().split()) +m = max([a, b, c]) +print((m * 3 - (a + b + c)) // 2 if (a + b + c) % 2 == (m * 3) % 2 else ((m + 1) * 3 - (a + b + c)) // 2)" +p03862,s068669451,Accepted,"n, x = map(int, input().split()) +a = list(map(int, input().split())) + +ans = 0 +p = 0 + +for ai in a: + if p + ai > x: + d = p + ai - x + ans += d + p = ai - d + else: + p=ai + +print(ans) +" +p02843,s448714894,Accepted,"X=int(input()) +d,m=divmod(X,100) +print(1 if m<=(d*5) else 0)" +p02791,s348944164,Wrong Answer,"n = int(input()) +p = list(map(int, input().split())) + +mins=[0]*n +mins[0]=p[0] +for i in range(0,n): + mins[i] = min(p[i-1], p[i]) +ans=1 +for i in range(1, n): + if p[i] <= mins[i]: + ans+=1 + +print(ans)" +p02602,s055857293,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) +seiseki = [] + +for i in range(N - K): + if A[i] < A[i + K]: + print(""Yes"") + else: + print(""No"")" +p02935,s728231597,Wrong Answer,"n=int(input()) +v=[] +v+=list(map(int,input().split())) +v.sort() +l=len(v) +result=v[0]/(2**(l-1)) +for i in range(1,n): + result=result+v[i]/(2**(l-i)) +print(int(result))" +p03087,s609250204,Accepted,"n, q = map(int, input().split()) +s = input() +tmp = [0 for i in range(len(s))] +for i in range(len(s)-1): + if s[i] == ""A"" and s[i+1] == ""C"": + tmp[i] = 1 + +ans = [0 for i in range(len(s)+1)] +for i in range(1, len(ans)): + ans[i] = ans[i-1] + tmp[i-1] + +for i in range(q): + l, r = map(int, input().split()) + count = 0 + print(ans[r-1] - ans[l-1]) + + + + +" +p02935,s815327665,Accepted,"N = int(input()) +v = list(map(int, input().split())) +v.sort() + +ans = v[0] +for i in v[1:]: + ans += i + ans /= 2 +print(ans) +" +p03543,s424921304,Accepted,"n = input() +if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]: + print('Yes') +else: + print('No')" +p03679,s650145250,Wrong Answer,"a,b,c = map(int,input().split()) +print(""delicious"" if b>=c else ""safe"" if c-b-1<=a else ""dangerous"")" +p02983,s264909890,Accepted,"L, R = map(int, input().split()) +ama=[] +for i in range(L,R+1): + amari = i%2019 + if amari ==0: + print(amari) + exit() +minimi = 2019 +for j in range(L,R+1): + for s in range(j+1,R+1): + waka = (j*s)%2019 + minimi = min(minimi,waka) +print(minimi)" +p02612,s600133440,Accepted,"price = int(input()) +if price % 1000 == 0: + print(0) +else: + print(1000-(price%1000)) +" +p02723,s107201273,Wrong Answer,"s = input() +if s[2] == s[3] or s[4] == s[5]: + print('Yes') +else: + print('No')" +p03785,s366366731,Wrong Answer,"N, C, K = map(int, input().split()) +T = [] + +for n in range(N): + l = int(input()) + T.append(l) + +T.sort() + +ans = 0 +V = C # current vacancies + +for i in range(N-1): + if T[i] + K >= T[i+1]: + V -= 1 + else: + ans += 1 + V = C + + if V == 0: + ans += 1 + V = C + else: + pass + +ans += 1 + +print(ans)" +p02792,s648771506,Accepted,"n = int(input()) +letters_mapping = {num: {num2:[] for num2 in range(10)} for num in range(10)} + +for num in range(1, n + 1): + first_letter = str(num)[0] + last_letter = str(num)[-1] + letters_mapping[int(first_letter)][int(last_letter)].append(num) + +count = 0 +for i, v in letters_mapping.items(): + for j, x in letters_mapping[i].items(): + for num in letters_mapping[i][j]: + count += len(letters_mapping[j][i]) + +print(count) " +p02866,s702098677,Accepted,"N = int(input()) +*D, = map(int, input().split()) +MOD = 998244353 + +import collections +dic = collections.Counter(D) + +flag = 1 if dic[0] != 1 or D[0] != 0 else 0 +ans = 1 +for d in range(1, max(D)+1): + ans *= pow(dic[d-1], dic[d], MOD) + ans %= MOD + +if flag: + print(0) +else: + print(ans)" +p03672,s763809131,Accepted,"S=input() +L=len(S) + +for i in range(2,L,2): + #print(S[0:(L-i)//2], S[(L-i)//2:(L-i)]) + if S[0:(L-i)//2]==S[(L-i)//2:(L-i)]: + print(L-i) + break" +p03351,s817926465,Wrong Answer,"a,b,c,d=map(int,input().split()) + +while True: + if abs(a-b)>d: + print('No') + break + if abs(b-c)>d: + print('No') + break + else: + print('Yes') + break" +p02963,s683582060,Wrong Answer,"S = int(input()) + +x1,y1 = 0,0 +x2 = 10**9 +y2 =1 +y3,x3 = divmod(S,x2) + +for a in [x1,x2,x3,y1,y2,y3]: + if a == y3: + print(a) + else: + print(a,end="" "")" +p02989,s827647643,Accepted,"N=int(input()) +d=list(map(int,input().split())) +d.sort() +if d[N//2 -1]==d[N//2]: + print(0) +else: + ans=d[N//2]-d[N//2 -1] + print(ans)" +p03478,s577686808,Wrong Answer,"N,A,B = map(int,input().split()) + +ans =0 + +while N > 0: + n = N + t = 0 + + while n > 0: + t += n % 10 + n //= 10 + + if A <= t <= B: + ans += N + + N -= 1 +" +p02957,s286766555,Wrong Answer,"a,b=map(int,input().split()) +if (a+b)%2==0: + print(abs((a-b)/2)+min(a,b)) +else: + print(""IMPOSSIBLE"")" +p03472,s123307553,Accepted,"def main(): + from collections import deque + from math import ceil + n, h, *ab = map(int, open(0).read().split()) + a = ab[::2] + *b, = map(lambda x: -x, ab[1::2]) + c = a + b + c.sort(key=lambda x: abs(x), reverse=True) + + q = deque(c) + cnt = 0 + while h > 0: + cnt += 1 + x = q.popleft() + h -= abs(x) + if x > 0: + cnt += ceil(h / x) + break + + print(cnt) + + +if __name__ == '__main__': + main() +" +p04005,s575601331,Accepted,"a,b,c = map(int,input().split()) + +if a%2==0 or b%2==0 or c%2==0: + print(0) + +else: + mx = max(a,b,c) + print((a*b*c)//mx)" +p03371,s630469182,Accepted,"a, b, c, x, y = map(int, input().split()) + +ans = float(""inf"") +for i in range(0, max(2*x, 2*y)+1, 2): + na = 0 if x-i//2 < 0 else x-i//2 + nb = 0 if y-i//2 < 0 else y-i//2 + ans = min(ans, c*i + a*na + b*nb) + +print(ans) +" +p02724,s364799857,Accepted,"x=int(input()) +print(x//500*1000+x%500//5*5)" +p03419,s694479860,Accepted,"#ARC091-C +a,b = map(int,input().split()) +n,m = max(a,b),min(a,b) + +if n <= 1: + result = 1 +elif m <= 1: + result = n - 2 +else: + result = (m-2)*(n-2) + +print(result)" +p02596,s322659492,Accepted,"k=int(input()) +num=7%k +for i in range(1, 10**6+1): + if num%k==0: + print(i) + exit() + else: + num=(10*num+7)%k +print(-1) + + +" +p02755,s065137057,Wrong Answer,"a,b = map(float,input().split()) +a_base_min = int(a * 25 /2) +a_base_max = int((a+1)*25/2) +b_base_min = int(b *10) +b_base_max = int((b+1) *10) + +if (b_base_min <= a_base_min) and (a_base_min <= b_base_max): + print(int(a_base_min)) +elif (a_base_min < b_base_min) and (b_base_min <= a_base_max): + print(int(b_base_min)) +else: + print(-1)" +p02790,s879914226,Accepted,"a, b = map(str, input().split()) +print(min (a * int(b), b * int(a)))" +p02873,s626495690,Accepted,"S = list(input()) +ls = len(S) + +a = [0] * (len(S) + 1) + + +for i in range(ls): + if S[i] == ""<"": + a[i + 1] = max(a[i + 1], a[i] + 1) + +for i in range(ls - 1, -1, -1): + if S[i] == "">"": + a[i] = max(a[i], a[i + 1] + 1) + +print(sum(a))" +p02633,s182805593,Wrong Answer,"from math import ceil +x=int(input()) +print(ceil(360//x)) +" +p03386,s746383119,Wrong Answer,"a, b, k = map(int, input().split()) +l = [i for i in range(a, b+1)] + +for i in set(l[-k:] +l[:k]): + print(i)" +p02993,s186787757,Accepted,"S = input() +if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]: + print('Bad') +else: + print('Good')" +p03059,s537370021,Accepted,"a, b, t = map(int, input().split()) +print(t//a*b) +" +p02572,s106137971,Accepted,"n = int(input()) +a = list(map(int, input().split())) +mod = pow(10, 9) + 7 +s = sum(a) % mod +ans = s * s % mod +for i in a: + ans -= i * i + ans %= mod +ans = ans * pow(2, mod - 2, mod) % mod +print(ans)" +p02665,s231350680,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +from itertools import accumulate + +n = int(readline()) +a = list(map(int, readline().split())) +cumsum = list(accumulate(a[::-1])) +ans = 0 +check = 1 +for aa, v in zip(a, cumsum[::-1]): + if aa > check: + print(-1) + exit() + else: + ans += min(check, v) + check -= aa + check *= 2 +print(ans) +" +p03282,s739882114,Accepted,"def resolve(): + S = input() + K = int(input()) + for i in range(K): + if S[i] != ""1"": + print(S[i]) + exit() + print(""1"") +resolve()" +p02973,s369183559,Accepted,"from sys import * +from bisect import * + +n = int(input()) +a = list(map(int, stdin.readlines())) + +dp = [1] +for j in a: + j *= -1 + i = bisect(dp, j) + if i < len(dp): + dp[i] = j + else: + dp.append(j) +print(len(dp))" +p02689,s034549992,Accepted,"n, m = map(int, input().split()) +h = list(map(int, input().split())) +edges = [tuple(map(int, input().split())) for _ in range(m)] + +good_obs = [True] * n +for a, b in edges: + if h[a - 1] >= h[b - 1]: + good_obs[b - 1] = False + if h[a - 1] <= h[b - 1]: + good_obs[a - 1] = False +print(sum(good_obs)) +" +p03645,s611906474,Accepted,"n, m = map(int, input().split()) + +root = [[] for i in range(n + 1)] +for i in range(m): + a, b = map(int, input().split()) + root[a].append(b) + root[b].append(a) + +ans = 'IMPOSSIBLE' +for x in root[n]: + if 1 in root[x]: + ans = 'POSSIBLE' + break + +print(ans)" +p02842,s837902613,Wrong Answer,"import math +a = int(input()) +for i in range(a): + if math.floor(i*1.08) == a: + print(i) + exit() +print("":("")" +p02817,s166676237,Wrong Answer,print(''.join(input().split())) +p03042,s290966487,Accepted,"# 初期入力 +import sys +input = sys.stdin.readline +S =input().strip() + +s12 =int(S[:2]) +s34 =int(S[2:]) +mm=[1,2,3,4,5,6,7,8,9,10,11,12] +yy=[i for i in range(100)] +if s12 in yy and s12 in mm and s34 in yy and s34 in mm: + print(""AMBIGUOUS"") +elif s12 in yy and s34 in mm: + print(""YYMM"") +elif s12 in mm and s34 in yy : + print(""MMYY"") +else: + print(""NA"") +" +p02784,s755378001,Accepted,"h,n = map(int,input().split()) +a = list(map(int,input().split())) +k = sum(a) +if k>=h: + print(""Yes"") +else: + print(""No"")" +p02621,s053832079,Wrong Answer,"n=int(input(""enter no"")) +print(n+n*n+n*n*n)" +p03645,s825718506,Accepted,"n, m = map(int, input().split()) +a = [list(map(int, input().split())) for _ in range(m)] + +# n, m = 3, 2 +# a = [[1, 2], [2, 3]] + +pot_starts = [] +pot_ends = [] + +for i in a: + if i[0] == 1: + pot_starts.append(i[1]) + elif i[1] == n: + pot_ends.append(i[0]) + +if set(pot_starts).intersection(pot_ends): + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"")" +p03657,s341417100,Accepted,"a,b=map(int,input().split()) +ans=[a%3,b%3,(a+b)%3] +if 0 in ans: + print(""Possible"") +else: + print(""Impossible"")" +p02694,s900906276,Accepted,"import math +x = int(input()) +i = 1 +sum = 100 +while True: + sum = math.floor(sum * 1.01) + if x <= sum: + break + i += 1 +print(i)" +p03852,s772977884,Accepted,"l = ['a', 'e', 'i', 'o', 'u'] +c = input() +if (c in l) == True: + print('vowel') +else: + print('consonant')" +p02775,s683707643,Accepted,"S = input() +L = len(S) + +dp = [[0 for _ in range(L + 1)] for over in range(2)] +dp[0][0] = 0 +dp[1][0] = 1 + +for j, s in enumerate(S, 1): + n = int(s) + dp[0][j] = min(dp[0][j - 1] + n, dp[1][j - 1] + (10 - n)) + dp[1][j] = min(dp[0][j - 1] + (n + 1), dp[1][j - 1] + (10 - n - 1)) + +print(dp[0][-1])" +p04019,s255032560,Wrong Answer,"# import collections +S = input() +# CS = collections.Counter(S) +# print(CS) +cn = S.count('N') +ce = S.count('E') +cs = S.count('S') +cw = S.count('W') +if cn > 1 and cs > 1 and ce < 0 and cw < 0: + print('Yes') +elif cn < 0 and cs < 0 and ce > 1 and cw > 1: + print('Yes') +elif cn > 1 and cs > 1 and ce > 1 and cw > 1: + print('Yes') +else: + print('No') +" +p03274,s561584762,Wrong Answer,"n, k = map(int, input().split()) +x = list(map(int, input().split())) +ans = 10 ** 8 +ok = True +for i in range(n-k+1): + a = 0 + for j in range(k): + if not ok and x[i+j] < 0: continue + elif not ok and x[i+j] > 0: + a *= 2 + ok =True + if x[i] < 0 and a == 0: + ok = False + a += abs(x[i]) + if ok and j == k-1: + a += x[i+j] + if ans > a: ans = a +print(ans)" +p03998,s848013273,Accepted,"from sys import stdin + +def S(): return stdin.readline().rstrip() +def I(): return int(stdin.readline().rstrip()) +def LS(): return list(stdin.readline().rstrip().split()) +def LI(): return list(map(int,stdin.readline().rstrip().split())) + +sa,sb,sc = [list(S()) for i in range(3)] + +f = sa.pop(0) +l = {'a':sa, 'b':sb, 'c':sc} +p = {'a':'A', 'b':'B', 'c':'C'} +while True: + if 0 < len(l.get(f)): + f = l.get(f).pop(0) + else: + break + +print(p.get(f))" +p03408,s252581021,Wrong Answer,"import collections +n = int(input()) +s = [input() for _ in range(n)] +m = int(input()) +t = [input() for _ in range(m)] + +c = collections.Counter(s).most_common() +C = [] +for i in range(len(c)): + C.append([c[i][0], c[i][1]]) + +ans = [] +for j in range(len(C)): + if C[j][0] in t: + C[j][1] -= t.count(C[j][0]) + ans.append(C[j][1]) + +print(max(ans))" +p03339,s583151670,Accepted,"def solve(): + N = int(input()) + S = input() + attention = sum(s != 'W' for s in S[1:]) + min_val = attention + # print(min_val) + for i in range(1,N): + if S[i] == 'E': attention -= 1 + if S[i-1] != 'E': + attention += 1 + # print(attention) + min_val = min(min_val, attention) + + # print('---') + print(min_val) + +solve()" +p02860,s458386014,Wrong Answer,"N = int(input()) +S = input() +if N // 2 != 0: + print('No') +else: + letter = S[1:1+N//2] + if S == letter + letter: + print('Yes') + else: + print('No') + " +p02795,s219981672,Accepted,"import math + +H=int(input()) +W=int(input()) +N=int(input()) + +if W>H : + if N%W==0: + k=N/W + else: + k=math.ceil(N/W) +else: + if N%H==0: + k=N/H + else: + k=math.ceil(N/H) + +k=int(k) +print(k)" +p02848,s245971282,Accepted,"#A=65, Z=90 +N=int(input()) +S=input() +for i in range(len(S)): + print(chr((ord(S[i])-65+N)%26+65),end="""") +print()" +p03289,s300194108,Accepted,"import string + +S = input() +re_S = set(S)-set(""AC"") +bl = S[0] == ""A"" +bl &= (S[2:-1].count(""C"") == 1) +bl &= (re_S <= set(string.ascii_lowercase )) + +print(""AC"" if bl else ""WA"") + +" +p02552,s597682207,Wrong Answer,"x = int(input()) +ans = 1 if x == 0 else 1 + +print(ans)" +p02687,s153286784,Wrong Answer,print('A%sC'%'BR'[id(id)%9%2]) +p02583,s499072031,Accepted,"N = int(input()) +L = list(map(int, input().split())) + +res = 0 +for i in range(N): + for j in range(i+1, N): + for k in range(j+1, N): + tmp = sorted([L[i], L[j], L[k]]) + if tmp[0] < tmp[1] < tmp[2] and (tmp[0] + tmp[1]) > tmp[2]: + res += 1 +print(res) +" +p02640,s017252182,Accepted,"x,y = map(int,input().split()) + +tsuru = (4 * x - y) // 2 +kame = x - tsuru + +if (4 * kame) + (2 * tsuru) == y and kame >= 0 and tsuru >= 0: + print(""Yes"") +else: + print(""No"")" +p03548,s260559228,Wrong Answer,"a , b , c = map(int, input().split()) +m = a % (b+c) +ans = a // (b+c) +if m > 0: + print(ans) +else: + print(ans-1) +" +p03127,s628922506,Accepted,"n = int(input()) +A = list(map(int,input().split())) +from fractions import gcd +ans = A[0] +for a in A[1:]: + ans = gcd(ans,a) +print(ans)" +p03773,s112198968,Accepted,"A, B = map(int,input().split()) +print((A+B)%24)" +p03611,s892900901,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +c = [0]*(max(a)+1) +max_num = 0 +for i in a: + c[i] += 1 +for x in range(max(a)-1): + if max_num < (c[x] + c[x+1] + c[x+2]): + max_num = (c[x] + c[x+1] + c[x+2]) +print(max_num) +" +p02691,s672315912,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = 0 +b = {} +for i in range(n): + l = a[i] + (i+1) + r = (i+1) - a[i] + if r in b: + ans += b[r] + if l in b: + b[l] += 1 + else: + b[l] = 1 + +print(ans)" +p02729,s038491504,Accepted,"N,M = map(int,input().split()) + + + + +print(int(N*(N-1)/2 + M*(M-1)/2))" +p02612,s566710250,Wrong Answer,"N = int(input()) +print(N%1000)" +p02618,s926729464,Accepted,for i in range(365):print((19-i)%26+1) +p03076,s347992223,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +orders = sorted([a, b, c, d, e], key=lambda x: 10 if x % 10 == 0 else x % 10, reverse=True) +total = 0 +for o in orders[:-1]: + total += ((o + 9) // 10) * 10 +total += orders[-1] +print(total) +" +p03943,s658871052,Wrong Answer,"a,b,c=map(int,input().split()) +Lis=[a,b,c] +sorted(Lis) +if a==b+c: + print(""Yes"") +else: + print(""No"")" +p03617,s746497460,Accepted,"a,b,c,d=map(int,input().split()) +n=int(input()) + +twoval=min(8*a,4*a+2*b,4*b,2*b+c,2*c,d) +oneval=min(4*a,2*b,2*a+b,c) + +if n%2==0: + print(twoval*(n//2)) +else: + print(oneval+twoval*((n-1)//2)) + +" +p03719,s806765250,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10 ** 8) +INF = float('inf') +MOD = 10 ** 9 + 7 + + +def main(): + A, B, C = map(int, readline().split()) + if A<=C<=B: + print('Yes') + else: + print('No') + + +if __name__ == '__main__': + main() +" +p03698,s102044506,Wrong Answer,"s=input() +w=set() +for i in range(len(s)): + w.add(s[i]) +if len(s)==len(w): + print(""Yes"") +else: + print(""No"")" +p02729,s952268208,Accepted,"#!/usr/bin/env python3 +from math import factorial +def com(n,r): + if nn): + print((i-1)**2) + quit()" +p03264,s504413993,Accepted,"N = int(input()) + +E = N//2 +O = N//2 + N%2 + +print(E*O) +" +p02597,s340644540,Accepted,"n = int(input()) +s = input() +i = 0 +j = len(s)-1 +count = 0 +while i 1: + print(0) +elif abs(a-b) == 1: + print(math.factorial(a)*math.factorial(b) %MOD) +else: + print(((math.factorial(a)**2)*2 %MOD))" +p02866,s140279275,Accepted,"from collections import Counter +mod=998244353 +n=int(input()) +D=list(map(int,input().split())) +Count=Counter(D) +if D[0]!=0 or Count[0]!=1:print(0);exit() + +ans=1 +for i in range(1,max(D)+1): + ans *=Count[i-1]**Count[i] + ans %=mod +print(ans)" +p02882,s895193609,Accepted,"from math import atan2, degrees + +a, b, x = map(int, input().split()) + +if a * a * b / 2 >= x: + c = 2 * x / a / b + print(degrees(atan2(b, c))) +else: + c = 2 * x / a / a - b + print(degrees(atan2(b - c, a))) +" +p02813,s710228977,Accepted,"from itertools import permutations + + +def solve(string): + n, *pq = map(int, string.split()) + *ps, = permutations(range(1, n + 1)) + return str(abs(ps.index(tuple(pq[n:])) - ps.index(tuple(pq[:n])))) + + +if __name__ == '__main__': + import sys + print(solve(sys.stdin.read().strip())) +" +p03162,s233591083,Accepted,"n = int(input()) +dp = [0, 0, 0] +for i in range(n): + todo = list(map(int, input().split())) + ndp = [0, 0, 0] + ndp[0] = max(dp[1], dp[2]) + todo[0] + ndp[1] = max(dp[0], dp[2]) + todo[1] + ndp[2] = max(dp[0], dp[1]) + todo[2] + dp = ndp +print(max(ndp))" +p03944,s933816021,Wrong Answer,"w, h, n = map(int, input().split()) +area = [0, 0, w, h] +for i in range(n): + x, y, a = map(int, input().split()) + if a == 1: + area[0] = x + elif a == 2: + area[2] = x + elif a == 3: + area[1] = y + else : + area[3] = y +print((area[2]-area[0]) * (area[3] - area[1]) if (area[2]-area[0]) * (area[3] - area[1]) > 0 else 0)" +p02848,s135610874,Accepted,"N=int(input()) +S=input() +a=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] +ans='' +for i in (S): + num=a.index(i)+N + if(num>25): + num-=26 + ans+=a[num] +print(ans)" +p02660,s608410029,Accepted,"from collections import Counter +N = int(input()) +factors = [] +i = 2 +while N > 1: + if N < i * i: + factors.append(N) + break + while N % i == 0: + factors.append(i) + N //= i + i += 1 + +ans = 0 +for count in Counter(factors).values(): + i = 1 + while count >= i: + count -= i + i += 1 + ans += 1 +print(ans) +" +p03971,s135147664,Wrong Answer,"N, A, B = map(int, input().split()) +S = input() + +num = 0 +num_b = 0 + +for i in range(N): + if S[i] == ""a"": + if num < A + B: + print(""Yes"") + num += 1 + else: + print(""No"") + elif S[i] == ""b"": + if num < A + B and num_b < B: + print(""Yes"") + num += 1 + num_b += 1 + else: + print(""Np"") + else: + print(""No"") +" +p02633,s139192248,Accepted,"x = int(input()) +for i in range(1, 361): + if x*i % 360 == 0: + print(i) + exit()" +p02553,s167651483,Wrong Answer,"li = list(map(int,input().split())) + +a = li[0] +b = li[1] +c = li[2] +d = li[3] + +ac = a * c +bc = b * c +ad = a * d +bd = a * d +result = ac +if result < bc: + result = bc +elif result < ad: + result = ad +elif result < bd: + result = bd +elif a < 0 and 0 < b and result < 0: + result = 0 +elif c < 0 and 0 < d and result < 0: + result = 0 +print(result)" +p03962,s733374040,Wrong Answer,"a, b, c = list(map(int, input().split())) +if a != b != c: + print(3) +elif a == b == c: + print(1) +else: + print(2) +" +p03986,s179923481,Accepted,"def main(): + #input data + import sys + input = lambda:sys.stdin.readline().strip() + S = input() + + #solve + N = len(S) + cnt=0 + ans=0 + for i in range(N): + if S[i]=='S': + cnt+=1 + else: + if cnt: + cnt-=1 + ans+=2 + print(N-ans) + + +if __name__=='__main__': + main()" +p02665,s576430883,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +ans=1 +count=1 +"""""" +for i in range(1,n+1): + ans+=count*2 + count*=2 +#print(ans) +"""""" +ans=1 +count=1 +now=1 +for i in range(n+1): + count=(count-a[i])*2 + if a[i]%2==1: + now=now*2-a[i]-1 + else: + now=now*2-a[i] + ans+=count + #print(count,ans,now) + +print(max(-1,ans))" +p02802,s036640835,Accepted,"N, M = map(int,input().split()) +accepted = [0]*N +wrong_ans =[0]*N +for i in range(M): + p,s = input().split() + p = int(p)-1 + if s ==""AC"": + accepted[p] = 1 + elif s == ""WA"" and accepted[p]==0: + wrong_ans[p] = wrong_ans[p]+1 + +AC = 0 +penalty = 0 +for i in range(N): + if accepted[i] == 1: + AC = AC+1 + if wrong_ans[i]>=1: + penalty = penalty+wrong_ans[i] +print(AC,penalty)" +p03131,s676888085,Accepted,"K, A, B = map(int, input().split()) + +ans = 1 +yen = 0 +if A+1 >= B: + print(K+1) + quit() +cycle = max(0, (K-(A-1))//2) +res = (K-(A-1)) % 2 +ans = cycle * (B-A) + A + res +print(ans)" +p03438,s084443796,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) + +sabun=[B[i]-A[i] for i in range(N)] + +print(""Yes"" if (sum([i for i in sabun if i>0])+sum([i for i in sabun if i<0])*2)>=0 else ""No"") +" +p02813,s678042093,Accepted,"import fractions +import itertools + +n=int(input()) +p=tuple(map(int,input().split())) +q=tuple(map(int,input().split())) + +anslist=list(itertools.permutations(range(1,n+1))) +print(abs(anslist.index(p)-anslist.index(q)))" +p03086,s433236667,Accepted,"s=input() +ans=0 +cur=0 +ACGT=[""A"",""C"",""G"",""T""] +for ss in s: + if ss in ACGT: + cur+=1 + else: + ans=max(cur,ans) + cur=0 +print(max(ans,cur)) + +" +p03329,s885710717,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def div(n, t): + if n < t: + return n + else: + return div(n // t, t) + n % t + + +def main(): + N = int(input()) + print(min(div(i, 6) + div(N - i, 9) for i in range(N + 1))) + + +if __name__ == ""__main__"": + main() +" +p02702,s775659228,Wrong Answer,"from itertools import combinations +s = input() +d = {} +tmp = 0 +i = 0 +for char in s[::-1]: + tmp += int(char) * pow(10, i, 2019) + tmp %= 2019 + if tmp not in d: + d[tmp] = 1 + else: + d[tmp] += 1 + i += 1 + +result = 0 +for num, v in d.items(): + if num == 0: + result += v + continue + if v > 1: + result += v * (v - 1) // 2 + +print(result) +" +p03774,s261159970,Accepted,"n, m = map(int, input().split()) +a, b = [0]*n, [0]*n +c, d = [0]*m, [0]*m +for i in range(n): + a[i], b[i] = map(int,input().split()) +for i in range(m): + c[i], d[i] = map(int,input().split()) + + +for i in range(n): + l = 10 ** 9 + for j in range(m): + if abs(a[i] - c[j]) + abs(b[i] - d[j]) < l: + l = abs(a[i] - c[j]) + abs(b[i] - d[j]) + idx = j + 1 + + print(idx)" +p03835,s028696803,Wrong Answer,"k,s = map(int,input().split()) +start = s//3 +ans = 0 +if s < k: + k = s + +for i in range(start,k+1): + for j in range(start,k+1): + for l in range(start,k+1): + if i+j+l == s: + ans += 1 +print(ans)" +p03852,s861098748,Accepted,"c = input() +if c in 'aeiou': + print('vowel') +else: + print('consonant')" +p03951,s552619455,Accepted,"n = int(input()) +s = input() +t = input() + +ans = n * 2 +for i in range(n): + if s[n - i - 1:] == t[:i + 1]: + ans = min(ans, n * 2 - (i + 1)) +print(ans) +" +p03331,s399215067,Wrong Answer,"N = int(input()) +ans = 10**10 +for i in range(1, N//2): + a = sum(map(int, str(i))) + b = sum(map(int, str(N-i))) + ans = min(a+b, ans) +print(ans)" +p03407,s368759204,Accepted,"a,b,c=map(int,raw_input().split()) +if a+b>=c: + print ""Yes"" +else: + print ""No""" +p03673,s457210938,Accepted,"n = int(input()) +l = list(map(int,input().split())) +if n%2==0: + a = l[1::2][::-1] + b = l[::2] + for i in a: + print(i,end=' ') + for j in b: + print(j,end=' ') + +else: + a = l[0::2][::-1] + b = l[1::2] + for i in a: + print(i,end=' ') + for j in b: + print(j,end=' ')" +p02629,s978824478,Accepted,"N = int(input()) +a = N%26 +next = int(N/26) +b = N%26 +next = int(N/26) +a=[] +answer=[] +for i in range(20): + if (N > 26) and (N%26)!=0: + a.append(N%26) + N = int(N/26) + elif (N > 26) and (N%26)==0: + a.append(26) + N = int((N-1)/26) + else: + a.append(N) + break +for i in range(len(a)): + answer.append(chr(ord('a')+a[i]-1)) +mojiretu = ' ' +for x in reversed(answer): + mojiretu += x +print(mojiretu)" +p03387,s747872646,Accepted,"a, b, c = map(int, input().split()) +L = [a, b, c] +L.sort() +ans = L[2]-L[1] +L[0] += ans +if L[0]%2 == L[2]%2: + ans += (L[2]-L[0])//2 +else: + ans += 1 + ans += (L[2]+1-L[0])//2 +print(ans) +" +p04029,s591733819,Accepted,"import sys +import math +def i():return int(sys.stdin.readline().replace(""\n"","""")) +def i2():return map(int,sys.stdin.readline().replace(""\n"","""").split()) +def s():return str(sys.stdin.readline().replace(""\n"","""")) +def l():return list(sys.stdin.readline().replace(""\n"","""")) +def intl():return [int(k) for k in sys.stdin.readline().replace(""\n"","""").split()] +def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace(""\n"","""").split())) +def t():return tuple(map(int,sys.stdin.readline().replace(""\n"","""").split())) + +if __name__ == ""__main__"":pass + +n = i() +a = [i for i in range(1,n+1)] +print(sum(a))" +p04020,s594395967,Accepted,"def solve(): + ans = 0 + N = int(input()) + A = [int(input()) for _ in range(N)] + rem = 0 + for i in range(N): + ans += (A[i]+rem)//2 + if A[i]>0: + rem = (A[i]+rem)%2 + else: + rem = 0 + return ans +print(solve())" +p04005,s408810856,Wrong Answer,"#from statistics import mean, median,variance,stdev +a,b,c=map(int, input().split()) + +x=min(a,b,c) +z=max(a,b,c) +if a==x and b==z: + y=c +if a==x and c==z: + y=b +if b==x and a==z: + y=c +if b==x and c==z: + y=a +if c==x and a==z: + y=b +if c==x and b==z: + y=a + +print(0 if z%2==0 else a*b)" +p02684,s602133000,Accepted,"n, k = map(int, input().split()) +a = [0] + list(map(int, input().split())) + +seen = [False] * (n+1) +visited = [] +nxt = 1 +cnt = 0 +while not seen[nxt] and cnt != k: + seen[nxt] = True + visited.append(nxt) + nxt = a[nxt] + cnt += 1 + +if cnt == k: + print(nxt) + exit() + +idx = visited.index(nxt) +print(visited[idx:][(k-idx)%(len(visited)-idx)]) +" +p02912,s387280968,Wrong Answer,"import heapq +n, m = map(int, input().split()) +lst = list(map(int, input().split())) +lst = list(map(lambda x: x*(-1), lst)) +heapq.heapify(lst) + +for i in range(m): + tmp_min = heapq.heappop(lst) + heapq.heappush(lst, tmp_min//2) # 計算誤差の関係で-1を2回かけてます +print(-sum(lst))" +p04033,s112115482,Wrong Answer,"a,b = map(int,input().split()) + +if a>0 and b>0: + print('Positive') +elif a<0 and b>0 : + print('Zero') +else: + print('Negative')" +p02813,s666519659,Accepted,"n = int(input()) +p = list(map(int,input().split())) +q = list(map(int,input().split())) +import itertools +i = 1 +for ptn in itertools.permutations(range(1,n+1)): + if list(ptn)==p: + a = i + if list(ptn)==q: + b = i + i += 1 +print(abs(a-b))" +p03951,s593430685,Accepted,"N=int(input()) +s=input() +t=input() +ans=2*N +for i in range(N): + A=s[:i]+t + if A[:N]==s: + ans=N+i + break +print(ans) +" +p03623,s736092700,Accepted,"x, a, b = map(int, input().split()) +if abs(x - a) < abs(x - b): + print(""A"") +else: + print(""B"")" +p03815,s647775914,Wrong Answer,"def main(): + x=int(input()) + s=2*(x//11) + t=x%11 + print(s if t<1 else s+1 if t<6 else s+2) +main()" +p03592,s945733727,Accepted,"import sys +readline = sys.stdin.readline + +N,M,K = map(int,readline().split()) + +for a in range(N + 1): + for b in range(M + 1): + if a * (M - b) + (N - a) * b == K: + print(""Yes"") + exit(0) +else: + print(""No"")" +p02613,s667665552,Accepted,"# -*- coding: utf-8 -*- +n=int(input()) +slist=[] +for i in range(n): + moji=str(input()) + slist.append(moji) +numdic={} +for chr in [""AC"",""WA"",""TLE"",""RE""]: + numdic[chr]=slist.count(chr) +for chr,val in numdic.items(): + print(chr,"" x "",val)" +p02639,s760212596,Accepted,"xs = input('').split(' ') + +for i in range(5): + x = int(xs[i]) + if x==0: + print(i+1) +" +p02624,s616533312,Accepted,"N = int(input()) + +ans = 0 + +for i in range(1,N+1): + s = N // i + g = (s * (s+1)) // 2 + ans += g * i +print(ans) + " +p02742,s478480779,Accepted,"import sys +input = sys.stdin.readline + +def main(): + h, w = map(int, input().split()) + + if h == 1 or w == 1: + print(1) + else: + print((h * w + 1) // 2) + +main() +" +p03331,s947366463,Accepted,"import math +N = int(input()) +n = N +amari = 0 +for i in range (len(str(N))): + amari += n % 10 + n = math.floor(n / 10) +if amari == 1: + print(10) +else: + print(amari) +" +p03042,s887562389,Accepted,"s = input() + +forward = s[:2] +backward = s[2:] +def check(s): + if 0 maxx or miny > maxy: + print(0) +else: + print((maxx-minx)*(maxy-miny)) +" +p02633,s125900830,Accepted,"x = int(input()) +for i in range(1,1000000): + if (i * x) % 360 == 0: + print(i) + exit()" +p02948,s894419135,Wrong Answer,"import heapq # heapqライブラリのimport +import sys +input = sys.stdin.readline +N,M=map(int,input().split()) +lst=[] +for i in range(N): + A,B=map(int,input().split()) + lst.append((A,-B)) +heapq.heapify(lst) # リストを優先度付きキューへ +ct=0 +noko=1 +ans=0 +while lst!=[]: + c=heapq.heappop(lst) + if c[0]>M: + break + elif noko>0 or c[0]>ct: + noko+=(-1+c[0]-ct) + ct=c[0] + ans+=c[1] +print(-ans)" +p03076,s612410072,Accepted,"l=[int(input()) for i in range(5)] + +diff=0 +num=0 +for i in l: + if i%10==0: + num+=i + else: + a=round(i+5,-1) + num+=a + diff=max(diff,a-i) + +print(num-diff)" +p03720,s335373313,Wrong Answer,"import numpy as np + +n, m = map(int, input().split(' ')) + +array = np.zeros(n) + +for i in range(m): + a, b = map(int, input().split(' ')) + array[a-1] += 1 + array[b-1] += 1 + +for number in array: + print(number)" +p03624,s128740223,Wrong Answer,"S=list(set(input())) +S.sort() +import string +A=list(string.ascii_lowercase) +for i in range(len(S)): + if not S[i]==A[i]: + print(A[i]) + break + else: + print(""None"")" +p02724,s670734884,Accepted,"def solve(): + X = int(input()) + n_500 = X // 500 + X -= n_500 * 500 + n_5 = X // 5 + + print(n_500 * 1000 + n_5 * 5) + +if __name__ == '__main__': + solve()" +p03067,s548996641,Accepted,"a, b, c = map(int, input().split()) +if a < c < b or b < c < a: + print(""Yes"") +else: + print(""No"")" +p02642,s223563987,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +cnt = 0 +cnt2 = 0 +for i in A: + for j in A: + if i != j: + if i%j == 0: + cnt += 1 + if i != j: + if cnt == 0: + cnt2 += 1 + cnt = 0 +print(cnt2) +" +p03041,s510294583,Accepted,"n,k = map(int,input().split()) +s = list(input()) + +s[k-1] = s[k-1].lower() +print(''.join(s))" +p02760,s698318361,Wrong Answer,"import numpy as np +A = [] +for i in range(3): + A.append(list(map(int, input().split()))) +A = np.array(A) + +N = int(input()) +B = [] +for j in range(N): + B.append(int(input())) + +res = np.array([int(i in B) for i in A.ravel()]).reshape(3, 3) +diag_sum = res[0 ,0] + res[1, 1] + res[2, 2] +diag_sum2 = res[0, 2] + res[1, 1] + res[2, 0] +if res.sum(axis=0).any() or res.sum(axis=1).any() or diag_sum == 3 or diag_sum2 == 3: + print('Yes') +else: + print('No') + + +" +p03220,s798530269,Accepted,"N = int(input()) +[T, A] = list(map(int, input().split())) +H = list(map(int, input().split())) +c = 0.006 +H_tem = [T - c*H[_] for _ in range(N)] +min_ans = float(""inf"") + +for i in range(len(H)): + ans = abs(A - H_tem[i]) + if ans < min_ans: + min_ans = ans + point = i+1 + +print(point)" +p02555,s148490703,Accepted,"s = int(input()) +MOD = 10**9 + 7 +C = [0]*(s + 1) +C[0] = 1 +for n in range(3, s+1): # n:[3,s] + C[n] = (C[n-1] + C[n-3]) % MOD +print(C[s]) +" +p02730,s980659451,Accepted,"S = input() + +a = S[:(len(S) - 1) // 2] +b = S[(len(S) - 1) // 2 + 1:] + +if a == b and a == a[::-1]: + print('Yes') +else: + print('No')" +p02829,s305945685,Wrong Answer,"A = int(input()) +B = int(input()) +c = [1,2,3] +c.remove(A) +c.remove(B) +print(c)" +p03437,s221061912,Wrong Answer,"X,Y=map(int,input().split()) +for i in range(2,Y): + if X*i%Y!=0: + print(X*i) + exit() +print(-1) +" +p03327,s944955104,Accepted,"n = int(input()) + +if n >= 1000: + print(""ABD"") +else: + print(""ABC"")" +p02772,s656126782,Accepted,"n=int(input()) +a=list(map(int,input().split())) +s=[i for i in a if i%2==0] +t=[i for i in s if i%3>0 and i%5>0] +print('APPROVED' if len(t)==0 else 'DENIED')" +p03481,s921021540,Wrong Answer,"import math + + +x, y = [int(w) for w in input().split()] + +l = math.log2(y/x) +print(1 + int(l)) +" +p03835,s961984789,Accepted,"k, s = [int(w) for w in input().split()] + +ans = 0 +for x in range(k+1): + for y in range(k+1): + if 0 <= s-x-y <= k: + ans += 1 + +print(ans) +" +p03035,s380723311,Accepted,"a,b=map(int,input().split()) +if a>=13: + print(b) +elif 6<=a<13: + print(b//2) +else: + print(0) + " +p03243,s574790306,Accepted,"n = int(input()) +while True: + s = str(n) + if s[0] == s[1] and s[0] == s[2]: + print(n) + break + n += 1" +p02835,s122406568,Wrong Answer,"list = list(map(int, input().split())) +if sum(list)<=22: + print(""bust"") +else: + print(""win"")" +p03487,s749578306,Accepted,"from collections import defaultdict +N=int(input()) +A=list(map(int,input().split())) +dic=defaultdict(int) +for i in range(0,N): + dic[A[i]]+=1 + +ans=0 +for key in dic.keys(): + if dic[key]>=key: + ans+=dic[key]-key + else: + ans+=dic[key] + +print(ans) +" +p03041,s453511891,Accepted,"n, k = map(int, input().split()) +s = list(input()) +s[k-1] = s[k-1].lower() +print(''.join(s))" +p03623,s674072939,Wrong Answer,"x , a ,b = map(int,input().split()) +X = abs(a - x) +Y = abs(b - x) +Z = max(Y,X) +if Z == X: + print(""A"") +else: + print(""B"") +" +p02717,s586712375,Accepted,"X,Y,Z=map(int,input().split()) +a=X +X=Y +Y=a +c=X +X=Z +Z=c +print(X,Y,Z) +" +p03252,s091283173,Accepted,"import collections +S = input() +T = input() +scounter = collections.Counter(S) +tcounter = collections.Counter(T) +scounter_v = dict(scounter).values() +tcounter_v = dict(tcounter).values() +sdist = sorted([i for i in scounter_v]) +tdist = sorted([i for i in tcounter_v]) +if sdist == tdist: + print(""Yes"") +else: + print(""No"") +" +p03644,s665534424,Wrong Answer,"n = int(input()) +for i in range(7): + if n < 2 ** i: + print(2**(i-1))" +p02817,s543850795,Accepted,"a=list(map(str,input().split())) +print(a[1]+a[0])" +p02684,s799565378,Accepted,"#!/usr/bin/env python3 +import sys +input = sys.stdin.readline + +n, k = map(int, input().split()) +a = [int(item) - 1 for item in input().split()] +visited = [0] * n + +v = 0 +visited[0] = 1 +pre = [0] +loop = [] +start = False +while True: + v = a[v] + if visited[v] == 1: + start = True + if visited[v] == 2: + break + if not start: + pre.append(v) + else: + loop.append(v) + visited[v] += 1 + +if k < len(pre): + print(pre[k] + 1) + exit() +k -= len(pre) +print(loop[k % len(loop)] + 1)" +p02879,s787569657,Accepted,"x = input().split() +a = int(x[0]) +b = int(x[1]) +if a <= 9 and b <= 9: + print(a * b) +else: + print('-1')" +p02862,s016417354,Wrong Answer,"X, Y = map(int, input().split()) +MOD = 10 ** 9 + 7 + + +S = -X + 2 * Y +T = 2 * X - Y + +if S % 3 != 0 or T % 3 != 0: + print(0) + exit() + +S //= 3 +T //= 3 + + +def cmb(n, r, p): + r = min(n - r, r) + if r == 0: + return 1 + over = 1 + for i in range(n, n - r, -1): + over = over * i % p + under = 1 + for i in range(1, r + 1): + under = under * i % p + inv = pow(under, p - 2, p) + return over * inv % p + + +ans = cmb(S + T, S, MOD) % MOD +print(ans % MOD) +" +p02988,s526690668,Wrong Answer,"n = int(input()) +count=0 +#p = [input() for i in range(n)] +p=list(map(int,input().split())) +for i in range(n-2): + if (p[i-1]p[i+1]>p[i]): + count+=1 +print(count)" +p02957,s759592150,Accepted,"a,b = map(int,input().split()) +if (a+b) % 2 == 1: + print(""IMPOSSIBLE"") +else: + print((a+b)//2) +" +p03261,s541838104,Wrong Answer,"import sys + +N = int(input()) + +W = [] +for i in range(N): + w = str(input()) + if w in W: + print(""No"") + sys.exit() + if i != 0 and w[-1] != W[-1][-1]: + print(""No"") + sys.exit() + W.append(w) + +print(""Yes"")" +p02959,s454103341,Accepted,"def resolve(): + N = int(input()) + A = list(map(int, input().split())) + B = list(map(int, input().split())) + sumA = sum(A) + + for i in range(N): + res = B[i] + if A[i] > 0 and res != 0: + A[i], res = max(A[i] - res, 0), max(res - A[i], 0) + + if A[i+1] > 0 and res != 0: + A[i+1], res = max(A[i+1] - res, 0), max(res - A[i+1], 0) + + print(sumA - sum(A)) + return + +resolve()" +p03435,s091271405,Accepted,"#ABC088-C +grid = [list(map(int,input().split())) for _ in range(3)] +flg = True +b1 = grid[0][0] +b2 = grid[0][1] +b3 = grid[0][2] +if grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3: + a2 = grid[1][0] - b1 +else: + flg = False +if grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3: + a3 = grid[2][0] - b1 +else: + flg = False + +if flg: + print('Yes') +else: + print('No')" +p03012,s759374553,Accepted,"N=int(input()) +w=list(map(int, input().split())) +S=sum(w) +k=0 +ans=10**7 + +for i in range(N-1): + k+=w[i] + if abs(S-2*k)<=ans: + ans=abs(S-2*k) + +print(ans)" +p03910,s266494368,Wrong Answer,"N = int(input()) + +if N==1: + print(1) + quit() +if N % 2 == 0: + print(N//2-1, N//2+1) + +else: + print(N//2, N//2+1)" +p02994,s149691732,Accepted,"n, l = map(int, input().split()) +apple = [i for i in range(l, l+n)] +total = sum(apple) + +ans = float('inf') +ans2 = 0 +for i in range(n): + tmp = total - apple[i] + if ans > abs(total - tmp): + ans = abs(total - tmp) + ans2 = tmp + +print(ans2)" +p03478,s625235540,Accepted,"n, a, b = map(int, input().split()) + +ans = 0 +for i in range(1,n+1): + w = sum(list(map(int, list(str(i))))) + if a <= w and w <= b: + ans += i +print(ans)" +p04044,s960759515,Accepted,"N,L = map(int,input().split()) +S = [] +ans = """" + +for i in range(N): + S.append(input()) + +L = sorted(S) + +for i in range(len(L)): + ans = ans+L[i] + +print(ans)" +p03711,s196750664,Wrong Answer,"a,b = map(int,input().split()) + +if a == 2 or b == 2: + print('No') +elif a == 1 or 3 or 5 or 7or 8or 10or 12: + if b == 3 or 5 or 7or 8or 10or 12: + print('Yes') + else: + print('No') +elif a == 4 or 6 or 9or 11: + if b == 6 or 9 or 11: + print('Yes') + else: + print('No')" +p02631,s484544379,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +xor = a[0] ^ a[1] +for i in range(2, n): + xor ^= a[i] + #print(bin(xor)) +for i in range(n): + print(xor ^ a[i], end=' ')" +p02748,s218838051,Wrong Answer,"def resolve(): + a, b, m = map(int, input().split()) + a_list = sorted(list(map(int, input().split()))) + b_list = sorted(list(map(int, input().split()))) + min_total = min(a_list) + min(b_list) + for _ in range(m): + x, y, c = map(int, input().split()) + a_c = a_list[x-1] + b_c = b_list[y-1] + if min_total > a_c + b_c - c: + min_total = a_c + b_c - c + print(min_total) +resolve()" +p02882,s752887670,Accepted,"import math +def at(n): + return math.degrees(math.atan(n)) + +def main(): + a, b, x = [int(p) for p in input().split("" "")] + V = a * a * b + if x < V / 2: + print(at(a * b * b / (2 * x))) + else: + print(at(2*(a*a*b-x)/a**3)) + +main() +" +p02760,s402609028,Wrong Answer,"d=[list(map(int,input().split()))for i in range(3)] +row=int(input()) +num=[int(input()) for j in range(row)] +bingo=0 +for a in range(3): + if d[0][a] in num and d[1][a] in num and d[2][a] in num: + bingo=bingo+1 + if d[a][0] in num and d[a][1] in num and d[a][2] in num: + bingo=bingo+1 +if d[1][1] in num and d[2][2] in num and d[0][0] in num: + bingo=bingo+1 +if d[0][1] in num and d[2][2] in num and d[1][0] in num: + bingo=bingo+1 +if bingo>0: + print('Yes') +else: + print('No')" +p03371,s267454570,Accepted,"import sys +stdin = sys.stdin +sys.setrecursionlimit(10 ** 7) + +i_i = lambda: int(i_s()) +i_l = lambda: list(map(int, stdin.readline().split())) +i_s = lambda: stdin.readline().rstrip() + +A, B, C, X, Y = i_l() + +if X < Y: + X * C + (Y - X) * B + print(min((X * A + Y * B), (X * C * 2 + (Y - X) * B), C * max(X, Y) * 2)) +else: + print(min((X * A + Y * B), (Y * C * 2 + (X - Y) * A), C * max(X, Y) * 2)) + " +p03761,s957754962,Accepted,"n=int(input()) +s=[100]*26 +for i in range(n): + a=[0]*26 + for j in list(input()): + a[ord(j)-97]+=1 + for j in range(26): + s[j]=min(s[j],a[j]) +ans='' +for i in range(26): + for j in range(s[i]): + ans=ans+chr(i+97) +print(ans)" +p03338,s439271406,Accepted,"N = int(input()) +S = list(input()) +ma=0 +for i in range(N-1): + ma=max(len(set(S[:i]) & set(S[i:])), ma) +print(ma)" +p03524,s191317736,Accepted,"from collections import defaultdict +s = input() +cnt = defaultdict(int) +for i in range(len(s)): + cnt[s[i]] += 1 +mean = len(s) // 3 +for t in [""a"", ""b"", ""c""]: + if cnt[t] != mean and cnt[t] != mean + 1: + print(""NO"") + exit() + +print(""YES"")" +p03449,s851884660,Accepted,"x=int(input()) +s=[list(map(int,list(input().split()))) for i in range(2)] +y=list(s) + +for i in range(x-1): + y[1][(x-2-i)]=y[1][(x-2-i)]+y[1][(x-1-i)] + +y[0][(x-1)]=y[0][(x-1)]+y[1][(x-1)] + +for i in range(x-1): + if y[0][(x-i-1)]>=y[1][(x-i-2)]: + y[0][(x-i-2)]=y[0][(x-i-2)]+y[0][(x-i-1)] + else: + y[0][(x-i-2)]=y[0][(x-i-2)]+y[1][(x-i-2)] +print(y[0][0])" +p03150,s493320861,Wrong Answer,"s=input() +print('YES' if len(s)>=7 and s[:3]=='key' and s[-4:]=='ence' else 'NO')" +p03779,s915872914,Accepted,"x = int(input()) + +s = 0 + +t = 1 +while True: + s += t + if s >= x: + break + + t += 1 + +print(t)" +p02756,s699692964,Accepted,"from collections import deque +s = deque(i for i in input()) +n = int(input()) +l = [[i for i in input().split()] for _ in range(n)] + +front = True + +for i in l: + if i[0] == '1': + front = not front + else: + if front ^ (int(i[1]) == 1): + s.append(i[2]) + else: + s.appendleft(i[2]) + +ans = ''.join(s) + +if front: + print(ans) +else: + ans = ans[::-1] + print(ans)" +p03785,s029122049,Accepted,"from collections import deque + + +N, C, K = map(int, input().split()) +T = [int(input()) for _ in range(N)] +T.sort() +d = deque(T) +count = 0 +while len(d) > 0: + t = d.popleft() + K + for i in range(C-1): + if len(d) > 0 and d[0] <= t: + d.popleft() + else: + break + count += 1 + +print(count) +" +p03220,s872056149,Wrong Answer,"n = int(input()) +t, a = map(int, input().split()) +h = list(map(int, input().split())) +ans = -1 +nearest = 10**18 +for i in range(n): + target = abs(t - h[i] * 0.006) + if abs(a - nearest) > abs(a - target): + nearest = target + ans = i + 1 +print(ans) +" +p03146,s666558898,Wrong Answer,"s=int(input()) +a=[0]*1000000 +for i in range(1000000): + if s%2==1: + s=s*3+1 + else: + s=s/2 + + if s in a: + print(i+2) + break + a[i]=s" +p03162,s434513600,Wrong Answer,"N=int(input()) +ABC=[] +for i in range(N): + ABC+=[[int(i) for i in input().split()]] +DP=[[0,0,0] for i in range(N)] +for i in range(1,N): + for j in range(3): + DP[i][j]=ABC[i][j]+max(DP[i-1][(j+1)%3],DP[i-1][(j+2)%3]) +print(max(DP[-1])) + +" +p03721,s316675148,Accepted,"import sys +input = sys.stdin.readline +import heapq + +def readlines(n): + for _ in range(n): + a, b = map(int, input().split()) + yield a, b + +def main(): + n, k = map(int, input().split()) + ary = [] + heapq.heapify(ary) + for a, b in readlines(n): + heapq.heappush(ary, (a, b)) + + while True: + a, b = heapq.heappop(ary) + k -= b + if k <= 0: + print(a) + return + +main() + + +" +p02753,s038031077,Accepted,"S = input() +if S[0] != S[1] or S[1] != S[2]: + print('Yes') +else: + print('No')" +p02659,s629224632,Accepted,"import decimal + +A, B = map(decimal.Decimal, input().split()) +ans = A * B +print(int(ans)) +" +p03475,s048227862,Wrong Answer,"n=int(input()) +cs=[list(map(int,input().split())) for _ in range(n-1)] +for i in range(n-1): + t=0 + for c,s,f in cs[i:]: + t=max(t,s) + if t%f: + t=t-t%f + t+=c + print(t) + +print(0)" +p02623,s271125020,Wrong Answer,"def main(): + n, m, k = map(int,input().split()) + A = list(map(int,input().split())) + B = list(map(int,input().split())) + C = [] + for x in range(n): + sumA = int(sum(A[0:x])) + for y in range(m): + sumB = int(sum(B[0:y])) + if sumA + sumB < k: + C.append(x+y) + print(max(C)) +main()" +p02795,s151351511,Accepted,"h = int(input()) +w = int(input()) +n = int(input()) + +if (h>w) : + rep=h +else : + rep=w + +i=0 +while rep * i < n: + i+=1 + +print(i) +" +p03289,s835157268,Accepted,"s = input() + + +def check(w): + if w[0] != 'A': + return False + n = len(w) + count = 0 + for a in range(2, n-1): + if w[a] == 'C': + count += 1 + if count != 1: + return False + upper = 0 + for a in range(0, n): + if w[a] >= 'A' and w[a] <= 'Z': + upper += 1 + + if upper != 2: + return False + return True + + +if check(s): + print('AC') +else: + print('WA') +" +p02754,s617315610,Wrong Answer,"X = list(map(int,input().split())) + +N = X[0] +b = X[1] +r = X[2] + +if b == 0: + print(0) +elif r == 0: + print(N) +elif b + r == N: + print(b) +else: + b_count = 0 + Line = 0 + while Line <= N: + Line += b + b_count += b + Line += r + + + print(b_count)" +p03345,s210309806,Accepted,"a, b, _, k = map(int, input().split()) +print(b - a if k & 1 else a - b)" +p02571,s815579474,Accepted,"s = input() +t = input() +cnt_max = 0 +for i in range(len(s)-len(t)+1): + cnt = 0 + for j in range(len(t)): + if s[i+j] == t[j]: + cnt += 1 + if cnt > cnt_max: + cnt_max = cnt +print(len(t)-cnt_max)" +p02689,s475394972,Accepted,"n, m = map(int,input().split()) +h = list(map(int,input().split())) +c = [[] for _ in range(n)] +for i in range(m): + a, b = map(int,input().split()) + c[a-1].append(h[b-1]) + c[b-1].append(h[a-1]) + +cnt = 0 +for i, a in enumerate(c): + if a: + a.sort(reverse=True) + if a[0] < h[i]: + cnt += 1 + else: + cnt += 1 +print(cnt)" +p02848,s965212436,Accepted,"import string +N = int(input()) +S = list(input()) + +al = list(string.ascii_uppercase) +ans = [] +for i in S: + pos = al.index(i) + N + if pos < 26: + ans.append(al[pos]) + else: + ans.append(al[pos-26]) +print(''.join(ans))" +p03284,s987577125,Accepted,"n,k=map(int,input().split()) +if n%k==0: + print(0) +else: + print(1)" +p02681,s698806694,Accepted,"s = input() +t = input() +n = len(s) +if s == t[:n]: + print('Yes') +else: + print('No')" +p03385,s136566479,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + + +def main(): + S = input() + ans = set() + for c in S: ans.add(c) + if ans == {'a', 'b', 'c'}: + print(""Yes"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main() +" +p02624,s029481531,Accepted,"import sys +import math +read = sys.stdin.read +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10 ** 8) +INF = float('inf') +MOD = 10 ** 9 + 7 + +def main(): + N = int(readline()) + ans = 0 + for i in range(1,N+1): + n = N//i + ans += n*(n+1)*i//2 + print(ans) + + +if __name__ == '__main__': + main() +" +p02647,s344776599,Accepted,"def main(): + n,k,*a=map(int,open(0).read().split()) + for _ in range(k): + b=[0]*n + m=10**18 + for i,t in enumerate(a): + if t=n:break + for i in range(n-1):b[i+1]+=b[i] + a=b + print(' '.join(map(str,a))) +main()" +p03127,s059194844,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +A.sort() + + +dig = 0 +while A[0] >= 10: + A[0] = A[0] // 10 + dig += 1 + +ans = 2 +for i in range(N): + if A[i] % (2 * 10 ** dig) == 1: + ans = 1 + break + +print(ans * 10 ** dig) + " +p03434,s382626433,Wrong Answer,"N=int(input()) +a=list(map(int,input().split())) +a.sort(reverse=True) +x=0 +y=0 +for i in range(N): + if i%2==0: + x+=i + else: + y+=i +print(x-y) +" +p03475,s122851963,Wrong Answer," +N = int(input()) +M = [list(map(int, input().split())) for _ in range(N-1)] + +def dfs(i): + DP = [99999999999999] * N + DP[i] = M[i][1] + + for j in range(i+1, N): + prev = DP[j-1] + M[j-1][0] + start = M[j-1][1] + M[j-1][0] + if start >= prev: + DP[j] = start + else: + DP[j] = prev + ( DP[j-1] - M[j-1][1] ) % M[j-1][2] + + print(DP[N-1]) + +for i in range(N-1): + dfs(i) + +print(0)" +p03815,s341787394,Wrong Answer,"x = int(input()) +if x == 1: + print(0) +elif x <= 6: + print(1) +elif x <= 12: + print(2) +else: + a = x // 11 + b = x % 11 + n = 11 * a + if x == n: + print(a) + elif n + 5 >= x: + print(2 * a + 1) + else: + print(2 * a + 2) + +" +p02694,s831828935,Wrong Answer,"import math +X = int(input()) +n = 100 +ans = 1 +for i in range(10000000): + if n >= X: + print(ans) + break + else: + n = math.ceil(n*1.01) + ans += 1 " +p03760,s372172609,Accepted,"O=input() +E=input() +lengthO=len(O) +lengthE=len(E) +for i in range(len(O)+len(E)): + if i%2==0: + print(O[i//2],end="""") + else: + print(E[i//2],end="""")" +p02818,s178807829,Accepted,"a, b, k = map(int,input().split()) +# for i in range(k): +# if a >= 1: +# a -= 1 +# elif b >= 1: +# b -= 1 +# else: +# continue + +tmp = min(k, a) +a -= tmp +k -= tmp +b = max(0, b - k) + +print(a, b)" +p03479,s823893480,Wrong Answer,"from math import log2, floor +X, Y = map(int, input().split()) +ans = floor(log2(Y/X)) + 1 +print(ans)" +p03592,s974867296,Accepted,"N,M,K = map(int,input().split()) +flag = False +for i in range(N+1): + for j in range(M+1): + if i*M + j*N - 2*i*j == K: + flag = True + +print(""Yes"" if flag else ""No"")" +p02958,s956508391,Accepted,"import numpy as np + +n = int(input()) +p = np.array([int(i) for i in input().split()]) + +a = np.arange(-1, -n-1, -1) +print('YES' if np.count_nonzero(p+a) < 3 else 'NO') +" +p03624,s630045577,Accepted,"s=input() +alph=[chr(i) for i in range(97,97+26)] +for i in s: + if i in alph: + alph.remove(i) +if alph: + print(alph[0]) +else: + print(""None"")" +p02584,s859341518,Wrong Answer,"# -*- coding: utf-8 -*- +x, k, d = map(int, input().split()) + +for i in range(1, k+1): + if x >= 0: + x = x - d + if x < 0: + x = x + d + +print(abs(x))" +p03493,s201983780,Wrong Answer,"numbers = input() +print(numbers) +if int(numbers) == 000: + print(0) +elif int(numbers) == 111: + print(3) +elif int(numbers) == 101 or int(numbers) == 110 or int(numbers) == 11: + print(2) +else: + print(1)" +p03417,s454463936,Accepted,"n,w=map(int,input().split()) +print(abs(n*w-n*2-w*2+4))" +p03544,s291635859,Accepted,"N = int(input()) + +L = [2,1] + +for i in range(100): + L.append(L[i]+L[i+1]) + +print(L[N])" +p02843,s389383945,Wrong Answer,"x = input() +x = '000'+x +z = x[:-2] +y = x[-2:] +s = 0 +z = int(z) +y = int(y) +L = [] +for i in range(1,15): + s +=i + if s>=y and z>=i: + print(1) + exit() +if z>=14: + print(1) + exit() +print(0)" +p03380,s527014957,Accepted,"N = int(input()) +A = list(map(int, input().split())) +A.sort() +M = A[-1] +a = M // 2 +for i in range(N-1): + if A[i] <= a and A[i+1] >= a: + if (M-A[i])*A[i] >= (M-A[i+1])*A[i+1]: + ans = [M, A[i]] + else: + ans = [M, A[i+1]] +ans = [str(b) for b in ans] +ans = ' '.join(ans) +print(ans) + " +p03625,s422642816,Accepted,"import sys + +N = int(input()) +A = list(map(int, input().split())) +A = sorted(A, reverse=True) + +cnt = 0 +for i in range(N-1): + if A[i] - A[i+1] == 0: + cnt +=1 +if cnt < 2: + print(""0"") + sys.exit() + +leng1 = 0 +leng2 = 0 +diff = 10**9 + +i = 0 +while diff != 0: + diff = A[i] - A[i+1] + i += 1 +leng1= A[i] + +A.remove(leng1) +A.remove(leng1) + +i = 0 +diff = 10**9 +while diff != 0: + diff = A[i] - A[i+1] + i += 1 +leng2= A[i] + +print(leng1*leng2)" +p02831,s559676628,Accepted,"a,b = (int(i) for i in input().split()) + +import fractions + +def lcm(x, y): + return (x * y) // fractions.gcd(x, y) + +print(lcm(a, b))" +p03711,s848467425,Accepted,"la = [1,3,5,7,8,10,12] +lb = [4,6,9,11] +lc = [2] + +x, y = map(int, input().split()) + +if x in la and y in la: + print('Yes') +elif x in lb and y in lb: + print('Yes') +elif x in lc and y in lc: + print('Yes') +else: + print('No')" +p02767,s375881137,Wrong Answer,"import statistics +import math +import numpy as np + +N=int(input()) +X=list(map(int,input().split())) +X.sort() +#print(X) +med=int(statistics.median(X)) + +min=10**10 +sum=0 +while True: + sum=0 + for i in range(N): + sum+=(X[i]-med)**2 + if sum= S - x - y >= 0: + ans += 1 +print(ans) +" +p03241,s030405075,Accepted,"import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline + +in_n = lambda: int(readline()) +in_nn = lambda: map(int, readline().split()) +in_s = lambda: readline().rstrip().decode('utf-8') + + +def main(): + N, M = in_nn() + + ans = 1 + inf = M // N + 1 + for i in range(inf, 1, -1): + if i * N <= M and M % i == 0: + ans = i + break + + print(ans) + + +if __name__ == '__main__': + main() +" +p02717,s989171630,Wrong Answer,"l = input().split(' ') + +print(str(l[2])+str(l[0])+str(l[1]))" +p03493,s743045326,Accepted,"li = list(input()) + +print(li.count(""1""))" +p03379,s225848606,Wrong Answer,"n = int(input()) +x = list(map(int,input().split())) +if n == 2: + print(x[1]) + print(x[0]) +else: + srt_x = sorted(x) + print(x) + print(srt_x) + m = n//2 + for i in range(n): + if x[i]=n+1: + break + for o in range(ord(""a""), ord(m)+2): + if ord(m) c: + p = 1 + elif i < c: + m = 1 + if p == 1 and m == 1: + p = m = 0 + ans += 1 + c = i +print(ans) +# maybe pills will work??" +p03293,s956176656,Wrong Answer,"S = str(input()) +T = str(input()) + +flg = False + +for i in range(0,len(S)-1): + temp = S[-i-1:] + + ret = temp + S[:len(S)- i -1] + + if ret == T: + flg = True + break + + +if flg == True: + print('Yes') +else: + print('No')" +p02664,s075391369,Accepted,"t = list(input()) +for i in range(len(t)): + if t[i] == ""?"": + t[i] = ""D"" + +print("""".join(t))" +p02548,s212603186,Accepted,"import sys +input = sys.stdin.readline + +N=int(input()) +ANS=0 +for i in range(1,N): + ANS+=(N-1)//i + +print(ANS) +" +p03543,s556452563,Accepted,"N = input() +_1 = N[:-1] +_2 = N[1:] + +ans = 'No' +if _1[0] == _1[1]: + if _1[1] == _1[2]: + ans = 'Yes' + +if _2[0] == _2[1]: + if _2[1] == _2[2]: + ans = 'Yes' + +print(ans)" +p02881,s508049342,Wrong Answer,"n = int(input()) +l = [] +for i in range(1,n): + sur = n%i + ans = n/i + # print(i,ans,sur) + if ans < i: + break + elif sur == 0: + l.append(i) +l.sort(reverse=True) +max = l[0] +max_op = n/max +ite = max-1+max_op-1 +print(ite)" +p02888,s255473631,Accepted,"import sys + + +def input(): + return sys.stdin.readline().strip() + + +N = int(input()) +L = list(map(int, input().split())) + +L.sort() + +ans = 0 +# a(一番短い辺)を固定して,b, cで尺取 +for a in range(N): + c = a + 1 + for b in range(a + 1, N): + while c < N and L[c] < L[a] + L[b]: + c += 1 + ans += c - (b + 1) + +print(ans) +" +p03623,s251178155,Accepted,"x,a,b = map(int,input().split()) +if abs(x - a) <= abs(x - b): + print('A') +else: + print('B')" +p02759,s194968980,Wrong Answer,"n = int(input()) +if n%2 == 0: + print(n//2) +else: + print(n//2) +" +p02657,s308929142,Wrong Answer,s = input() +p03804,s297233013,Accepted,"# B + +import numpy as np +N, M = map(int, input().split()) + +A = np.array([list(input()) for i in range(N)]) +B = np.array([list(input()) for i in range(M)]) + +flag=0 +for i in range(N-M+1): + for j in range(N-M+1): + A_tmp = A[i:i+M,j:j+M] + # print(A_tmp) + # print(B) + if (B==A_tmp).all(): + flag=1 + if flag==1: + break + if flag==1: + break +if flag==1: + print(""Yes"") +else: + print(""No"")" +p02677,s906785671,Accepted,"import math +A,B,H,M = map(int,input().split()) + +H %= 12 +ra = 0.5*(60*H+M)-6*M +ra = min(ra,360-ra) +cos_ra = math.radians(ra) +C = math.sqrt((A**2+B**2)-(2*A*B*math.cos(cos_ra))) +print(C)" +p02787,s246039879,Wrong Answer,"H,N=map(int,input().split()) +AB=[] +bestmagic=0 +bestdpc=0 +for i in range(N): + A,B=map(int,input().split()) + dpc=A/B + if bestdpc 1: + f |= {n} + return f +a, b = map(int, input().split()) +print(len(c(a) & c(b)) + 1)" +p03625,s155843449,Accepted,"from collections import Counter + +n=int(input()) +l=[int(i) for i in input().split()] +c=Counter(l).most_common() +s=sorted([key,val] for key,val in c if val>=2) + +if len(s)<2: + ans=0 +elif s[-1][1]>=4: + ans=s[-1][0]**2 +else: + ans=s[-1][0]*s[-2][0] + +print(ans) +" +p03944,s259012529,Accepted,"w,h,n = map(int,input().split()) + +x1 = 0 +x2 = w +y1 = 0 +y2 = h + +for _ in range(n): + x,y,a = map(int,input().split()) + if a == 1: + x1 = max(x1, x) + elif a == 2: + x2 = min(x2, x) + elif a == 3: + y1 = max(y1, y) + else: + y2 = min(y2, y) + +if x2 - x1 > 0 and y2 - y1 > 0: + print((x2-x1) * (y2-y1)) +else: + print(0) +" +p02623,s749520665,Accepted,"'''ABC172 C''' +import numpy as np +n,m,k = map(int,input().split()) +a = np.array([int(i) for i in input().split()], dtype='int64') +b = np.array([int(i) for i in input().split()], dtype='int64') + +a_c = np.zeros(n+1,dtype='int64') +a_c[1:] = np.cumsum(a) + +b_c = np.zeros(m+1,dtype='int64') +b_c[1:] = np.cumsum(b) + +a_c = a_c[a_c <= k] +b_c = b_c[b_c <= k] +ans = 0 +for i,ai in enumerate(a_c): + n = np.searchsorted(b_c, k - ai, side = 'right') + ans = max(i + n-1, ans) +print(ans)" +p03385,s259254388,Accepted,"s = input() +if ord(s[0]) + ord(s[1]) + ord(s[2]) == ord('a') + ord('b') + ord('c'): + print('Yes') +else: + print('No')" +p03943,s233340182,Accepted,"a,b,c = map(int, input().split()) +if abs(a-b) == c or abs(a-c) == b or abs(b-c) == a: + print(""Yes"") +else: + print(""No"")" +p02665,s435183204,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +if a[0] >= 1 or n == 0: + print(1 if a[0] == 1 and n == 0 else -1) + exit() +b = [0] * (n + 1) +for i in range(1, n + 1): + b[i] = a[i] + b[i - 1] +v = 1 +ans = 1 +for i in range(n): + if v < 2 * a[i + 1]: + print(-1) + exit() + v = min(b[n] - b[i], 2 * (v - a[i])) + if v <= 0: + print(-1) + exit() + ans += v +print(ans)" +p02718,s219023452,Wrong Answer,"N,M=map(int,input().split()) +A=list(map(int,input().split())) +A.sort(reverse=True) +total=0 +for i in range(N): + total+=A[i] +if A[M-1]>total/(4*M): + print(""Yes"") +else: + print(""No"") + " +p03017,s714367604,Wrong Answer,"n, a, b, c, d = map(int, input().split()) +S = input() +if c < d: + if ""##"" in S[a:d-3]: + print(""No"") + else: + print(""Yes"") +else: + f = S[b-2:].find(""..."") + if f != -1 and f != (d-1) and (""##"" not in S[a:d-3]): + print(""Yes"") + else: + print(""No"")" +p02678,s051181892,Wrong Answer,"print(""No"")" +p02832,s261237460,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +check = 1 +ans = 0 + + +for i in a: + ans+=1 + if i == check: + ans -=1 + check+=1 + +if a==[j for j in range(1,N+1)]: + print(0) + exit() + +elif ans==N: + print(-1) + exit() + +print(ans) + + + +" +p03986,s130169263,Accepted,"S = input() +s = ans = 0 +for c in S: + if c=='S': + s += 1 + else: + if s: + s -= 1 + else: + ans += 1 +print(ans+s)" +p03821,s232788194,Wrong Answer,"N = int(input()) +AB = [0] * N +for n in range(N): + AB[-1-n] = [int(x) for x in input().strip().split()] +ans = 0 +cnt = 0 +for (a, b) in AB: + if b == 1: + if a == 0: + ans += 1 + else: + t = b - ((a + cnt) % b) + cnt += t + ans += t +print(ans) +" +p02706,s845330917,Wrong Answer,"N,M = map(int,input().split()) +A = list(map(int,input().split())) +counter = 0 + +for i in range(M): + counter += A[i] + +print(N-counter)" +p03387,s610165482,Accepted,"A = [int(x) for x in input().split()] +if sum(A) % 2 == max(A) % 2: + ans = (max(A) * 3 - sum(A)) // 2 +else: + ans = ((max(A) + 1) * 3 - sum(A)) // 2 +print(ans)" +p02842,s799435249,Accepted,"n = int(input()) + +for v in range(int(n//1.08)+2): + if int(v*1.08) == n: + print(v) + exit() +print(':(')" +p03041,s886370801,Wrong Answer,"n,k = map(int, input().split()) +s = input() +s = s.replace(s[k-1], s[k-1].lower()) +print(s)" +p02766,s580204000,Accepted,"N,K = map(int,input().split()) +count = 0 + +while N//K != 0: + N = N//K + count += 1 +print(count+1)" +p03345,s651794388,Accepted,"a,b,c,k = map(int,input().split()) +if k % 2 == 0: + ans = a - b +else: + ans = b - a + +if abs(ans) >= 10**18: + print(""Unfair"") +else: + print(ans)" +p03136,s247791011,Accepted,"n=int(input()) +l=[int(i) for i in input().split()] +l.sort() + +longest=l.pop() +remain=sum(l) +if longest 0: + print(b*d) +else: + print(-1*min(abs(a),abs(b))*min(abs(c),abs(d)))" +p03387,s099573999,Accepted,"A, B, C = map(int, input().split()) +S = A + B + C +M = max(A, B, C) +if S%2 != M%2: + M = M + 1 +print((3*M-S)//2)" +p03086,s473067943,Accepted,"s=list(input()) +dna = [""A"",""T"",""G"",""C""] +res=[0] +x=0 +for i in range(len(s)): + if s[i] in dna: + x+=1 + else: + res+=[x] + x=0 +print(max(x,max(res)))" +p03814,s334249071,Wrong Answer,"s = list(input()) + +flag = 0 +pos_a, pos_z = 1, 1 +length = 0 + +for i, ltr in enumerate(s, 1): + if ltr == 'A': + pos_a = i + flag = 1 + elif ltr == 'Z' and flag == 1: + pos_z = i + if pos_z - pos_a > length: + length = pos_z - pos_a + else: + flag = 0 + +print(length)" +p03457,s089363279,Accepted,"# vim: fileencoding=utf-8 + + +def main(): + n = int(input()) + t, x, y = 0, 0, 0 + for i in range(n): + a, b, c = map(int, input().split()) + d = a - t + m = abs(x - b) + abs(y - c) + if d - m < 0 or (d - m) % 2 == 1: + print(""No"") + return + t, x, y = a, b, c + print(""Yes"") + + +if __name__ == ""__main__"": + main() +" +p02627,s136325128,Wrong Answer,"c=input() +if c>='A' and c<='Z': + print('A') +else: + print('B')" +p02675,s306636268,Accepted,"N=int(input()) +n=N%10 +if n==3: + print(""bon"") +elif n==0 or n==1 or n==6 or n==8: + print(""pon"") +else: + print(""hon"")" +p02584,s115746901,Accepted,"#!/usr/bin/env python3 +x, k, d = map(int, input().split()) +x = abs(x) +if (n := k - x // d) < 0: + print(x - k * d) +else: + print(abs(d - x % d) if n % 2 else x % d) +" +p03062,s022508051,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +num = 0 +mi = 10**9 +for i in range(n): + num += abs(a[i]) + if abs(mi) >= abs(a[i]): + mi = a[i] +cnt = 0 +for i in range(n): + if a[i] < 0: + cnt += 1 +if cnt%2 == 1: + print(num-2*mi) +else: + print(num)" +p02612,s958597704,Wrong Answer,"N=int(input()) +a=N%1000 +print(a)" +p02760,s890771427,Accepted,"A = [list(map(int, input().split())) for i in range(3)] +N = int(input()) +b = set([int(input()) for i in range(N)]) +flag = False +for i in range(3): + if A[i][0] in b and A[i][1] in b and A[i][2] in b: + flag = True + if A[0][i] in b and A[1][i] in b and A[2][i] in b: + flag = True +if A[0][0] in b and A[1][1] in b and A[2][2] in b: + flag = True +if A[0][2] in b and A[1][1] in b and A[2][0] in b: + flag = True +print(['No','Yes'][flag])" +p03210,s309866703,Wrong Answer,"X = int(input()) +if X == 7 or X == 5 or X == 3: + print('Yes') +else: + print('No')" +p02602,s804646003,Wrong Answer,"n,k = map(int,input().split()) +a = list(map(int,input().split())) + +for i in range(k,n): + if a[i-3] < a[i]: + print(""Yes"") + else: + print(""No"")" +p02612,s271770192,Accepted,"N = int(input()) + +n = N/1000 + +for i in range(11): + if i >= n: + print(i*1000-N) + break" +p03971,s550592751,Accepted,"n, a, b = map(int, input().split()) +s = input() +jap_c = 0 +ab_c = 0 +for i in list(s): + if i == 'a': + if jap_c + ab_c < a+b: + jap_c += 1 + print('Yes') + continue + if i == 'b': + if jap_c + ab_c < a+b: + if ab_c < b: + ab_c += 1 + print('Yes') + continue + print('No')" +p03545,s838022000,Accepted,"s = [int(i) for i in input()] +for i in range(8): + a = s[0] + lst = [] + for j in range(3): + if i>>j & 1 == 1: + a += s[j+1] + lst.append(""+"") + else: + a -= s[j+1] + lst.append(""-"") + if a == 7: + lst.append(""=7"") + break + +for i,j in zip(s,lst): + print(i,j,sep="""",end="""") +else: + print("""")" +p03645,s339690786,Accepted,"N, M = map(int, input().split()) +from_one = [] +to_n = [] +for _ in range(M): + a, b = map(lambda x:int(x)-1, input().split()) + if a == 0: + from_one += [b] + elif b == 0: + from_one += [a] + elif a == N-1: + to_n += [b] + elif b == N-1: + to_n += [a] + +from_one = set(from_one) +to_n = set(to_n) +if len(from_one & to_n) >= 1: + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"") +" +p03274,s318766852,Accepted,"from bisect import bisect_left + +n, k = map(int, input().split()) +x = list(map(int, input().split())) +ans = 0 +min_dis = 10 ** 20 +a = 0 +for i in range(n - k + 1): + dis = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1])) + if min_dis > dis: + ans = dis + min_dis = dis +print(ans) +" +p03719,s147256365,Accepted,"a,b,c = map(int, input().split()) +print('Yes' if c >= a and c <= b else 'No')" +p03359,s938895514,Accepted,"a, b = map(int, input().split()) + +if a <= b: + print(a) +else: + print(a-1) +" +p02572,s523240768,Accepted,"def findProductSum(A, n): + array_sum = sum(A) + array_sum_square = array_sum ** 2 + individual_square_sum = 0 + for i in range(0, n, 1): + individual_square_sum += A[i] * A[i] + return (array_sum_square - + individual_square_sum) // 2 + +n = input() +arr = list(map(int, input().split())) +res = findProductSum(arr, len(arr)) % (10**9 + 7) +print(res) + + +" +p03719,s952760749,Wrong Answer,"a,b,c = input().split() +if c >= a and c <= b: + print('Yes') +else: + print('No')" +p02811,s851913898,Wrong Answer,"K,X= input().split() + +if 500 * K >= X: + print('Yes') +else: + print('No') +" +p02959,s845861655,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +ans = 0 +for i, b in enumerate(B): + l = min(A[i], b) + b -= l + r = min(A[i + 1], b) + ans += l + r + +print(ans) +" +p02988,s618113988,Accepted,"def main(): + n = int(input()) + p = [int(x) for x in input().split()] + ans = 0 + for i in range(1, n - 1): + a = [p[i - 1], p[i], p[i + 1]] + if p[i] != max(a) and p[i] != min(a): + ans += 1 + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02922,s129455081,Accepted,"#B +import math +a,b = map(int,input().split()) + +k = math.ceil((b-1)/(a-1)) + +if b == 1: + print(0) +elif a == b: + print(1) +else: + print(k)" +p02747,s365296870,Accepted,"from sys import stdin +s = stdin.readline().rstrip() +k = len(s) +if k%2 == 1: + print(""No"") +else: + if s == ""hi""*(k//2): + print(""Yes"") + else: + print(""No"")" +p02687,s424533328,Accepted,"import itertools +import numpy as np +S = str(input()) +if S == ""ARC"": + print(""ABC"") +else: + print(""ARC"")" +p03827,s626925300,Accepted,"N = int(input()) +S = list(input()) + +d = S.count('D') +i = S.count('I') +cnt = 0 +cntold = 0 +for n in range(N): + if S[n] == 'D': + cnt -= 1 + else: + cnt += 1 + + if cnt > cntold: + cntold = cnt +print(cntold)" +p02791,s821897302,Wrong Answer,"n = int(input()) +p = list(map(int, input().split())) + +def code(n,p): + answer = 0 + for idx, pp in enumerate(p): + if pp>n: + answer = idx+1 + + return idx + +idx = code(n,p) +if idx == None: + print(n) +else: + print(idx) +" +p03557,s458485698,Accepted,"import bisect +n=int(input()) +a = list(map(int, input("""").split())) +b = list(map(int, input("""").split())) +c = list(map(int, input("""").split())) +out=0 +a.sort() +b.sort() +c.sort() +for i in b: + na = bisect.bisect_left(a,i) + nc = bisect.bisect(c,i) + out += na * (len(c)-nc) +print(out)" +p02576,s361928633,Accepted,"a = list(map(int,input().split())) + +b = a[0] // a[1] +c = a[0] % a[1] +if c != 0: + c = 1 +ans = (b + c) * a[2] +print(str(ans))" +p03821,s814960173,Accepted,"n=int(input()) +a=[0]*n +b=[0]*n +for i in range(n): + a[i],b[i]=map(int,input().split()) +ans=0 +for i in range(n)[::-1]: + a[i]+=ans + if not a[i]%b[i]==0: + ans+=b[i]-a[i]%b[i] +print(ans)" +p03681,s252398584,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def factorial_mod(n, mod): + ret = 1 + for i in range(1, n + 1): + ret *= i + ret %= mod + return ret + + +def main(): + N, M = map(int, input().split()) + + mod = 10 ** 9 + 7 + factorial = factorial_mod(N, mod) * factorial_mod(M, mod) + + if abs(N - M) > 1: + print(0) + elif N == M: + print((factorial * 2) % mod) + else: + print(factorial % mod) + + +if __name__ == ""__main__"": + main() +" +p02731,s257172073,Accepted,"l = int(input()) +num = l/3 +print(num**3)" +p02838,s620574214,Wrong Answer,"n=int(input()) +a=list(map(int, input().split())) +sum=0 +for i,ii in enumerate(a[:-1]): + for j in a[i+1:]: + sum+=ii^j +print(int(sum%(1e9+7)))" +p03035,s938941029,Accepted,"a,b = map(int,input().split()) +if a > 12: + print(b) +elif 6<= a<=12: + print(b//2) +else: + print(0)" +p03323,s794528828,Accepted,"A,B=map(int,input().split()) + +if A<9 and B<9: + print(""Yay!"") +else: + print("":("") +" +p02772,s497964335,Wrong Answer,"import numpy as np +N = input() +list = list(map(int,input().split(' '))) + +list = np.array(list) +A = list[list%2 == 0] +B = np.unique(np.append(list[list%6 == 0],(list[list%10 == 0]))) + +if len(A) ==0: + print('APPROVED') +elif len(B) ==0: + print('DENIED') +else: + if len(A) == len(B) : + print('APPROVED') + else: + print('DENIED') +" +p03799,s857886746,Accepted,"n,m=map(int,input().split()) +if n*2>=m: + print(m//2) +else: + print((n*2+m)//4) +" +p02765,s626297848,Wrong Answer,"import sys +sys.setrecursionlimit(10**6) +readline = sys.stdin.readline +n,r = [int(i) for i in readline().split()] + +if n >= 10: + print(r) +else: + print(r-100*(10-n))" +p02572,s256066081,Wrong Answer,"# -*- coding: utf-8 -*- + + +# 整数の入力 +n = int(input()) +# スペース区切りの整数の入力 +zzz = list(map(int, input().split())) +b=sum(zzz)**2 +a=0 +for i in range(n): + # print(i) + x=zzz[i]**2 + print(x) + a +=x +# print(b) +# for a in zzz: +# print(a) + +# print(b) +# print(a) + +ans = (b-a)//2%(10**9+7) +print(ans) +" +p04034,s888804175,Accepted,"n, m = map(int, input().split()) +C = [0]*(n+1) +C[1] = 1 +D = [1]*(n+1) +for _ in range(m): + x, y = map(int, input().split()) + if C[x]: + C[y] = 1 + if D[x] == 1: + C[x] = 0 + D[x] -= 1 + D[y] += 1 +ans = sum(C) +print(ans)" +p03485,s657552799,Accepted,"a, b = map(int,input().split()) +print((a+b+1)//2)" +p02576,s276218096,Wrong Answer,"n, x, t = map(int, input().split()) +print(n//x*t) if t % x == 0 else print((n//x+1)*t)" +p02970,s042137507,Wrong Answer,"n ,d = map(int, input().split()) +if n == d: + print(1) +elif (n - 2*d) <= d: + print(d) +elif (n - 2*d) > d: + print(d -1) " +p03126,s364577034,Accepted," +n,m = map(int,input().split()) +ans = [0] * m +info = [] + +for i in range(n): + info = list(map(int,input().split())) + for j in range(1,info[0]+1): + ans[info[j]-1] += 1 +# print(ans) + +print(ans.count(n)) +" +p03943,s876803778,Accepted,"a,b,c = map(int,input().split()) +if a+b == c or a+c == b or b+c == a: + print(""Yes"") +else: + print(""No"")" +p02831,s824102909,Accepted,"def gcd(a, b): + if a < b : + a, b = b, a + while True: + a, b = b, a % b + if b == 0: + return a + +a, b = map(int, input().split()) +print(int(a * b / gcd(a, b)))" +p03377,s453949293,Wrong Answer,"a, b, c = list(map(int, input().split())) + +d = c - a + +if d>=0: + if d <= b: + print(""YES"") +else: + print(""NO"") + " +p03071,s153371503,Accepted,"a,b = (int(x) for x in input().split()) +ans = 0 +for i in range(2): + ans += max([a,b]) + if ans==a: + a -= 1 + else: + b -= 1 +print(ans) +" +p03427,s567622900,Accepted,"n = input() +if n[1:] == ""9"" * (len(n)-1) : + print(int(n[0])+9*(len(n)-1)) +else : + print(int(n[0])+9*(len(n)-1)-1) +" +p03627,s787886276,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +ans=0 +import collections +c=collections.Counter(a) +values,counts=zip(*c.most_common()) +lv=list(values) +lc=list(counts) +temp=[] +for i in range(0,len(lc)): + if lc[i]>=2: + temp.append(lv[i]) +temp.sort(reverse=True) +if len(temp)>=2: + ans=temp[0]*temp[1] +print(ans)" +p03338,s957797056,Accepted,"n = int(input()) +s = list(input()) + +ans = 0 +for i in range(1,n-1): + t = len(set(s[:i]) & set(s[i:])) + if ans < t: ans = t +print(ans)" +p02663,s286115373,Accepted,"h1,m1,h2,m2,K = map(int,input().split()) +ans = (60*h2+m2) - (60*h1+m1) -K +print(ans)" +p03163,s627170189,Accepted,"import numpy as np + +N, W = map(int, input().split()) +pairs = list(tuple(map(int, input().split())) for _ in range(N)) + +dp = np.zeros((N+1, W+1), np.int64) + +for (i, (w, v)) in enumerate(pairs): + dp[i+1] = dp[i] + dp[i+1, w:] = np.maximum(dp[i+1, w:], dp[i, :W-w+1] + v) + +print(np.amax(dp[N])) +" +p02935,s146955645,Accepted,"n = int(input()) +v = [int(i) for i in input().split()] +v.sort() +ans = (v[0]+v[1])/2 +count = 0 +for i in range(2,n): + count=(ans+v[i])/2 + ans = count +if n <=2: + print(sum(v)/2) +else: + print(count)" +p02547,s210558384,Wrong Answer,"print(""YNEOS""[""000"" not in """".join([str(eval(input().replace("" "",""-"")))for _ in ""_""*int(input())])::2])" +p02995,s153528595,Accepted,"import math +def lcm(x,y): + return(x*y)//math.gcd(x,y) + +a,b,c,d=map(int,input().split()) +e=b//c-(a-1)//c +f=b//d-(a-1)//d + +g=b//lcm(c,d)-(a-1)//lcm(c,d) +ans=e+f-g +#print(e,f,g) +print(b-a+1-ans) + +" +p02646,s848824801,Accepted,"A,V = map(int,input().split()) +B,W = map(int,input().split()) +T = int(input()) + +L = abs(A - B) +S = V - W +if S * T >= L: + print(""YES"") +else: + print(""NO"")" +p03319,s657191079,Wrong Answer,"N,K=map(int,input().split()) +A=list(map(int,input().split())) +print((N-1)/(K-1)) +" +p03351,s227873549,Accepted,"a, b, c, d = map(int, input().split()) +if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d): + print(""Yes"") +else: + print(""No"")" +p02664,s489051950,Accepted,"import numpy as np +import math +import collections + +S = input() +print(S.replace(""?"", ""D"")) +" +p02659,s291502516,Accepted,"import sys +from decimal import Decimal + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 + + +def main(): + A, B = map(Decimal, readline().split()) + print(int(A * B)) + + return + + +if __name__ == '__main__': + main() +" +p03469,s670433105,Accepted,"s = input() +s = ""2018"" + s[4:] +print(s)" +p02820,s896931303,Accepted,"n, k = map(int, input().split()) +r,s,p = map(int, input().split()) +t = list(input()) + +lis = [] +for i in t: + if i == 'r': + lis.append('p') + elif i == 's': + lis.append('r') + else: + lis.append('s') + +ans1 = 0 +for i in range(k, len(lis)): + if lis[i] == lis[i-k]: + lis[i] = 'o' + +rc = lis.count('r') * r +sc = lis.count('s') * s +pc = lis.count('p') * p + +print(rc+sc+pc)" +p02661,s929653117,Accepted,"n = int(input()) +al=[] +bl=[] +for i in range(n): + a , b = map(int, input().split()) + al.append(a) + bl.append(b) +al.sort() +bl.sort() +if n%2==1: + mi = al[n//2] + ma = bl[n//2] + print(int(ma-mi)+1) +else: + mi = (al[n//2-1]+al[n//2])/2 + ma = (bl[n//2-1]+bl[n//2])/2 + print(int((ma-mi)*2+1)) +" +p03672,s034242784,Accepted,"s = input() +x = len(s) +while x > 0: + x -= 2 + s = s[:x] + if s[:x//2] == s[x//2:]: + print(x) + break +" +p02681,s335429792,Accepted,"#!/usr/bin/env python3 + +S = input() +T = input() +if S == T[:-1]: + print(""Yes"") +else: + print(""No"")" +p02882,s543698689,Wrong Answer,"from math import acos +from math import atan +a,b,x = map(int,input().split()) +x /= a +pi = acos(-1.0) +if x > a * b / 2: + print(atan(2 * (a * b - x) / (a ** 2)) * 180 / pi) +if x <= a * b / 2: + print(atan((b ** 2) / 2 * x) * 180 / pi)" +p02924,s212469610,Accepted,"n = int(input()) + +print(n*(n-1)//2)" +p03759,s306238282,Accepted,"a,b,c=[int(i) for i in input().split()] +if b-a==c-b: + print('YES') +else: + print('NO')" +p03345,s301161848,Accepted,"import sys +sys.setrecursionlimit(10000000) +MOD = 10 ** 9 + 7 +INF = 10 ** 15 + +def main(): + A,B,C,K = map(int,input().split()) + if K%2 == 0: + ans = A - B + else: + ans = B - A + if abs(ans) > 1000000000000000000: + ans = 'Unfair' + print(ans) +if __name__ == '__main__': + main()" +p03699,s495843944,Accepted,"N = int(input()) +S = [] +for i in range(N): + s = int(input()) + S.append(s) +sumS = sum(S) +if sumS % 10 != 0: + print(sumS) +else: + S = sorted(S) + flag = 0 + for j in range(N): + if S[j] % 10 != 0: + print(sumS - S[j]) + flag = 1 + break + if flag == 0: + print(0) +" +p03380,s582300771,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) + +a.sort() +m = a[-1] +import bisect +j = bisect.bisect_left(a,m//2) +if j==n-1: + j-=1 +print(m,a[j])" +p02555,s053701477,Accepted,"M = 10**9 + 7 +s = int(input()) - 3 + +f = [1] +for i in range(1, s + 1): + f.append(f[-1] * i % M) + +r = 0 +for k in range(s // 3 + 1): + r += f[s] * pow(f[k], M - 2, M) * pow(f[s - k], M - 2, M) + s -= 2 + +print(r % M) +" +p02935,s519001965,Wrong Answer,"N = int(input()) +v = list(map(int, input().split())) + +v.sort() + +print(v) + + +for i in range(N - 1): + temp = (v[0] + v[1]) / 2 + v = v[2:] + v.append(temp) + v.sort() + +print(v[0]) +" +p03107,s604386959,Accepted,"from collections import Counter + +s = list(input()) + +c0 = s.count(""0"") +c1 = s.count(""1"") + +print(min(c0, c1)*2)" +p03821,s533848494,Accepted,"n=int(input()) + +ab=[list(map(int,input().split())) for i in range(n)] + +c=[] +ans=0 +if ab[n-1][0]%ab[n-1][1]!=0: + ans+=ab[n-1][1]-(ab[n-1][0]%ab[n-1][1]) +#print(ab[n-1][0],ab[n-1][1],ans) +for i in range(n-2,-1,-1): + ab[i][0]+=ans + if ab[i][0]%ab[i][1]!=0: + + ans+=ab[i][1]-(ab[i][0]%ab[i][1]) + #print(ab[i][0],ab[i][1],ans) +print(ans)" +p03679,s721068659,Wrong Answer,"x, a, b = map(int, input().split()) +if b <= a: + print('delicious') +elif b <= x: + print('safe') +else: + print('dangerous')" +p03038,s619808629,Accepted,"n,m=map(int,input().split()) +a=sorted(list(map(int,input().split()))) +l=[list(map(int,input().split())) for i in range(m)] +l=sorted(l,key=lambda x:x[1], reverse=True) + +p=0 +comp=[] +for b,c in l: + comp+=[c]*b + p+=b + if p>=n: + break + +ans=0 +for i in range(n): + if i> i) + if i%2 == 0: + if s == 1: + S += 2**i + else: + if s == 0: + S += 2**i + i += 1 + lis.append(S) +print(*lis)" +p03386,s609504179,Accepted,"A,B,K=map(int,input().split()) +S=(set(range(A,A+K))|set(range(B-(K-1),B+1))) +S=list(S) +S.sort() + +for x in S: + if A<=x<=B: + print(x) +" +p02789,s216772682,Accepted,"def f(M,N): + if M==N: + return 'Yes' + else: + return ""No"" +N,M=map(int,input().split()) +print(f(M,N))" +p02582,s718504824,Wrong Answer,"s = input() +a = 0 +for i in range(3): + if s[i] == 'R': + a += 1 + else: + break +print(a) +" +p02608,s852390675,Wrong Answer,"n = int(input()) + +count = [0] * 10001 + +for x in range(1,101): + for y in range(1,101): + for z in range(1,101): + temp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x + if(1 <= temp and temp <= 10000): + count[temp] += 1 + +for i in range(n): + print(count[i])" +p02900,s560374787,Accepted,"import math +A, B = map(int, input().split()) +if B < A: + A, B = B, A +a = [] +while A % 2 == 0: + a.append(2) + A //= 2 +f = 3 +while f * f <= A: + if A % f == 0: + a.append(f) + A //= f + else : + f += 2 +if A != 1: + a.append(A) +ans = 0 +for i in set(a): + if B % i == 0: + ans += 1 +print(ans+1) +" +p03745,s636555816,Wrong Answer,"def solve(): + n = int(input()) + a = list(map(int, input().split())) + state, cut = -1, 0 + for i in range(n-1): + #print(i, cut, state) + if a[i] < a[i+1]: + if state != 1: + cut += 1 + state = 1 + else: + if state != 0: + cut += 1 + state = 0 + return 0 + +if __name__ == ""__main__"": + solve() +" +p04031,s635056754,Accepted,"n = int(input()) +a = sorted(list(map(int,input().split()))) +sum = 0 +List_sum = [] +Counter = [] +Count_num = (a[-1] - a[0])+1 +for i in range(Count_num): + Counter.append(a[0]+i) + if Counter[-1] == a[-1]: + break +if len(set(a)) == 1: + print(0) +else: + for i in Counter: + for j in a: + sum += (i-j)**2 + else: + List_sum.append(sum) + sum = 0 + else: + print(min(List_sum))" +p02706,s597968627,Accepted,"N,M = map(int, input().split()) + +A = list(map(int,input().split())) +T = sum(A) + +if N< T: + print(""-1"") +else: + print(N-T)" +p02744,s477165609,Accepted," +N = int(input()) +def dfs(s, l, char_num): + if l == N: + print(s) + else: + for i in range(char_num+1): + ns = s+chr(97+i) + dfs(ns, l+1, len(set(ns))) + +dfs('a',1, 1) +" +p03211,s012759263,Accepted,"s = input() +ans = 753 +for i in range(len(s)-2): + ans = min(ans, abs(int(s[i:i+3])-753)) +print(ans)" +p02854,s323042021,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +su=0 +mi=2000000 +for i in range(n): + su+=a[i] + +c=0 +for i in range(n): + c+=a[i] + left=su-c + mi=min(mi,max((c-left),(left-c))) + +print(mi) +" +p03077,s049114044,Accepted,"import math +N = int(input()) +A = int(input()) +B = int(input()) +C = int(input()) +D = int(input()) +E = int(input()) +m = max(math.ceil(N/A),math.ceil(N/B),math.ceil(N/C),math.ceil(N/D),math.ceil(N/E)) +print(m+4)" +p02987,s054646210,Wrong Answer,"# 文字列を取得 +s = input() + +# バラバラにして並び替え +slist = list(s) +slist.sort() +print(slist) + +if slist[0] == slist[1] and slist[2] == slist[3] and slist[0] != slist[2]: + print(""Yes"") +else: + print(""No"")" +p02693,s469949702,Accepted,"import math +K = int(input()) +A,B = list(map(int,input().split())) +num = 0 +while num <=2000: + num += K + if num >1000: + print(""NG"") + break + if num <= B and A <= num: + print(""OK"") + break + else: + continue" +p02924,s517151040,Wrong Answer,"n = int(input()) +print(int(n*(n-1)/2))" +p03611,s955695578,Accepted,"N=int(input()) +a=list(map(int,input().split())) +dp=[0]*(10**5+3) +for i in range(N): + for j in range(3): + dp[a[i]+j]+=1 +print(max(dp))" +p02881,s885261601,Accepted,"n = int(input()) +tmp = 1 + +for i in range(1,10**6+1): + if n%i == 0: + if i <= n//i: + tmp = i + else: + break + elif tmp == 1 and i >= n/i: + break + +print(tmp + (n//tmp) -2)" +p03679,s779910462,Accepted,"x, a, b = map(int, input().split()) +if b <= a: + print(""delicious"") +elif b - a <= x: + print(""safe"") +elif b - a > x: + print(""dangerous"")" +p03605,s950887002,Accepted,"n = input() +if n[0] == '9' or n[1] == '9': + print(""Yes"") +else: + print(""No"")" +p03657,s510292674,Accepted,"a,b = map(int,input().split()) +dum = a+b +if a % 3 == 0 or b % 3 == 0 or dum % 3 == 0: + print(""Possible"") +else: + print(""Impossible"")" +p02603,s160747414,Wrong Answer,"n,*a=map(int,open(0).read().split()) +ans=1000 +num= 0 +for i in range(n): + if i == n-1: + if a[i-1]ans: + continue + elif a[i] == a[i+1]: + continue + else: + ans += num*a[i] + +print(ans) +" +p03835,s405142123,Accepted,"K, S = map(int, input().split()) +cnt = 0 +for x in range(K+1): + for y in range(min(K,S-x)+1): + z = S - x - y + if z <= K: + cnt += 1 +print(cnt)" +p03000,s400381042,Accepted,"def main(): + from itertools import takewhile + + N, X = map(int, input().split()) + *L, = map(int, input().split()) + + def accumulate(a): + s = 0 + yield s + for x in L: + s += x + yield s + + ans = len(tuple(takewhile(lambda s: s <= X, accumulate(L)))) + + print(ans) + + +if __name__ == '__main__': + main() +" +p02866,s805010695,Wrong Answer,"from collections import Counter +n = int(input()) +lst = list(map(int,input().split())) +mod = 998244353 +c = dict(Counter(lst)) +c = dict(sorted(c.items(), key=lambda x:x[0])) + +ans = 1 +pre_v = 1 +for e,(k,v) in enumerate(c.items()): + print(e,k,v) + if e==0 and k!=0: + ans = 0 + break + elif e!=k: + ans = 0 + break + else: + ans = ans*pow(pre_v, v, mod)%mod + pre_v = v +print(ans%mod)" +p03720,s269699198,Accepted,"n, m = map(int, input().split()) + +roads = [0 for i in range(n)] +for i in range(m): + a, b = map(int, input().split()) + roads[a-1] += 1 + roads[b-1] += 1 + +for road in roads: + print(road)" +p03943,s637725127,Accepted,"As = sorted(list(map(int, input().split()))) +if As[0] + As[1] == As[2]: + print(""Yes"") +else: + print(""No"")" +p03408,s682331540,Accepted,"n = input() +red = [] +for i in range(n): + red.append(raw_input()) +k = input() +blue = [] +for j in range(k): + blue.append(raw_input()) +ans = 0 +for r in red: + counterR = 0 + counterB = 0 + for word in red: + if word == r: + counterR += 1 + for word in blue: + if word == r: + counterB += 1 + if ans < counterR - counterB: + ans = counterR - counterB +print ans" +p02747,s005262631,Accepted,"S=[i for i in input()] +flg = True +while len(S)>=2: + if S[0]==""h"" and S[1]==""i"": + del S[0:2] + else: + flg = False + break +if flg and len(S)==0: + print(""Yes"") +else: + print(""No"")" +p03673,s011667723,Accepted,"n = int(input()) +a = list(map(int, input().split())) +if len(a) == 1: + res = a[0] +elif len(a) % 2 == 0: + res = "" "".join(map(str, a[-1::-2] + a[::2])) +else: + res = "" "".join(map(str, a[-1::-2] + a[1::2])) +print(res)" +p02923,s966628730,Accepted,"N=int(input()) +s=list(map(int, input().split())) + +maxans=0 +pre=s[0] +tmpans=0 +for i in range(1,N): + now=s[i] + if pre>=now: + tmpans+=1 + else: + tmpans=0 + pre=now + maxans=max(tmpans, maxans) +print(maxans)" +p02753,s284326335,Accepted,"s = input() +if (s[0]==s[1] and s[1]==s[2]): + print(""No"") +else: + print(""Yes"")" +p03645,s565693111,Wrong Answer,"import sys +stdin = sys.stdin +ni = lambda: int(ns()) +na = lambda: list(map(int, stdin.readline().split())) +nn = lambda: list(stdin.readline().split()) +ns = lambda: stdin.readline().rstrip() +sys.setrecursionlimit(10**6) + +n,m = na() +g = [[] for i in range(n)] +for i in range(m): + a,b = na() + a,b = a-1,b-1 + g[a].append(b) + g[b].append(a) + +for i in g[0]: + if n-1 in g[i]: + print('POSSIBLE') + exit() + +print('INPOSSIBLE')" +p03161,s475186976,Wrong Answer,"def min_cost(h, n, k): + dp = [10**6 for i in range(n)] + dp[0] = 0 + for i in range(1, n): + for k in range(1, k + 1): + if (i - k) >= 0: + dp[i] = min(abs(h[i] - h[i - k]) + dp[i - k], dp[i]) + + + print(dp[n - 1]) + +n, k = list(map(int, input().split())) +h = list(map(int, input().split())) +min_cost(h, n, k) + +" +p03592,s887119009,Accepted,"n, m, k = map(int, input().split()) +ok = False +for i in range(n+1): + for j in range(m+1): + if k == (n*j + m*i) - 2*i*j: + ok = True + +if ok: + print('Yes') +else: + print('No')" +p02753,s007319177,Accepted,"S = input() + +if S=='AAA' or S=='BBB': + print('No') +else: + print('Yes')" +p03815,s267809849,Accepted,"import sys +import itertools +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +import math +import collections +MOD = 10**9 + 7 +x = int(input()) +cnt = 0 +if x<=6: + print(1) +elif x<=11: + print(2) +else: + if x%11 == 0: + print((x//11)*2) + elif x%11 > 6: + print(((x//11)+1)*2) + else: + print((x//11)*2 + 1)" +p02633,s490943019,Wrong Answer,"t=int(input()) +if(360%t==0): + print(int(360/t)) +else: + t=360/t + s=360%t + print(int(t)*s) + +" +p03944,s671065167,Accepted,"w,h,n = map(int,input().split()) +A = [list(map(int,input().split())) for _ in range(n)] + +xmin,xmax,ymin,ymax = 0,w,0,h + +for a in A: + if a[2] == 1: + xmin = max(xmin, a[0]) + if a[2] == 2: + xmax = min(xmax, a[0]) + if a[2] == 3: + ymin = max(ymin, a[1]) + if a[2] == 4: + ymax = min(ymax, a[1]) + +S = (xmax-xmin) * (ymax-ymin) +if S < 0 or xmin > xmax or ymin > ymax: + S = 0 +print(S)" +p03951,s534575082,Accepted,"n=int(input()) +s=input() +t=input() +ans=0 +for i in range(n): + if s[i:] == t[:n-i]: + ans = max(n-i,ans) +print(2*n-ans)" +p03472,s540922741,Accepted,"n, h = map(int, input().split()) +a = [0]*n +b = [0]*n +for i in range(n): + a[i], b[i] = map(int, input().split()) + +a.sort(reverse=True) +b.sort(reverse=True) +ans = 0 +while True: + if h <= 0: + break + if len(b) != 0 and b[0] > a[0]: + c = b.pop(0) + h -= c + ans += 1 + else: + ans += h // a[0] + if h%a[0] != 0: + ans += 1 + break + +print(ans)" +p03162,s931372853,Accepted,"n = int(input()) +ABC = [list(map(int, input().split())) for i in range(n)] + +# i日目にjを選択した後の幸福度 dp[i][j] +dp = [[0 for j in range(3)] for i in range(n + 1)] + +for i in range(n): + for j in range(3): + for k in range(3): + if j == k: + continue + dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k]) + +print(max(dp[-1])) +" +p02681,s367590949,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + s=input() + t=input() + if t[:-1]==s: + print('Yes') + else: + print('No') +resolve()" +p03681,s196597727,Wrong Answer,"n, m = map(int, input().split()) + +def lp(animal, row): + for i in range(1, n+1): + row *= i + return row + +result = abs(n-m) +limit = 10**9+7 +row = 1 +if result >= 2: + print(0) +elif result == 1: + row = lp(n, row) + row = lp(m, row) +elif n == m: + row = lp(n, row) + row = lp(m, row) + row *= 2 + +print(row%limit) +" +p03696,s003888438,Wrong Answer,"n, s = int(input()), input() +t = s.lstrip("")"").rstrip(""("") +a, b = map(t.count, ""()"") +x, y = map(s.count, ""()"") +x -= a +y -= b +if a>b: + a -= b + b = 0 +else: + b -= a + a = 0 +print(""(""*(b+y) + s + "")""*(a+x))" +p02922,s931275177,Accepted,"import math +A, B = map(int,input().rstrip().split()) +ans = math.ceil((B-1)/(A-1)) +print(ans)" +p02693,s784159113,Wrong Answer,"K=int(input()) +A,B=map(int,input().split()) +i=0 +ok=0 +while i*K <= B: + if A <= i*K <= B: + print(""OK"") + ok=1 + i=i+1 +if ok!=1: + print(""NG"")" +p02797,s548875738,Accepted,"N,K,S=map(int,input().split()) +ans=[] + +if S<10**9: + ans=[S for i in range(K)] + ans+=[S+1 for i in range(N-K)] +else: + ans=[S for i in range(K)] + ans+=[1 for i in range(N-K)] + +print(*ans)" +p02622,s382840938,Accepted,"s = input() +t = input() +r = 0 +for i in range(len(s)): + if s[i] != t[i]: + r += 1 +print(r)" +p03944,s209774613,Wrong Answer,"X,Y,N=map(int,input().split()) +max_X=X +max_Y=Y +current_min_x=0 +current_min_y=0 +current_max_x=X +current_max_y=Y +xy=[list(map(int,input().split())) for _ in range(N)] +for x,y,a in xy: + n=0 + if a==1: + current_min_x=max(current_min_x, x) + elif a==2: + current_max_x=min(current_max_x, x) + elif a==3: + current_min_y=max(current_min_y, y) + elif a==4: + current_max_y=min(current_max_y, y) +result=(current_max_x-current_min_x)*(current_max_y-current_min_y) +print(result if result > 0 else 0)" +p02797,s289797279,Accepted,"N, K, S = map(int, input().split()) +a = [S for i in range(K)] +if S == 10 ** 9: + S -= 2 +for i in range(N - K): + a.append(S + 1) +print(*a) +" +p02598,s616426452,Accepted,"import math + +N, K = map(int, input().split()) +A = sorted(list(map(int, input().split()))) + +max_l = max(A) + 1 +min_l = 0 +cur = (max_l + min_l) // 2 + + +def check(l): + count = 0 + for a in A: + count += math.ceil(a / l) - 1 + + return count <= K + + +while True: + if check(cur): + max_l = cur + 1 + else: + min_l = cur + + if cur == (max_l + min_l) // 2: + break + + cur = (max_l + min_l) // 2 + +print(cur) +" +p03059,s903584531,Accepted,"a, b, t = map(int, input().split()) +print((t//a)*b) +" +p02608,s608057869,Accepted,"n = int(input()) +arr = [0]*10100 +for i in range(1,110): + for j in range(1,110): + for k in range(1,110): + s = i*i+j*j+k*k+i*j+j*k+k*i; + if s<10100: + arr[s]+=1 +for i in range(n): + print(arr[i+1]) +" +p02555,s886859842,Accepted,"MOD = 10**9+7 + +S = int(input()) +memo = {1:0,2:0,3:1,4:1,5:1} + +def Redi(n): + if n in memo: + return memo[n] + else: + ans = 1 + for i in range(3,n-2): + ans += Redi(n-i) + memo[n] = ans % MOD + return memo[n] + +print(Redi(S))" +p03289,s340041961,Accepted,"import sys +input = sys.stdin.readline + +S = input().rstrip() +S32 = S[2:-1] +trimed_S = S32.replace('C', '', 1) +ac_cut_S = S.replace('A', '', 1).replace('C', '', 1) + +ans = 'AC' +if S[0] != 'A': + ans = 'WA' +elif (not ac_cut_S.islower()) or len(S32) - len(trimed_S) != 1: + ans = 'WA' + +print(ans) +" +p02973,s330355198,Wrong Answer,"from bisect import bisect_left, bisect_right + +def LIS(arr): #bisect.bisect_left + n = len(arr) + lis = [-10**18] + for a in arr: + if a >= lis[-1]: + lis.append(a) + else: + lis[bisect_left(lis, a)] = a + return len(lis) - 1 + +import sys +input = sys.stdin.readline + +N = int(input()) +A = [-int(input()) for _ in range(N)] + +print(LIS(A))" +p02683,s528348429,Wrong Answer,"n, m, x = map(int, input().split()) +bk = [list(map(int, input().split())) for _ in range(n)] +pr = 10 ** 6 +for i in range(2 ** n): + ef = [0] * (m + 1) + for j in range(n): + if i >> j & 1: + ef = [p + q for (p, q) in zip(ef, bk[j])] + for k in range(1, m + 1): + if ef[k] < x: + break + if k == m: + pr = min(pr, ef[0]) +print(pr if pr != 10 ** 6 else -1)" +p02818,s741071209,Accepted,"A, B, K = list(map(int,input().split())) + +# A から Kを引く +A = A - K +# Aが負なら,その負の大きさの分だけBから引く +if A < 0: + B = B + A + A = 0 +# Bが負なら0にする +if B < 0: B = 0 + +print(A,B)" +p03760,s299315358,Accepted,"o = str(input()) +e = str(input()) +s = [] +for i in range(len(e)): + s.append(o[i]) + s.append(e[i]) +if len(o) > len(e): + s.append(o[-1]) +print(*s, sep = """")" +p03252,s207815730,Wrong Answer,"S = input() +T = input() +L = [c for c in S if c not in T] +L2 = [c for c in T if c not in S] +if len(L) != len(L2): + print(""No"") +else: + print(""Yes"")" +p03971,s761222068,Wrong Answer,"n,a,b=map(int,input().split()) +s=input().strip() +njp=0 +nop=0 +for i in range(len(s)): + if s[i]=='a': + if njp<(a+b): + njp+=1 + print('Yes') + else: + print('No') + elif s[i]=='b': + if njp<(a+b): + if nop<=b: + nop+=1 + njp+=1 + print('yes') + else: + print('No') + else: + print('No') + else: + print('No') +" +p03474,s001740744,Wrong Answer,"li = [""0"",""1"",""2"",""3"",""4"",""5"",""6"",""7"",""8"",""9""] +a,b = map(int,input().split()) +s = input() +for i in range(a+b): + if i != a: + if s[i] not in li: + print(""No"") + exit() +print(""Yes"")" +p03471,s860842053,Wrong Answer,"N,Y = map(int, input().split()) +ans= [-1, -1, -1] + +for x in range(N+1): + for y in range(N-x+1): + price = x*10000 + y*5000 + int(N-x-y)*1000 + if price == Y: + print(x,y,N-x-y) + break +" +p02723,s951420102,Accepted,"s = input() + +if s[2] == s[3] and s[4] ==s[5]: + print('Yes') +else: + print('No')" +p02801,s420709405,Accepted,"import string +c = input() +abc_list = list(string.ascii_lowercase) +for num,string in enumerate(abc_list): + if string == c: + print(abc_list[num+1])" +p02714,s138921873,Wrong Answer,"n = int(input()) +s = input() +r = s.count('R') +g = s.count('G') +b = s.count('B') +ans = r*g*b +for i in range(n-3): + for j in range(i+1,n-1): + k = 2*j-i + if k < n: + if s[i] != s[j] and s[j]!= s[k] and s[i] != s[k]: + ans -= 1 +print(ans)" +p02705,s483578318,Accepted,"import math +R = int(input()) + +print(2*R*math.pi)" +p02624,s940852597,Accepted,"N = int(input()) + +ans = 0 + +for i in range(1,N+1): + cnt = N // i + ans += i*cnt*(cnt+1)//2 + +print(ans)" +p02983,s332358569,Accepted,"def main(): + l, r = map(int, input().split()) + minv = 2019 + if r - l > 2019+1: + print(0) + else: + for i in range(l, r+1): + for j in range(l, r+1): + if i < j: + minv = min(minv, (i*j)%2019) + print(minv) + +if __name__ == '__main__': + main()" +p02658,s006665221,Accepted,"if __name__ == ""__main__"": + N = int(input()) + num_list = list(map(int, input().split())) + ans = 1 + MAX = 1e18 + for i in num_list: + ans = ans*i + if ans > MAX: + ans = -1 + break + if 0 in num_list: + print(0) + else: + print(ans)" +p02835,s711047461,Wrong Answer,"A1, A2, A3 = map(int, input().split()) +print(A1+A2+A3)" +p02982,s420888493,Wrong Answer,"n,d=map(int,input().split()) +point=[] +for _ in range(n): + point.append(list(map(int,input().split()))) +ans=0 +for i in range(n-1): + for l in range(1,n): + if i==l: + continue + dis=0 + for f in range(d): + dis+=(point[i][f]-point[l][f])**2 + dis=dis**0.5 + #print(dis) + if dis.is_integer(): + ans+=1 +print(ans)" +p03076,s014124650,Accepted,"abcde=[int(input()) for i in range(5)] +ans=0 +m=10 +for i in abcde: + ans += (i+9)//10*10 + m=min(m,(i-1)%10+1) +print(ans-10+m)" +p02747,s228329218,Accepted,"s=input() +if len(s)%2!=0: + print('No') + exit() +else: + for i in range(len(s)//2): + if not (s[2*i]=='h' and s[2*i+1]=='i'): + print('No') + exit() + print('Yes')" +p02786,s524954850,Accepted,"# -*- coding: utf-8 -*- +H = int(input()) +h = H +count = 1 +total_count = count +while h > 1: + count *= 2 + total_count += count + h //= 2 +print(total_count)" +p03817,s326073627,Accepted,"from math import ceil +x = int(input()) +ans = x // 11 * 2 +ans += ceil((x%11)/6) +print(ans)" +p03012,s180847990,Wrong Answer,"n = int(input()) +w = list(map(int, input().split())) +s = [0] +for i in range(n): + s.append(w[i] + s[i]) + +for i in range(n+1): + if(2*(s[i]) > s[n]): + t = i + break +print(abs(s[n] - 2*(s[t])))" +p02784,s652552899,Accepted,"h,n=input().split() +h=int(h) +n=int(n) +#print(h,n) +arr=list(map(int,input(""\r"").strip().split()))[:n] +sum=0; +for i in range(0,n): + # print(arr[i]) + sum+=arr[i] + +if sum>=h: + print(""Yes"") +else: + print(""No"") + + " +p03327,s938243202,Accepted,print('ABD' if int(input())>999 else 'ABC') +p03146,s580243201,Accepted,"s = int(input()) +a = [] +a.append(s) +ans = 0 +while True: + if a[ans]%2==0: + if a[ans]//2 in a: + print(ans+2) + break + a.append(a[ans]//2) + else : + if 3*a[ans]+1 in a: + print(ans+2) + break + a.append(3*a[ans]+1) + ans+=1" +p03062,s663015523,Accepted,"import sys +input = sys.stdin.readline + +N = int(input()) +A = list(map(int,input().split())) +cnt = 0 +for i,a in enumerate(A): + if a<0: + cnt += 1 + A[i] = -1*a +A = sorted(A) +print(sum(A)-2*A[0]*(cnt%2))" +p03730,s680852114,Accepted,"a, b, c = [int(i) for i in input().split()] + +exist = False +for i in range(1,b+1): + + if i*a % b == c: + exist = True + +if exist: + print(""YES"") +else: + print(""NO"")" +p02583,s623553033,Accepted,"n = int(input()) +L = list(map(int, input().split())) +result = 0 +for i in range(n): + for j in range(i + 1, n): + for k in range(j + 1, n): + a = L[i] + b = L[j] + c = L[k] + if a == b or b == c or c == a: + continue + if a+b > c and b+c > a and c+a > b: + result += 1 + # print(i, j, k) + +print(result) +" +p02631,s404739423,Accepted,"N=int(input()) +A=list(map(int, input().split())) +a=A[0] +for i in range(1,N): + a=a^A[i] +D=[] +for i in range(N): + D.append(a^A[i]) +print(*D)" +p02697,s823399738,Accepted,"#!/usr/bin/env python3 +import sys, math, itertools, collections, bisect +input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') +inf = float('inf') ;mod = 10**9+7 +mans = inf ;ans = 0 ;count = 0 ;pro = 1 + +n,m = map(int,input().split()) +if n % 2 == 1: + a = 1; b = n + for i in range(m): + print(a,b) + a += 1;b -= 1 +else: + a = 1; b = n + tmp = n + while b-a > n//2: + print(a,b) + a += 1 + b -= 1 + count += 1 + if count >= m:exit() + b-=1 + for i in range(m-count): + print(a,b) + a += 1 + b -= 1 +" +p02946,s844610077,Accepted,"k,x = list(map(int,input().split())) +for i in range (x-k+1,x+k): + print (i)" +p03998,s874204292,Accepted,"strs = [input() for _ in range(3)] +idxs = [0,0,0] +turn = 0 +while True: + idx = idxs[turn] + if idx >= len(strs[turn]): + break + card = strs[turn][idxs[turn]] + idxs[turn] += 1 + + if card == 'a': + turn = 0 + elif card == 'b': + turn = 1 + else: + turn = 2 + +print(['A','B','C'][turn])" +p02994,s633307870,Accepted,"N, L = map(int, input().split()) + +total = N * (L - 1) + N * (N + 1) / 2 +lowest = 10 ** 10 +for i in range(1, N + 1): + y = L + i - 1 + lowest = min(lowest, abs(y)) +print(int(total) - lowest) if total >= 0 else print(int(total) + lowest)" +p03145,s771257428,Accepted,"a,b,c = map(int,input().split()) + +print(int(a * b * 0.5))" +p03854,s505972643,Accepted,"S = input()[::-1] +D = [""dream""[::-1], ""dreamer""[::-1], ""erase""[::-1], ""eraser""[::-1]] +while True: + for d in D: + if S.startswith(d): + S = S.replace(d, """", 1) + break + else: + break +print(""YNEOS""[S!=""""::2])" +p02633,s966734421,Accepted,"import math +n=int(input()) +if 1 < math.gcd(360,n) < 360: + print(360//math.gcd(360,n)) +else: + print(360)" +p03109,s371465885,Accepted,"s=input() +if int(s[5:7])<5: + print(""Heisei"") +else: + print(""TBD"")" +p02618,s054967411,Accepted,"import random +ans=0 +d=int(input()) +c=list(map(int,input().split())) +s=[] +for i in range(d): + List=list(map(int,input().split())) + s.append(List) +for i in range(d): + ans=random.randint(1,26) + print(ans)" +p03427,s356852510,Accepted,"N = input() +if all([n == '9' for n in N]): + print(9 * len(N)) +else: + print(max(9 * (len(N) - 1) + (int(N[0]) - 1), sum(list(map(int, N)))))" +p02959,s051125470,Accepted,"# Code for C - City Savers +# Use input() to fetch data from STDIN +n = input() +a = [int(x) for x in input().split()] +b = [int(x) for x in input().split()] + +total = 0 +for i in range(len(a) - 1): + s = min(a[i], b[i]) + a[i] = a[i] - s + b[i] = b[i] - s + + t = min(a[i+1], b[i]) + a[i+1] = a[i+1] - t + b[i] = b[i] - t + total += s + t + + +print(total) +" +p03038,s884393803,Accepted,"N, M = map(int, input().split()) +from collections import* +c = Counter(map(int, input().split())) +for _ in range(M): + B, C = map(int, input().split()) + c[C] = c[C] + B if C in c else B +s = 0 +for i in sorted(c.items())[::-1]: + m = min(i[1], N) + s += i[0] * m + N -= m +print(s) +" +p02702,s756260032,Accepted,"s=list(input()) +mod=2019 +A=[0]*2019 +a=0 +b=1 +for i in range(len(s)): + a=(a+int(s[-1-i])*b)%mod + A[a]+=1 + b=b*10%mod +ans=A[0]*(A[0]+1)//2 +for i in range(1,2019): + if A[i]!=0: + ans=ans+(A[i]-1)*A[i]//2 +print(ans)" +p04011,s183105695,Accepted,"a=int(input()) +b=int(input()) +c=int(input()) +d=int(input()) +ans=0 +if a<=b: + ans=a*c +else: + ans=b*c+(a-b)*d +print(ans)" +p02880,s531117289,Accepted,"N=int(input()) +for i in range(1,10): + if N%i==0 and N/i<=9: + print(""Yes"") + break +else: + print(""No"")" +p03105,s164152524,Accepted,"a, b, c = map(int, input().split()) +print(min(c, b//a))" +p03659,s580342815,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +x = A[0] +y = sum(A[1:]) + +c=x-y +ans=abs(c) + +for i in range(1,N-1): + c+=2*A[i] + if abs(c)< abs(ans): + ans = abs(c) + +print(ans)" +p02787,s381545355,Accepted,"H, N = map(int, input().split()) +A, B = [], [] +for i in range(N): + a, b = map(int, input().split()) + A.append(a) + B.append(b) + +# dp +INF = 1 << 30 +dp = [INF] * (H + 1) # dp[i]: モンスターの体力を i 減らすため消耗する魔力の最小値 +dp[0] = 0 +for h in range(H + 1): + for n in range(N): + dp[h] = min(dp[h], B[n] + dp[max(h - A[n], 0)]) + +print(dp[H])" +p02982,s484176973,Accepted,"import itertools +N, D = map(int, input().split()) +count = 0 + +X = [] +for i in range(N): + X.append(list(map(int, input().split()))) + +for i in list(itertools.combinations(X, 2)): + f = 0 + for j in range(D): + f += (i[0][j]-i[1][j])**2 + f **= 0.5 + if f.is_integer(): + count += 1 +print(count)" +p03797,s204753999,Wrong Answer,"N,M = [int(i) for i in input().split()] +S = 0 + +if N <= 2*M: + S = N + (M - 2*N)//4 +else: + if N > M//2: + S = M//2 + else: + S = N + +print(S) +" +p03645,s955547586,Wrong Answer,"from collections import deque + +n,m = map(int, input().split()) +G = [[] for _ in range(n)] +for i in range(m): + a,b = map(int, input().split()) + a-=1 + b-=1 + G[a].append(b) + G[b].append(a) + +dist = [-1]*n +que = deque() +dist[0]=0 +que.append(0) +while len(que): + v = que.pop() + for node in G[v]: + if dist[node]==-1: + dist[node]=dist[v]+1 + que.append(node) + +if dist[-1]==2: + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"")" +p02787,s648326017,Accepted,"h,n = map(int,input().split()) +P = [] +M = [] + +for i in range(n): + p,m = map(int,input().split()) + P.append(p) + M.append(m) + +dp=[[999999999]*(h+1) for _ in range(n+1)] +dp[0][0] = 0 +for i in range(n): + for j in range(h+1): + dp[i+1][j] = min(dp[i+1][j],dp[i][j]) + dp[i+1][min(j+P[i],h)] = min(dp[i+1][min(j+P[i],h)],dp[i+1][j] + M[i] ) + +print(dp[n][h])" +p02723,s006985816,Wrong Answer,"def main(): + S = input() + if S[2] == S[3] and S[4] == S[4]: + print(""Yes"") + else: + print(""No"") + + +if __name__ == ""__main__"": + main() +" +p02678,s445260300,Accepted,"import networkx as nx +n,m,*s = map(int, open(0).read().split()) + +g=nx.Graph() +g.add_nodes_from([i for i in range(1,n+1)]) +for x in zip(*[iter(s)] * 2): + g.add_edge(x[0],x[1]) +di=nx.predecessor(g,source=1) + +if len(di)!=n: + print(""No"");exit() +print(""Yes"") +for x in range(2,n+1): + print(di[x][0])" +p03860,s010797992,Accepted,print(input('A')[8]+'C') +p02796,s897895351,Wrong Answer,"n = int(input()) +ans = n +d = {} +for i in range(n): + x,l = map(int, input().split()) + d[x] = l +if n == 1: + print(ans) +else: + s = list(d.keys()) + s.sort() + st = s[0]-d[s[0]] + gl = s[0]+d[s[0]] + for i in s[1:]: + if st 1: + PRIME.add(N) + return PRIME + + +a, b = map(int, input().split()) + +ans = factorize(a) & factorize(b) +print(len(ans) + 1) +" +p03289,s871322209,Wrong Answer,"s = input() +count1 = 0 +count2 = 0 +count3 = 0 +count4 = 0 +if s[0] == 'A'and s[1].islower() == True: + count1 += 1 +for i in range(2, len(s) - 2): + if (s[i] == 'C'): + count2 += 1 +for i in range(len(s) - 2, len(s)): + if s[i].islower() == True: + count3 += 1 +if count1 != 1 or count2 != 1 or count3 != 2: + print('WA') +else: + print('AC') + +" +p02755,s369631879,Accepted,"a,b=map(int,input().split()) +def ceil(x): + if x%1==0: + return x//1 + else: + return x//1+1 +a1=int(ceil(a*100/8)) +a2=int(ceil((a+1)*100/8)-1) +b1=int(ceil(b*100/10)) +b2=int(ceil((b+1)*100/10)-1) +count=0 +for i in range(a1,a2+1): + if b1<=i<=b2: + print(i) + count=0 + break + else: + count+=1 +if count!=0: + print(-1)" +p03136,s147709965,Accepted,"n = int(input()) +l = list(map(int,input().split())) +x = max(l) +if sum(l)-x>x: + print('Yes') +else: + print('No')" +p02718,s097496938,Accepted,"a=list(map(int,input().split())) +n=a[0] +m=a[1] +touhyou=list(map(int,input().split())) +s=float(sum(touhyou)/4/m) +list=[] +for i in touhyou: + if i>=s: + list.append(i) +if len(list)>=m: + print(""Yes"") +else: + print(""No"" ) +" +p03145,s539167148,Accepted,"a, b, c = map(int, input().split()) + +s = (a+b+c)/2 +S = s*(s-a)*(s-b)*(s-c) + +print(int(S**0.5))" +p02838,s494456840,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) + +sum_ = 0 +for i in range(n-1): + for j in range(i,n): + sum_ += a[i] ^ a[j] +print(int(sum_%(1e9+7)))" +p03860,s755019740,Accepted,"s = list(input().split()) +print(s[0][0]+s[1][0]+s[2][0])" +p02639,s645969479,Wrong Answer,"n=list(map(int,input().split())) +for i in range(len(n)): + if n[i]==0: + print(i) + break" +p03627,s494593163,Accepted,"from collections import Counter +n = int(input()) + +a = list(map(int, input().split())) +c = Counter(a) +f = [0,0] +for k in c.keys(): + if c[k] >= 2: + f.append(k) + if c[k] >= 4: + f.append(k) + +f.sort() + +[a, b] = f[-2:] + +print(a*b)" +p04031,s961492903,Wrong Answer,"from math import ceil + +n = int(input()) +numeros = list(map(int, input().split())) + +y = ceil(sum(numeros)/n) +soma = 0 +for v in numeros: + soma += (v-y)**2 + +print(soma) + + +" +p02899,s917696843,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = [0] * n + +for i in range(n): + ans[a[i]-1] = i+1 + +print(*ans)" +p03632,s731743735,Accepted,"a, b, c, d = map(int, input().split()) + +if a < d and c < b: + if b < d: + if a < c: + print(b - c) + else: + print(b - a) + else: + if a < c: + print(d - c) + else: + print(d - a) +else: + print(0) +" +p02627,s769528383,Accepted,"a = input() +if a == a.upper(): + print(""A"") +else: + print(""a"")" +p02832,s326429380,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +ans=[0]*n +c=1 +for i in range(n): + if a[i]==c: + ans[i]=1 + c+=1 +print(n-sum(ans)) " +p02768,s427670018,Accepted,"def framod(x,y,p=10**9+7): + for i in range(x+1,y+1): + x = (x*i)%p + return x + +######################################### + +n,a,b=map(int,input().split()) +p=10**9+7 + +ans=0 +for i in [a,b]: + upper = framod(n-i+1,n,p) + lower = framod(1,i,p) + ret = (upper*pow(lower,p-2,p))%p + ans = (ans+ret)%p +print((pow(2,n,p)-ans-1)%p)" +p02848,s972200489,Accepted,"n = int(input()) +s = str(input()) + +h = ""abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"" +h = h.upper() +ans = str("""") + +for i in range(len(s)): + for j in range(26): + if s[i] == h[j]: + ans +=h[j+n] + continue + +print(ans) +" +p03103,s440438106,Accepted,"import sys + + +def input(): + return sys.stdin.readline().strip() + + +N, M = map(int, input().split()) +drinks = sorted(tuple(map(int, input().split())) for _ in range(N)) +ans = 0 +for A, B in drinks: + if M > B: + ans += A * B + M -= B + else: + ans += A * M + break +print(ans) +" +p03327,s240609825,Wrong Answer,"N = int(input()) + +if 999 >= N >= 100: + print(""ABC"" + str(N)) +if 99 >= N >= 10: + print(""ABC0"" + str(N)) +if 9 >= N >= 1: + print(""ABC00"" + str(N)) +if 1008 >= N >= 1000: + M = N - 999 + print(""ABD00"" + str(M)) +if 1098 >= N >= 1009: + M = N - 999 + print(""ABD0"" + str(M)) +if 1998 >= N >= 1099: + M = N - 999 + print(""ABD"" + str(M))" +p04031,s331454693,Wrong Answer,"import math +n = int(input()) +*a, = map(int, input().split()) + +ave = math.ceil(sum(a)/n) + +ans = 0 +for _a in a: + ans += (ave-_a)**2 + +print(ans) +" +p03001,s403802814,Accepted,"W, H, x, y = map(int, input().split()) +print(W*H/2, int(2*x == W and 2*y == H)) +" +p03449,s851390682,Accepted,"n = int(input()) +a1 = list(map(int,input().split())) +a2 = list(map(int,input().split())) +ame = 0 +for i in range(n): + get = sum(a1[0:i+1])+sum(a2[i:n]) + ame = max(ame,get) +print(ame)" +p03077,s397934324,Wrong Answer,"n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +import math +t1 = math.ceil(n/a) +t2 = t1+max(1,math.ceil(n/b-t1+1)) +t3 = t2+max(1,math.ceil(n/c-t1+2)) +t4 = t3+max(1,math.ceil(n/d-t1+3)) +t5 = t4+max(1,math.ceil(n/e-t1+4)) + +print(t5) +" +p04011,s718411003,Wrong Answer,"n,k,x,y = map(int, open(0)) +print(k*x+(n-k)*y)" +p02708,s919900241,Accepted,"def II(): return int(input()) +def MI(): return map(int, input().split()) +N,K=MI() +ans=0 +MOD=10**9+7 +for i in range(K,N+2): + x=(N+1-i)*i+1 + ans+=x + ans%=MOD +print(ans)" +p02727,s344254532,Accepted,"X, Y, A, B, C = map(int, input().split()) +P = sorted(list(map(int, input().split())), reverse=True) +Q = sorted(list(map(int, input().split())), reverse=True) +R = sorted(list(map(int, input().split())), reverse=True) +print(sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X+Y]))" +p02596,s218099749,Wrong Answer,"k=int(input()) + +if (k%2==0) or (k%5==0): + print(-1) + exit() + +if k%7==0: + k//=7 + +o=0 +m=1 +if k==1: + print(1) + exit() + +for i in range(1,k): + m*=10 + o+=m%k + o%=k + if o==0: + print(i) + exit()" +p02646,s725044976,Wrong Answer,"a, v = map(int, input().split()) +b, w = map(int, input().split()) +t = int(input()) + +#print((v-w) // (b-a), v-w, b-a) +if (b-a) <= t*(v-w): + print(""YES"") +else: + print(""NO"")" +p02765,s834015526,Accepted,"i = list(map(int, input().split())) +if 1 <= i[0] and i[0] <= 100: + N = i[0] +else: + print('N is invalid value.') +if 0 <= i[1] and i[1] <= 4111: + R = i[1] +else: + print('R is invalid value.') + +if N < 10: + rate = R + (100 * (10 - N)) +else: + rate = R + +print(rate)" +p03617,s927047914,Wrong Answer,"q,h,s,d = map(int,input().split()) +n = int(input()) + +cost = {} +cost[""2""] = d +cost[""1""] = s * 2 +cost[""0.5""] = h * 4 +cost[""0.25""] = q * 8 +cost = sorted(cost.items() , key=lambda x:x[1]) + +ans = 0 + +for i in cost: + L = float(i[0]) + C = i[1] * L // 2 + + if L <= n: + ans += C * (n//L) + n %= L + +print(int(ans))" +p03719,s923830397,Wrong Answer,"a,b,c=map(int,input().split()) +print('NYoe s'[ac::2])" +p03069,s826637213,Accepted,"def Z(): return int(input()) +def ZZ(): return [int(_) for _ in input().split()] + +def main(): + N = Z() + s = input() + a, b = [0], [0] + for i in range(N): + if s[i] == '#': a.append(a[-1]+1) + else: a.append(a[-1]) + + if s[-1-i] == '.': b.append(b[-1]+1) + else: b.append(b[-1]) + b = b[::-1] + output = 10 ** 6 + for x, y in zip(a, b): output = min(output, x + y) + print(output) + + return + +if __name__ == '__main__': + main() +" +p02754,s187509741,Accepted,"n, a, b = map(int, input().split()) + +q, r = divmod(n, (a + b)) + +answer = a * q + min(a, r) +print(answer)" +p04012,s982600941,Wrong Answer,"w = input() +beau = {} +for i in range(len(w)): + if not w[i] in beau: + beau[w[i]] = 1 + else: + beau[w[i]] += 1 +num = sum(list(beau.values()))%2 +if num == 0: + print('YES') +else: + print('NO')" +p02820,s538474787,Accepted,"def sol(score,hand): + if hand==""r"": + return score[""p""] + elif hand==""p"": + return score[""s""] + elif hand==""s"": + return score[""r""] + return 0 +n,k=map(int,input().split()) +r,s,p=map(int,input().split()) +t=input() +win="""" +for num,val in enumerate(t): + if num b: + a, b = b, a +print(max(0,b-(a+W))) +" +p02725,s153849995,Wrong Answer,"k,n=map(int,input().split()) +a=list(map(int,input().split())) +a.sort(reverse=True) +sa=[] +be=k + +for i in a: + sa.append(be-i) + be=i + +print(sum(sa)-max(sa))" +p02953,s518367715,Accepted,"n = int(input()) +h = [int(i) for i in input().split()] +hmax = h[0] +count = 0 +for i in range(1,n): + if hmax-1 <= h[i]: + count += 1 + hmax = max(hmax,h[i]) + else: + break +if n-1 == count: + print('Yes') +else: + print('No')" +p02879,s860480375,Accepted,"A,B = [int(i) for i in input().split()] +if A <10 and B < 10: + print(A*B) +else: + print(-1)" +p02640,s185920957,Wrong Answer,"x,y = input().split() +a = (2 * int(x)) - (int(y)/2) +b = (int(y)/2) - int(x) + +if (a + b == int(x)) and ((2*a) + (4*b) == int(y)) and a>=0 and b>=0: + print(""yes"") +else: + print(""no"")" +p02755,s799880853,Wrong Answer,"import sys +input = sys.stdin.readline +A, B = map(int, input().split()) + +xmin = 1 +while xmin < 100*A: + if int(0.08*xmin) == A and int(0.1*xmin) == B : + print(int(xmin)) + exit() + elif int(0.08*xmin) < A or int(0.1*xmin) < B : + xmin += 1 + else : + print(-1) + exit() + +" +p03243,s096178081,Accepted,"N = input() + + +def main(): + + if int(N) % 111 == 0: + print(N) + return + + cnt = int(N) + while True: + if cnt % 111 == 0: + print(cnt) + return + cnt += 1 + + +main() +" +p03435,s894122299,Wrong Answer,"c = {} +for i in range(3): + c[i] = list(map(int, input().split())) +a = [min(c.get(0)), min(c.get(1)), min(c.get(2))] +b = [min(c.get(0)[0], c.get(1)[0], c.get(2)[0]), min(c.get(0)[1], c.get(1)[1], c.get(2)[1]), min(c.get(0)[2], c.get(1)[2], c.get(2)[2])] +tf = True +for i in range(3): + for j in range(3): + tf = True if c.get(i)[j] == a[j] + b[j] else False +if tf: + print('Yes') +else: + print('No')" +p03069,s463697727,Wrong Answer,"N=int(input()) +S=input() +ans=[] +black=0 +white=0 +for n in range(N): + if S[n]=='.': + white+=1 + else: + black+=1 +stones={'b':0,'w':white} +for n in range(N): + if S[n]=='#': + stones['b']+=1 + else: + stones['w']-=1 + ans.append(stones['b']+stones['w']) +if 'b' in stones: + if stones['b']==N: + print(0) + else: + print(min(ans)) +else: + print(min(ans)) + " +p02952,s077841240,Accepted,"# -*- coding: utf-8 -*- + +n = int(input()) + +cnt = 0 +for i in range(1, n+1): + if len(str(i)) % 2 != 0: + cnt += 1 + +print(cnt) +" +p02598,s267372080,Accepted,"import math +N, K = map(int, input().split()) + +a = list(map(int, input().split())) + +def cal(x): + s = 0 + for aa in a: + s += math.ceil(aa / x) - 1 + if s <= K: return True + else: return False + +l = 0 +r = max(a) +while r - l > 1: + mid = (l + r) // 2 + if cal(mid): + r = mid + else: + l = mid +print(r)" +p02982,s483262604,Accepted,"import math +N,D = map(int,input().split()) + +X = [] +for i in range(N): + x = list(map(int,input().split())) + X.append(x) +cnt = 0 + +for i in range(N): + for j in range(i+1,N): + dist = 0 + for k in range(D): + dist += pow(X[i][k]-X[j][k],2) + dist = math.sqrt(dist) + + if dist.is_integer(): + cnt += 1 + +print(cnt) + " +p02697,s795977055,Wrong Answer,"N,M = map(int,input().rstrip().split("" "")) +ans = [[False for _ in range(N)] for _ in range(N)] + +if N % 2 == 1: + for i in range(1,M + 1): + print(str(i) + "" "" + str(N - i)) +else: + for i in range(1,min(M + 1,(N - 1) // 2)): + print(str(i) + "" "" + str(N - i - 2)) + if (N - 1) // 2 == M: + print(str(N - 2) + "" "" + str(N - 1))" +p02917,s618168149,Accepted,"#!/usr/bin/env python3 +ans = [1e9] * int(input()) +for i, x in enumerate(map(int, input().split())): + ans[i] = min(ans[i], x) + ans[i+1] = min(ans[i+1], x) +print(sum(ans)) + +" +p03721,s808901968,Accepted,"n,k = list(map(int, input().split())) +lst = [None for i in range(n)] + +for i in range(n): + a,b = list(map(int, input().split())) + lst[i] = (a,b) + +# print(lst) +lst.sort(key=lambda x:x[0]) +# print(lst) + +count = 0 +for i in range(n): + count += lst[i][1] + if count>=k: + print(lst[i][0]) + exit() +" +p03103,s772095508,Accepted,"N,M=map(int,input().split()) +a = [list(map(int,input().split())) for l in range(N)] +a.sort() +cost=0 +for i in range(N): + if M<=a[i][1]: + cost+=a[i][0]*M + break + elif M>a[i][1]: + M-=a[i][1] + cost+=a[i][0]*a[i][1] +print(cost)" +p03543,s131054465,Wrong Answer,"import sys +N = input() +i = 0 + +while N.count(str(i)) < 3: + i += 1 + if i > 9: + print('No') + sys.exit() + +print('Yes') +" +p02771,s326172728,Accepted,"# A - Poor +def main(): + A, B, C = map(int, input().split()) + is_poor = (A == B and A != C) or (A == C and A != B) or (B == C and A != B) + print(""Yes"" if is_poor else ""No"") + + +if __name__ == ""__main__"": + main() +" +p03478,s728382585,Accepted,"n,a,b = map(int,input().split()) +ans = 0 + +for i in range(n+1): + numsum = sum([int(x) for x in list(str(i))]) + if b>= numsum >=a: + ans+=i + +print(ans)" +p02831,s132060515,Wrong Answer,"import math +h = input()" +p02947,s928582767,Accepted,"import sys + +# import bisect +# map(int, sys.stdin.read().split()) +from collections import Counter + + + +def input(): + return sys.stdin.readline().rstrip() + + +def main(): + N = int(input()) + S = [] + for i in range(N): + s =list(input()) + s.sort() + s = """".join(s) + S.append(s) + + C = Counter(S) + ans =0 + for key,value in C.items(): + ans +=value*(value-1)/2 + + print(int(ans)) + + +if __name__ == ""__main__"": + main() +" +p02548,s693259605,Wrong Answer,"import math +N = int(input()) +ans = 0 +ve = math.floor(math.sqrt(N)) +for st in range(ve): + tmp = math.floor(N/(st+1)-0.000001) + score = 2*(tmp - st) + if score > 0: + score -= 1 + ans += score" +p03852,s242779354,Wrong Answer,"c = str, input() + +if c == ""a"" or ""e"" or ""i"" or ""o"" or ""u"": + print(""vowel"") +else: + print(""consonant"")" +p03206,s010693841,Accepted,"a=int(input()) +a=25-a +print(""Christmas "", end="""") +for i in range(a): + print(""Eve "", end="""") +" +p02631,s930114119,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +for i in range(N): + ans = 0 + for j in range(60): + x = 0 + for k in range(N): + if i == k: + continue + if A[k] >> j & 1: + x += 1 + if x % 2 == 1: + ans += 2**i + print(ans)" +p03605,s986297042,Wrong Answer,"N = input() +if ""9"" in N: + ans = ""YES"" +else: + ans =""NO"" +print(ans)" +p03693,s017132049,Accepted,"r,g,b = input().split() +print('YES' if int(r+g+b)%4==0 else 'NO')" +p02621,s502540125,Wrong Answer,"class Solution: + def calc(self, a: int) -> int: + return a+a*a+a*a*a" +p02768,s777256213,Accepted,"n, a, b = map(int, input().split()) +MOD = 10**9 + 7 + +def combination(n, k): + from math import factorial + numer = 1 + for i in range(k): + numer *= (n-i) + numer %= MOD + denom = factorial(k) % MOD + return numer * pow(denom, MOD-2, MOD) + +total = pow(2, n, MOD) - 1 +comb_a = combination(n, a) +comb_b = combination(n, b) +print((total - comb_a - comb_b) % MOD)" +p03289,s799439521,Accepted,"# solution +import io + +data=input() +if data[0]==""A""and data[2:-1].count(""C"")==1\ +and data[1:].replace(""C"",""c"",1).islower()==True: + print(""AC"") +else:print(""WA"")" +p02613,s316583542,Accepted,"import sys +from collections import Counter +import math + +counts = Counter(line.strip() for line in sys.stdin) + +for key in [""AC"", ""WA"", ""TLE"", ""RE""]: + if key not in counts: + print(""{} x 0"".format(key)) + else: + print(""{} x {}"".format(key, counts[key]))" +p02554,s048792245,Accepted,"N = int(input()) +mod = 1000000007 + +ans = (10**N - 2*(9**N) + 8**N) % mod +print(ans)" +p03323,s660014876,Accepted,"a, b = map(int, input().split()) +if a > 8 or b > 8: + print(':(') +else: + print('Yay!')" +p04033,s129253076,Accepted,"a, b = list(map(int, input().split())) + +if a*b <= 0: + print(""Zero"") +elif a > 0: + print(""Positive"") +elif b < 0 and (-a-b)%2 == 1: + print(""Positive"") +else: + print(""Negative"")" +p02836,s752120445,Wrong Answer,"s=input() +n=len(s) +cnt=0 +if n%2==0: + for aa in s[:n//2][::-1]: + for bb in s[n//2:n]: + if aa!=bb: + cnt+=1 + print(cnt) +else: + for cc in s[:(n-1)//2][::-1]: + for dd in s[(n+1)//2:n]: + if cc!=dd: + cnt+=1 + print(cnt)" +p03624,s709459730,Wrong Answer,"S = input() +S = sorted(S) +for i in range(97, 123): + if S.count(chr(i)) > 0: + continue + else: + print(chr(i)) + break" +p02726,s340460288,Wrong Answer,"n, x, y = map(int, input().split()) +count = [0 for i in range(2001)] +diff = y - x - 1 +for i in range(1, n): + for j in range(i+1, n+1): + if i <= x and y <= j: + count[j - i - diff] += 1 + #print(i, j, j - i - diff, ""!"") + else: + count[j - i] += 1 + #print(i, j, j - i) +for k in range(1, n): + print(count[k])" +p03438,s347404638,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +cou = 0 +for j,k in zip(a,b): + if jk: + cou -= (j-k) +if cou>=0: + print(""Yes"") +else: + print(""No"")" +p04045,s268619571,Accepted,"N, K = map(int, input().split()) +D = set(map(str, input().split())) + +for i in range(N,10**5): + l = set(list(str(i))) + if l & D: + continue + print(i) + break" +p03624,s160475365,Accepted,"s = input() + +b = [True] * 26 +for c in s: + b[ord(c) - ord('a')] = False + +ans = 'None' +for i in range(26): + if b[i]: + ans = chr(ord('a') + i) + break +print(ans) +" +p02829,s369881059,Accepted,"import sys +import math +import fractions +from collections import defaultdict +stdin = sys.stdin + +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(stdin.readline().rstrip()) +nm = lambda: map(int, stdin.readline().split()) +nl = lambda: list(map(int, stdin.readline().split())) + +A=int(input()) +B=int(input()) +A2=min(A,B) +B2=max(A,B) +if(A2==1 and B2==2): + print(3) + sys.exit(0) + +if(A2==2 and B2==3): + print(1) + sys.exit(0) + +if(A2==1 and B2==3): + print(2) + sys.exit(0) +" +p03557,s539756382,Wrong Answer,"print(""a"")" +p03041,s459696780,Accepted,"n, k = map(int, input().split()) +s = list(input()) #文字列はそのままだとイミュータブル +s[k-1] = chr(ord(s[k-1]) + 32) +print("""".join(s))" +p03665,s921426928,Accepted,"from scipy.special import comb + +N, P = map(int, input().split()) +A = list(map(int, input().split())) + +o,e = 0,0 +for a in A: + if a%2==0: + e+=1 + else: + o+=1 + +if P == 0: + # select even cnt from o + t = 0 + for i in range(0, o+1, 2): + t += comb(o, i, True) + print(2**e * t) +else: + t = 0 + for i in range(1, o+1, 2): + t += comb(o, i, True) + print(2**e * t) + + + +" +p02720,s351046127,Accepted,"k = int(input()) +lunlun = [1,2,3,4,5,6,7,8,9] +i = 0 +while len(lunlun) < k: + p = lunlun[i] + if str(p)[-1] == '0': + lunlun.append(p*10) + lunlun.append(p*10+1) + elif str(p)[-1] == '9': + lunlun.append(p*10+8) + lunlun.append(p*10+9) + else: + lunlun.append(p*10+p%10-1) + lunlun.append(p*10+p%10) + lunlun.append(p*10+p%10+1) + i += 1 + +print(lunlun[k-1]) +" +p02947,s920143859,Wrong Answer,"n = int(input()) +s = ['' for i in range(n)] +for i in range(n): + s[i] = sorted(input()) +ss = sorted(s) + +ans = 0 +for i in range (n-1): + if ss[i] == ss[i+1]: + count = 2 + i+=1 + while i != n-1 and ss[i] == ss[i+1]: + count+=1 + i+=1 + ans+=(count*(count-1)//2) +print(ans)" +p02879,s585579532,Wrong Answer,"A,B=map(int,input().split()) +if A<=9 and B<=9: + print(""A*B"") +else: + print(""-1"")" +p03779,s906160509,Wrong Answer,"X = int(input()) +ans = 0 +for i in range(1,X): + X -= i + ans += 1 + if X <= 0: break +print(ans)" +p02702,s860302801,Wrong Answer," +def resolve(): + import sys + input = sys.stdin.readline + S = input().rstrip() + + result = 0 + length = len(S) + if length < 4: + return result + + for keta in range(4, length+1): + for i in range(length - keta + 1): + j = i + keta + if int(S[i:j]) % 2019 == 0: + result += 1 + + print(result) + + + +if __name__ == ""__main__"": + resolve() +" +p03910,s781719151,Accepted,"n=int(input()) +for i in range(int((2*n)**0.5-3),n+2): + if i*(i+1)//2==n: + for j in range(1,i+1): + print(j) + break + elif i*(i+1)//2>n: + k=i*(i+1)//2-n + for j in range(1,i+1): + if j!=k: + print(j) + break +" +p02802,s281016754,Accepted,"N,M = map(int,input().split()) +D = [[]for i in range(N)] +AC = 0 +WA = 0 +for i in range(M): + plobNum,res = input().split() + D[int(plobNum)-1].append(res) + +for prob in D: + wa_ = 0 + for submit in prob: + if submit == ""WA"" : + wa_+=1 + elif submit == ""AC"": + AC+=1 + WA +=wa_ + break + +print(""{} {}"".format(AC,WA))" +p03264,s121224115,Wrong Answer,"k = int(input()) + +if k%2 == 0: + print((k//2)**2) +else: + print((k/2)*((k/2)+1))" +p03761,s400175837,Wrong Answer,"n=int(input()) +d={} +for i in range(n): + s=input() + d[i]={} + for c in s: + if c in d[i]: + d[i][c]+=1 + else: + d[i][c]=1 +k={chr(i)for i in range(97,123)} +for e in d: + k&=set(d[e].keys()) +for t in k: + m=float('inf') + for e in d: + m=min(m,d[e][t]) + print(t*m,end='') +print('') +" +p02691,s244803687,Accepted,"def main(): + N = int(input()) + A = list(map(int, input().split())) + B = {} + for i, a in enumerate(A): + B[i - a] = B.get(i - a, 0) + 1 + r = 0 + for i, a in enumerate(A): + B[i - a] -= 1 + r += B.get(a + i, 0) + return r + +print(main()) +" +p02783,s322995182,Accepted,"H, A = map(int, input().split()) +print(H//A if H % A == 0 else H//A+1)" +p03545,s539409867,Accepted,"def main(): + import itertools + s=list(input()) + n=len(s) + + for pm in itertools.product(""+-"", repeat=3): + tmp="""" + for i,j in zip(s,pm): + tmp+=i+j + else: + tmp+=s[-1] + if eval(tmp)==7: + print(tmp+""=7"") + exit() + + +if __name__==""__main__"": + main()" +p02678,s360024226,Wrong Answer,"from collections import deque + +n, m = map(int, input().split()) + +graph = [[] for _ in range(n+1)] + +for i in range(m): + a, b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +dist = [-1] * (n+1) +dist[0] = 0 +dist[1] = 0 + +d = deque() +d.append(1) + +while d: + v = d.popleft() + for i in graph[v]: + if dist[i] != -1: + continue + dist[i] = dist[v] + 1 + d.append(i) + +ans = dist[2:] +if len(ans) > 0: + print('Yes') + print(*ans, sep=""\n"") +else: + print('No')" +p03611,s849512892,Accepted,"from collections import defaultdict + +N = int(input().strip()) +A = list(map(int, input().strip().split("" ""))) + +d = defaultdict(int) + +m = -1 + +for a in A: + d[a] += 1 + d[a+1] += 1 + d[a-1] += 1 + m = max(d[a], d[a+1], d[a-1], m) + +print(m)" +p03645,s027907828,Accepted,"n,m = map(int,input().split()) + +s1 = set() +s2 = set() +for i in range(m): + a,b = map(int,input().split()) + if a == 1: + s1.add(b) + elif b == 1: + s1.add(a) + elif a == n: + s2.add(b) + elif b == n: + s2.add(a) + +if s1.isdisjoint(s2): + print(""IMPOSSIBLE"") +else: + print(""POSSIBLE"") +" +p02951,s306507882,Accepted,"a, b, c = map(int, input().split()) +into_a = a - b +remain_c = c - into_a + +if remain_c > 0: + print(remain_c) +else: + print(0) + + +" +p02832,s903897305,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +broken = 0 +flag = [0, 0] +for i in range(1,N + 1): + if flag[1] != 0: + break + for j in range(len(A)): + if A[j] == i: + if len(A) != 1: + A = A[j + 1:] + else: + A = [] + flag[0] += 1 + break + else: + broken += 1 + if len(A) == i + 1: + flag[1] += 1 +if broken == 0 and flag[0] != 1: + print(-1) +else: + print(broken)" +p02624,s025897048,Accepted,"def main(): + n = int(input()) + y = [0]*(n+1) + res = 0 + for i in range(1,n+1): + j = 1 + while True: + if i*j > n: + break + y[i*j] += 1 + j += 1 + res += i*y[i] + print(res) + +if __name__ == '__main__': + main() +" +p03329,s368371366,Wrong Answer,"import bisect as bi + +li6 = [6 ** i for i in range(7)] +li9 = [9 ** i for i in range(6)] +print(li6) +print(li9) + +def s69(n): + if n < 6: + return n + else: + s6 = li6[bi.bisect(li6, n) - 1] + s9 = li9[bi.bisect(li9, n) - 1] + return min(n // s6 + s69(n % s6), 1 + s69(n - s9)) + + +print(s69(int(input())))" +p03059,s304224540,Wrong Answer,"a, b, t = map(int, input().split()) + +the_number_of_times = (t + 0.5) // a +the_number_of_biscuits = b * the_number_of_times + +print(the_number_of_biscuits)" +p03433,s562271445,Accepted,"N=int(input()) +A=int(input()) +ans=N%500 +if ans-A<=0: + print('Yes') +else: + print('No')" +p02554,s337074661,Accepted,"import math +import re +#import sympy + +#a,b,c,d=map(int,input().split()) + + + +war=10**9+7 + +a=int(input()) +if a<2: + print(0) + exit() + +print((10**a-9**a-9**a+8**a)%war) + +" +p02555,s170388818,Accepted,"s=int(input()) +m=s//3 +c=10**9+7 +dp=[[0]*(m+1) for i in range(s+1)] +for i in range(3,s+1): + dp[i][1]=1 +su=[0]*(m+1) + +for i in range(6,s+1): + for j in range(2,i//3+1): + su[j-1]=(su[j-1]+dp[i-3][j-1])%c + dp[i][j]=su[j-1] +print(sum(dp[-1])%c)" +p03030,s678654873,Accepted,"n = int(input()) +rs = [list(input().split()) for _ in range(n)] + + +new_rs = sorted(rs, key=lambda x: - int(x[1])) + + +def mp_count(s): + mps = {} + for mp, _ in s: # 2個の変数を用意しないと、1個の変数にリストがいい感じにおさまってしまう + if mp not in mps: + mps[mp] = 0 + return sorted(mps) + + +for m in mp_count(rs): + for r in new_rs: + if m == r[0]: + print(rs.index(r) + 1) +" +p02790,s088026590,Accepted,"a,b = map(int,input().split()) + +l = [str(a)*b, str(b)*a] +l.sort() +print(l[0])" +p02866,s006786114,Accepted,"import collections +n = int(input()) +d = list(map(int, input().split())) +mod = 998244353 +f = collections.Counter(d) +# print(f) +if d[0] != 0 or f[0] != 1: # 0は一個だけ + print(0) + exit() +ans = 1 +box = 1 # 値自体の個数を保存 +maxd = max(d) + +for i in range(maxd+1): + ans = ans*box**f[i] + ans %= mod + box = f[i] +print(ans) +" +p03208,s389106801,Accepted,"import numpy as np +N, K = list(map(int,input().split())) +a = [int(input()) for i in range(N)] +a = sorted(a, reverse = True) +ans = np.zeros(len(a)-K+1) +for i in range(len(a)-K+1): + ans[i] = a[i]-a[i+K-1] +print(int(ans.min()))" +p02631,s692922869,Wrong Answer,"n = int(input()) +alist = list(map(int, input().split("" ""))) +blist = list(map(bin, alist)) + +print(blist)" +p02742,s684970501,Accepted,"import sys +h, w = map(int, input().split()) + +if h == 1 or w == 1: + print(1) + sys.exit() +count_1 = (h+1) // 2 +count_2 = h // 2 + +loop_num = w // 2 +add_num = w - (loop_num * 2) +print((count_1+count_2) * loop_num + (count_1 * add_num)) +" +p03252,s405249499,Wrong Answer,"from collections import defaultdict +s = input() +t = input() +n = len(s) +changed = defaultdict(list) +for i in range(n): + if s[i] != t[i]: + changed[s[i]].append(t[i]) +#print(changed) +flag = True +for lis in changed.values(): + if len(set(lis)) != 1: + flag = False + break +if flag: + print(""Yes"") +else: + print(""No"")" +p02729,s657263504,Accepted,"N,M = map(int,input().split()) +print(N*(N-1)//2 + M*(M-1)//2)" +p04029,s246463237,Wrong Answer,"n = int(input()) +s = (n+1)*n/2 +print(s)" +p02813,s421956649,Accepted,"n = int(input()) +ps = tuple(map(int, input().split())) +qs = tuple(map(int, input().split())) + +from itertools import permutations + +l = list(permutations(range(1, n+1))) + +print(abs(l.index(ps) - l.index(qs)))" +p02987,s533316856,Accepted,"def solve(): + s = input() + count = 0 + for i in range(len(s)): + for j in range(i+1, len(s)): + if s[i] == s[j]: + count += 1 + print('YNeos'[count!=2::2]) + + + + + +if __name__ == '__main__': + solve() +" +p02993,s689382778,Accepted,"S=list(input()) +count=0 +for i in range(3): + if S[i]==S[i+1]: + count=1 +if count==1: + print('Bad') +else: + print('Good')" +p02719,s383591107,Accepted,"from sys import stdin, stdout +import math +import bisect +import queue + +n, k = map(int, stdin.readline().strip().split()) + +times = n // k + +ans = n - k * times +ans = min(ans,abs(n - (times + 1) * k)) + +stdout.writelines(str(ans)) +" +p02817,s769509200,Wrong Answer,"a,b = map(str, input().split()) +print(a+b)" +p02818,s594020157,Accepted,"a, b,k = map(int, input().split()) +if a>=k: + aa=a-k + ba=b +elif a+b>=k: + aa=0 + ba=b-(k-a) +else: + aa=0 + ba=0 + +print(""{} {}"".format(aa,ba))" +p02577,s621169988,Accepted,"N = input() + +cnt = 0 +for n in N: + cnt += int(n) + cnt %= 9 + +if cnt % 9 == 0: + print(""Yes"") +else: + print(""No"") +" +p03160,s022863521,Accepted,"n = int(input()) +h = list(map(int,input().split())) +dp = [int(1e+10) for _ in range(n)] +dp[0],dp[1] = 0,abs(h[1]-h[0]) +for i in range(2,n): + dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2])) +print(dp[-1])" +p02861,s812164079,Wrong Answer,"import math +N = int(input()) +xy = [list(map(int, input().split())) for i in range(N)] +k = 0 +total = 0 +for j in range(N-1): + for i in range(j + 1, N-1): + total += ((xy[j][0] - xy[i][0])**2 + (xy[j][1]-xy[i][1])**2)**(1/2) + k += 1 +total = total * 2 +print(total/N) +" +p02608,s021022101,Accepted,"N = int(input()) +ans = [0 for _ in range(N)] +for z in range(1, 101): + for y in range(1, 101): + for x in range(1, 101): + i = x**2 + y**2 + z**2 + x*y + y*z + z*x + if i <= N: + ans[i-1] += 1 + +for j in ans: + print(j)" +p02577,s674231852,Accepted,"N=int(input()) +if N % 9 == 0: + print(""Yes"") +else: + print(""No"")" +p03035,s424763821,Wrong Answer,"a,b=map(int,input().split()) +if a>12: + print(b) +elif 12>=a>=6: + print(b/2) +else: + print(0) +" +p02712,s674997354,Accepted,"N = int(input()) +sum=0 +for i in range(1,N+1): + if (i%3!=0)&(i%5!=0): + sum = sum + i +print(sum)" +p02784,s499344296,Accepted,"h, n = map(int, input().split()) +a = list(map(int, input().split())) + +if h <= sum(a): + print(""Yes"") +else: + print(""No"")" +p02922,s423029048,Accepted,"a, b = [int(i) for i in input().split()] +i = 0 +while True: + if a * i - i + 1 >= b: + print(i) + break + i += 1 + " +p03351,s412683585,Accepted,"a, b, c, d = map(int, input().split()) +if (abs(a - b) <= d and abs(b - c) <= d) or abs(a - c) <= d: + print(""Yes"") +else: + print(""No"")" +p03071,s558101318,Accepted,"A, B = map(int, input().split()) +print(max(A+A-1, A+B, B+B-1))" +p03352,s064445539,Accepted,"n = int(input()) +ans = 0 +for i in range(1,1000): + for j in range(2, 10): + if i**j <= n: + ans = max(ans, i**j) +print(ans)" +p03719,s982635478,Accepted,"a,b,c = map(int,input().split()) +if a<= c <= b: + print(""Yes"") +else: + print(""No"") +" +p03971,s896663719,Wrong Answer,"n,a,b=map(int,input().split()) +cnt_s = 0 +cnt_b = 0 + +for i in range(n): + if cnt_s <= a+b: + print('Yes') + cnt_s += 1 + elif cnt_s > a+b: + print('No') + elif cnt_s <= a+b and cnt_b <= b: + print('Yes') + cnt_b += 1 + cnt_s += 1 + else: + print('No') + " +p02971,s844879281,Wrong Answer,"N = int(input()) +A = [int(input()) for _ in range(N)] +a = sorted(set(A)) +max_count = A.count(a[-1]) +for i in range(N): + if len(a) > 1: + if A[i] != a[-1]: + print(a[-1]) + else: + if max_count < 1: + print(a[-1]) + else: + print(a[-2]) + else: + print(a[-1])" +p02597,s136096602,Accepted,"l = [] +n = int(input()) +r = 0 +for i in [1 if x == 'R' else 0 for x in list(input())]: + r += i + l.append(r) + +c = r - l[r-1] +print(c) +" +p02712,s282197446,Accepted,"N = int(input()) + +ans = 0 +for i in range(N+1): + if i % 3 != 0 and i % 5 != 0: + ans += i +print(ans) +" +p02547,s722370148,Accepted,"n = int(input()) +c = 0 +for i in range(n): + a,b = map(int,input().split()) + if a == b: + c += 1 + else: + c = 0 + if c == 3: + break +if c == 3: + print(""Yes"") +else: + print(""No"")" +p03448,s397524939,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) + +count = 0 + +for i in range(0, a+1): + for j in range(0, b+1): + for k in range(0, c+1): + print(i,j,k) + if i*500 + j*100 + k*50 == x: + count += 1 + +print(count)" +p02760,s829180821,Accepted,"L1 = list(map(int, input().split())) +L2 = list(map(int, input().split())) +L3 = list(map(int, input().split())) +L = L1 + L2 + L3 +N = int(input()) +A = [0]*9 +for _ in range(N): + i = int(input()) + if i in L: + A[L.index(i)] = 1 +if sum(A[:3])==3 or sum(A[3:6])==3 or sum(A[6:])==3: + print('Yes') +elif A[0]+A[3]+A[6]==3 or A[1]+A[4]+A[7]==3 or A[2]+A[5]+A[8]==3: + print('Yes') +elif A[0]+A[4]+A[8]==3 or A[2]+A[4]+A[6]==3: + print('Yes') +else: + print('No')" +p03481,s662946842,Accepted,"a = list(map(int,input().split())) +x = a[0] +y = a[1] + +n = a[0] +count = 0 + +while n <= y: + n = n << 1 + count += 1 + +print(str(count))" +p03796,s114490750,Accepted,"N=int(input()) +p=1 +for i in range(N): + p*=(i+1) + p=p%(10**9+7) +print(p)" +p03339,s651082067,Accepted,"N=int(input()) +l = input() +count0 = l[1:].count(""E"") +count=count0 +mi=count0 +for i in range(1, N): + if l[i-1]==""W"": + count+=1 + if l[i]==""E"": + count-=1 + mi=min(mi,count) +print(mi)" +p03331,s132640566,Wrong Answer,"n=int(input()) +ans=10e5 +for a in range(2,n//2+1): + b=n-a + ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)])) +print(ans)" +p02959,s230016897,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + + +# Imperative solution +res = 0 +rem = 0 + +for i in range(N): + B[i] += rem + mobs = min(A[i], B[i]) + rem = B[i] - mobs + res += mobs + +res += min(A[N], rem) +print(res)" +p03623,s519712985,Accepted,"x,a,b=map(int,input().split()) + +flg=0 +if b= t: + s[i] = ""a"" + k -= t + +t = k % 26 +s[-1] = chr(ord(s[-1]) + t) + +print("""".join(s)) +" +p03838,s563855972,Accepted,"x, y = map(int, input().split()) + + +ans = 10**10 +if x <= y: + ans = min(ans, y - x) + +if -x <= y: + ans = min(ans, 1 + y + x) + +if x <= -y: + ans = min(ans, 1 - y - x) + +if -x <= -y: + ans = min(ans, 2 - y + x) + +print(ans) +" +p02910,s201115836,Accepted,"s = input() +N = len(s) +a = 0 +for x in range(0,N,2): + if s[x] == ""L"": + a = 1 +for x in range(1,N,2): + if s[x] == ""R"": + a = 1 +if a == 0: + print(""Yes"") +else: + print(""No"")" +p02899,s669589076,Wrong Answer,"n = int(input()) +a_lst = list(map(int,input().split())) + +d = {} + +for i in range(n): + d[a_lst[i]] = i+1 + +d_sort = sorted(d.items(), key=lambda x : x[0]) + +ans_lst = [] +for item in d_sort: + ans_lst.append(item[1]) + +print(ans_lst)" +p03017,s432536348,Accepted,"n,a,b,c,d = map(int, input().split()) +s = list(input()) +s.append(""."") +a -= 1 +b -= 1 +c -= 1 +d -= 1 + +if c > d: + if ""##"" not in """".join(s[a+1:c]) and ""##"" not in """".join(s[b+1:d]) and ""..."" in """".join(s[b-1:d+2]): + print(""Yes"") + else: print(""No"") +else: + if ""##"" not in """".join(s[a+1:c]) and ""##"" not in """".join(s[b+1:d]): + print(""Yes"") + else: print(""No"")" +p02657,s224490152,Accepted,"a,b=map(int,input().split()) +print(a*b)" +p03377,s767297157,Wrong Answer,"A,B,X = list(map(int,input().split())) +print('YES' if X-A <= B else 'NO')" +p02600,s264536260,Accepted,print(8-(int(input())-400)//200) +p02612,s580220300,Accepted,"N = int(input()) + +if 1000 - N % 1000 == 1000: + print(0) +else: + print(1000 - N % 1000)" +p02759,s746988258,Accepted,"N = int(input()) +print(N // 2) if N % 2 == 0 else print(N // 2 + 1)" +p03261,s672894092,Accepted,"import sys +import heapq, math +from itertools import zip_longest, permutations, combinations, combinations_with_replacement +from itertools import accumulate, dropwhile, takewhile, groupby +from functools import lru_cache +from copy import deepcopy + +N = int(input()) +W = [input() for _ in range(N)] + +s = W[0][-1] + +ok = True +used = set() +used.add(W[0]) +for w in W[1:]: + if s != w[0] or w in used: + ok = False + + s = w[-1] + used.add(w) + +print(""Yes"" if ok else ""No"") +" +p02994,s807668557,Wrong Answer,"N,L = map(int,input().split()) + +s = 0 +for i in range(1,N+1): + s += L+i-1 + +if L >= 0: + eat = L +elif L-N < 0: + eat = L+N-1 +else: + eat = 0 + +print(s-eat)" +p02727,s511268084,Accepted,"import sys +import itertools + +def main(): + x, y, a, b, c = map(int, sys.stdin.buffer.readline().split()) + red = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True) + green = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True) + colorless = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True) + + apples = sorted(itertools.chain(red[:x], green[:y], colorless), reverse=True) + print(sum(apples[:x + y])) + +main()" +p02973,s470777236,Accepted,"from bisect import bisect_right +n=int(input()) +A=[int(input()) for _ in range(n)][::-1] + +DP=[A[0]] +for i in range(1,n): + num=A[i] + if DP[-1]<=num: + DP.append(num) + else: + index=bisect_right(DP,num) + DP[index]=num +print(len(DP))" +p03219,s116361346,Wrong Answer,"x,y=map(int,input().split()) +print(x*(y/2))" +p03486,s963148022,Accepted,"s = sorted(input()) +t = sorted(input())[::-1] +print(""Yes"" if s < t else ""No"") +" +p03437,s773672750,Accepted,"# -*- coding: utf-8 -*- + +X, Y = map(int, input().split()) + +if X % Y == 0: + print(-1) +else: + print(X) +" +p03317,s460302043,Accepted,"from math import ceil +n,k=map(int,input().split()) +a=list(map(int,input().split())) +print(ceil((n-1)/(k-1))) +" +p02546,s979989271,Accepted,"S=input() +if S[-1]=='s': + print(S+'es') +else: + print(S+'s')" +p03681,s747514371,Wrong Answer,"n, m = map(int, input().split()) +ans1 = 1 +ans2 = 1 +mod = 10**9 + 7 + +if abs(n-m) > 2: + print(0) + exit() + + +for i in range(1, n+1): + ans1 *= i + ans1 %= mod +for j in range(1, m+1): + ans2 *= j + ans2 %= mod + +if abs(m-n) == 1: + print(ans1 * ans2 % mod) +else: + print(2 * ans1 * ans2 % mod)" +p02983,s398392677,Accepted,"L, R = map(int, input().split()) +MOD = 2019 +INF = 10**5 +ans = INF + + +if 2019 <= R-L: + print(0) +else: + x = L % MOD + y = R % MOD + if x < y: + for i in range(x, y): + for j in range(i+1, y+1): + ans = min(ans, (i*j) % MOD) + if ans == 0: + break + print(ans) + else: + print(0)" +p02594,s733652295,Accepted,"x = int(input()) +print('Yes') if x >= 30 else print('No')" +p03699,s344758057,Accepted,"n = int(input()) +l = [] + +for i in range(n): + l.append(int(input())) + +l.sort() +ans = sum(l) + +if ans%10 == 0: + for i in range(n): + if l[i]%10 != 0: + ans -= l[i] + break + + else: + ans = 0 + +print(ans)" +p03282,s303209875,Accepted,"s = input() +k = int(input()) +for i in range(k): + if s[i] != ""1"": + print(s[i]) + exit() +print(1) +" +p03711,s082949526,Wrong Answer,"a1 = [1,3,5,7,8,10,12] +a2 = [4,6,9,11] +a3 = [2] + +x,y = list(map(int,input().strip().split())) + +if x in a1: + _x = 0 +elif x in a1: + _x = 1 +else: + _x = 2 +if y in a1: + _y = 0 +elif y in a1: + _y = 1 +else: + _y = 2 + +if _x == _y: + print(""Yes"") +else: + print(""No"")" +p03017,s818008547,Wrong Answer,"n,a,b,c,d = map(int,input().split()) +s = list(input()) +for i in range(n-1): + if s[i] == ""#"" and s[i+1] == ""#"": + print(""No"") + quit() +if c < d: + print(""Yes"") +elif c > d: + for j in range(n-2): + if s[j] == ""."" and s[j+1] == ""."" and s[j+2] == ""."": + print(""Yes"") + quit() + print(""No"")" +p03773,s871652732,Wrong Answer,"A, B = map(int, input().split()) +if A + B <= 23: + print(A + B) +else: + print(24 - A + B)" +p03680,s117155913,Accepted,"n=int(input()) +a=[int(input()) for i in range(n)] +ans=1 +res=1 +for i in range(n): + if a[res-1]==2: + print(ans) + exit() + else: + ans+=1 + res=a[res-1] +print(-1)" +p02765,s864514760,Accepted,"n,r = map(int,input().split()) +if n>=10: + print(r) +else: + print(r+100*(10-n)) + +" +p02972,s292888556,Accepted,"n = int(input()) +a = [0]+list(map(int,input().split())) +x = [0]*(n+1) +for i in range(n,0,-1): + buf = 0 + for j in range(1,n//i+1): + buf += x[i*j] + if buf%2!=a[i]:x[i]=1 +x = x[1:] +m = 0 +b = [] +for i in range(n): + if x[i]==1: + b.append(i+1) + m+=1 +print(m) +print(*b) + +" +p03000,s899003150,Wrong Answer,"N, X = map(int, input().split()) +L = list(map(int, input().split())) + +d = 0 +c = 0 +while d <= X: + c += 1 + d += L[c-1] + if c >= N: + break +print(c) +" +p03379,s781625176,Accepted,"n=int(input()) +l=list(map(int,input().split())) +x=sorted(l) +m=(x[n//2]+x[n//2-1])/2 +for y in l: + if y0: + print(x+1) +else: + print(x)" +p02713,s467651908,Accepted,"N = int(input()) + +# import time +# start = time.time() + +import math +from functools import reduce + + + +def gcd(*numbers): + return reduce(math.gcd, numbers) +ans = 0 +for a in range(1,N+1): + for b in range(1,N+1): + for c in range(1,N+1): + ans+=gcd(a,b,c) +print(ans) + +" +p03386,s618314030,Accepted,"a,b,k=map(int,input().split()) +if a+k-1>=b-k+1: + for i in range(a,b+1): + print(i) +else: + for i in range(a,a+k): + print(i) + for i in range(b-k+1,b+1): + print(i)" +p03910,s782671876,Wrong Answer,"n = int(input()) +ans = [] +if n == 1: + ans.append(1) +elif n == 2: + ans.append(2) +else: + c = n // 2 + 1 + ans.append(c) + ans.append(n-c) + +print(""\n"".join(list(map(str, ans))))" +p02691,s574810005,Wrong Answer,"from math import sqrt + +person = int(input()) +longs = list(map(int, input().split("" ""))) + +sum = 0 +for i in range(person): + for j in range(i, min(i + longs[i], person)): + if (j - i) == longs[i] + longs[j]: + sum += 1 +print(sum)" +p03835,s288398985,Accepted,"K, S = [int(i) for i in input().split()] + +count = 0 +for i in range(0, K+1): + for j in range(0, K+1): + k = S - i -j + if 0 <= k <= K: + count += 1 +print(count)" +p03997,s664046628,Wrong Answer," +a=int(input()) +b=int(input()) +h=int(input()) + +print((a+b)*h/2)" +p03804,s823596348,Accepted,"n, m = map(int, input().split()) +A = [input() for _ in range(n)] +B = [input() for _ in range(m)] + +ans = 'No' +for i in range(n - m + 1): + for j in range(n - m + 1): + if all([A[i + k][j:j + m] == B[k] for k in range(m)]): + ans = 'Yes' +print(ans)" +p02879,s650862075,Accepted,"a, b = map(int, input().split()) +print(a*b if 1 <= a <=9 and 1 <= b <= 9 else '-1')" +p03474,s181935478,Wrong Answer,"a,b = map(int,input().split()) +s = list(input()) +if len(s)==a+b+1 and s[a]=='-': + print('Yes') +else: + print('No')" +p02881,s245995280,Accepted,"# 2020/01/23 +# AtCoder Beginner Contest 144 - C + +# Input +n = int(input()) + +nsq = int(n ** (1/2)) + 1 + +x = nsq +y = nsq + +while x >= 1: + if n % x == 0: + ans = (x - 1) + int( (n / x) - 1) + break + else: + x = x - 1 + +# Output +print(ans) +" +p02598,s014961217,Wrong Answer,"import math +n, k = map(int, input().split()) +aas = list(map(int, input().split())) +diff = pow(10,-6) +left = 1 +right = 10**9 +def judge(mid): + cut = 0 + for i in aas: + cut += math.ceil(i / mid) - 1 + if cut <= k: + return True + else: + return False +while left < right: + mid = (left + right) / 2 + if (left <= right <= left + diff) or (right <= left <= right + diff): + break + elif judge(mid): + right = mid + else: + left = mid +print(int(right))" +p02823,s336609424,Accepted,"n, a, b = map(int, input().split()) +if (b-a)%2 == 0 : + print((b-a)//2) +else : + print((b-a)//2 + min(a-1,n-b) + 1) +" +p03943,s256278004,Accepted,"candy = list(map(int, input().split())) + +if candy.count(sum(candy)/2) == 1: + print('Yes') +else: + print('No')" +p02785,s431648326,Accepted,"n,h=map(int,input().split()) +a=list(map(int,input().split())) +a.sort() +a.reverse() +c=[0]*2 +c[0]=h +c[1]=len(a) +for k in range(0,min(c)): + a[k]=0 +print(sum(a))" +p03062,s636391838,Accepted,"n = int(input()) +a = sorted(map(int, input().split())) +print(sum(map(lambda a, b: abs(a + b), a[::2], a[1::2])) + (a[-1] if n % 2 == 1 else 0))" +p03861,s749244597,Accepted,"a, b, x = map(int, input().split()) +if a%x == 0: + print(b//x-a//x+1) +else: + print(b//x-a//x)" +p03127,s025659804,Wrong Answer,"n = int(input()) +a = list( map(int,input().split()) ) +a.sort() + +ans = a[0] +for i in range(1,n): + x = a[i] % ans + if x == 0 : + continue + else : + ans = min( x , ans ) + +print(ans)" +p02789,s618590998,Wrong Answer,"a, b = input().split() +if a<=b: + print('Yes') +else: + print('No')" +p03767,s217065733,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +a.sort(reverse=True) + +ans = sum(a[1:2*n+1:2]) +print(ans)" +p03069,s289924669,Wrong Answer,"def main(): + n = int(input()) + s = input() + black = s.count(""#"") + ans, white = black, 0 + for i in range(n): + if s[i] == ""."": + white += 1 + else: + black -= 1 + tmp = n - black - white + if tmp < ans: + ans = tmp + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03524,s689765160,Wrong Answer,"from collections import Counter +s = sorted(list(Counter(list(input())).values()))[::-1] +if len(s)==1: + print(""NO"") + exit() +a = s[0] +for i in s: + if a==i or a==i+1: + continue + else: + print('NO') +else: + print(""YES"")" +p02779,s849905711,Accepted,"n = int(input()) +a = input().split() +b = set(a) +if len(b)=n: + for i in range(n,S+1): + resList.append(resList[i-1]+resList[i-3]) + print(resList[len(resList)-1]%mod) + else: + print(resList[S]) + + + + +if __name__==""__main__"": + main()" +p03360,s837333549,Wrong Answer,"A = sorted(list(map(int,input().split()))) +N = int(input()) +A[-1] = A[-1]**N +print(sum(A))" +p03698,s557942492,Wrong Answer,"s = list(input()) +if len(s) == len(set(s)): + print(""YES"") +else: + print(""NO"")" +p02917,s304201045,Wrong Answer,"N = int(input()) +A = list(map(int,input().split()))+[float('inf')] +ans = 0 +for i in range(N-1): + ans+=min(A[i],A[i+1]) +print(ans)" +p03427,s173392372,Accepted,"N = input() +l = len(N)-1 +print(N if l == 0 else int(N[0]) + 9*l if N[1:] == '9'*l else int(N[0]) - 1 + 9*l)" +p02873,s452856057,Wrong Answer,"S = list(input()) +c = [0, 0] +n = 0 +s = """" +for i in range(len(S)): + if s == """": + s = S[i] + n = 1 + elif s == S[i]: + n += 1 + else: + if n > 1: + if S[i] == ""<"": c[0] += n + else: c[1] += n + n = 1 + s = S[i] + +if n > 1: + if S[i] == ""<"": c[0] += n + else: c[1] += n +c = max(c) +print(c * (c + 1) // 2)" +p02718,s059485372,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +total = sum(A) +print('Yes' if M <= len(list(filter(lambda x: x, map(lambda x: x * 4 * M >= total, A)))) else 'No')" +p02820,s113439726,Accepted,"n, k = map(int, input().split()) +r, s, p = map(int, input().split()) +t = input() + +ans = 0 +hist = [] +for _t in t: + h = """" + if len(hist) >= k: + h = hist.pop(0) + + if _t == ""r"" and h != ""p"": + ans += p + hist.append(""p"") + elif _t == ""s"" and h != ""r"": + ans += r + hist.append(""r"") + elif _t == ""p"" and h != ""s"": + ans += s + hist.append(""s"") + else: + hist.append("""") + +print(ans) +" +p02866,s040883143,Wrong Answer,"N=int(input()) +D=list(map(int,input().split())) +mod=998244353 + +if D[0]!=0: + print(0) + exit() + + +B=[0]*N +for d in D: + B[d]+=1 +if B[0]!=1: + print(0) + exit() + +ans=1 +total=1 +for i in range(1,N): + if B[i]==0: + if total!=N: + print(0) + exit() + else:break + total+=B[i] + ans*=(B[i-1]**B[i])%mod + +print(ans) +" +p02935,s330606404,Accepted,""""""" +int(input()) +map(int,input().split()) +list(map(int,input().split())) + +"""""" + +n=int(input()) +A=list(map(int,input().split())) +A.sort() +cur=(A[0]+A[1])/2 + +for i in range(2,n): + cur=(cur+A[i])/2 +print(cur) +" +p03545,s789751865,Accepted,"s = list(map(str, input())) +n = len(s) - 1 +for i in range(2**n): + ans = s[0] + for j in range(n): + if ( i >> j ) & 1 : + ans += ""+"" + s[j+1] + else: + ans += ""-"" + s[j+1] + if j == n-1: + if eval(ans) == 7: + print(ans+""=7"") + exit()" +p02556,s118755025,Wrong Answer,"N = int(input()) + +dots = [] +for _ in range(N): + dots.append(list(map(int,input().split()))) + +max = 0 +for i in range(N): + for j in range(i+1,N): + dist = abs(dots[i][0]-dots[j][0])+abs(dots[i][0]-dots[j][0]) + if dist > max: + max = dist + +print(max) +" +p03827,s613536016,Accepted,"N = int(input()) +S = input() + +maxv = 0 +tmp = 0 + +for i in S: + if i == 'I': + tmp += 1 + else: + tmp -= 1 + + if maxv < tmp: + maxv = tmp + +print(maxv)" +p03360,s808336572,Wrong Answer,"*ABC, = map(int, input().split()) +K = int(input()) +print(sum(ABC) - max(ABC) + (max(ABC) * 2 * K))" +p03075,s228640231,Wrong Answer,"A= [int(input()) for i in range(6)] +answer = ""Yay!"" +for u in range(4): + for s in range(u,4): + if A[s] - A[u] > A[5]: + answer = "":("" +print(answer)" +p03479,s602325524,Wrong Answer,"import math +x,y = map(int,input().split()) +print(math.floor(math.log2(y/x))+1)" +p04033,s734365446,Wrong Answer," +a,b = map(int,input().split()) + +if a > 0: + print(""Pssitive"") +elif a <= 0 and 0 <= b: + print(""Zero"") +elif b < 0: + if abs(b-a) % 2 == 1: + print(""Positive"") + else: + print(""Negative"") +" +p03435,s250957994,Wrong Answer,"number=[] +a=input().split() +b=input().split() +c=input().split() +lista=[int(d) for d in a] +listb=[int(e) for e in b] +listc=[int(f) for f in c] +if (sum(lista)+sum(listb)+sum(listc))%3==0: + print('Yes') +else: + print('No') + " +p02882,s182408603,Accepted,"from math import atan,pi +A,B,X=map(int,input().split()) + +if 2*X>=A*A*B: + P=atan(2*(A*A*B-X)/(A*A*A))*180/pi + print(P) +else: + Q=atan((A*B*B)/(2*X))*180/pi + print(Q) +" +p03435,s916518137,Accepted,"c = [] +for i in range(3): + c.append(list(map(int, input().split("" "")))) + +f = ""No"" +for a1 in range(101): + for a2 in range(101): + for a3 in range(101): + if (c[0][0] - a1 == c[0][1] - a2 == c[0][2] - a3 + and c[1][0] - a1 == c[1][1] - a2 == c[1][2] - a3 + and c[2][0] - a1 == c[2][1] - a2 == c[2][2] - a3): + f = ""Yes"" + +print(f)" +p03472,s136102455,Accepted,"#!/usr/bin/env python3 +import bisect +import math + +n, h = map(int, input().split()) +a, b = [0] * n, [0] * n +for i in range(n): + a[i], b[i] = map(int, input().split()) +max_a = max(a) +b.sort() +idx = bisect.bisect_right(b, max_a) +ans = 0 +tmp = 0 +for i in range(n - 1, -1, -1): + tmp += b[i] + if tmp >= h: + print(n - i) + exit() + if i <= idx: + break + +print(n - idx + math.ceil((h - sum(b[idx:])) / max_a)) +" +p03377,s126137683,Accepted,"a,b,x=map(int,input().split()) + +print(""YES""if a<=x and a+b>=x else""NO"")" +p02772,s269022488,Accepted,"a=int(input()) +list=map(int,input().split()) +list2=[] +list3=[] +for x in list: + if x%2==0: + list2.append(x) +for y in list2: + if y%3!=0 and y%5!=0: + list3.append(y) +s=len(list3) +if s==0: + print(""APPROVED"") +else: + print(""DENIED"")" +p04044,s350301106,Accepted,"N,L = map(int,input().split()) +A = [] + +for i in range(N): + s = input() + A.append(s) +A.sort() +print("""".join(A))" +p02761,s822179359,Wrong Answer,"n, m = map(int, input().split()) +array = [None] * n +for i in range(m): + keta, num = map(int, input().split()) + if n >= 2 and keta == 1 and num == 0: + print(-1) + break + if array[keta-1] != None and array[keta-1] != num: + print(-1) + break + array[keta-1] = num + + if i == m-1: + ans = 0 + for k in range(n): + if array[k] != None: + ans += 10**(n-1-k)*array[k] + print(ans) + " +p03293,s413127999,Wrong Answer,"s=input() +t=input() +ss=s+s +if t in s: + print(""Yes"") +else: + print(""No"")" +p02946,s862651616,Wrong Answer,"K,X=map(int,input().split()) +k=[] +for i in range ((X-K+1),(X+K),1): + k.append(i) +print(k)" +p03220,s749688208,Accepted,"n = int(input()) +t, a = map(int, input().split()) +h_list = list(map(int, input().split())) +ans = 0 +for i in range(n): + if abs(a - (t - h_list[i] * 0.006)) < abs(a - (t - h_list[ans] * 0.006)): + ans = i +print(ans + 1)" +p02953,s635498605,Accepted,"N = int(input()) +H = list(map(int, input().split())) + +ans = 'Yes' +for i in range(1, N): + if H[N-i-1]-1 == H[N-i]: + H[N-i-1] -= 1 + elif H[N-i-1]-1 > H[N-i]: + ans = 'No' + break + +print(ans)" +p02832,s027302172,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +x=1 +ans=0 +for i in a: + if i!=x: + ans+=1 + else: + x+=1 +print(ans)" +p03761,s170246384,Wrong Answer,"def intersection(lst1, lst2): + lst3 = [value for value in lst1 if value in lst2] + return lst3 + +def resolve(): + n = int(input()) + h = [] + for i in range(n): + h.append(input()) + sec = h[0] + for i in range(1, n): + sec = intersection(sec, h[i]) + print("""".join(sorted(sec))) +resolve()" +p02553,s815761194,Wrong Answer,"import numpy as np + +a, b, c, d = map(int, input().split()) + +print(max(np.abs([(a*c), (a*d), (b*c), (b*d)])))" +p03457,s524684701,Accepted,"import sys +n = int(input()) +a = [list(map(int, input().split())) for i in range(n)] +x = 0 +y = 0 +t = 0 +for i in range(n): + if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2: + print('No') + sys.exit() + else: + x = a[i][1] + y = a[i][2] + t = a[i][0] +print('Yes')" +p02699,s639914107,Accepted,"s,w = map(int,input().split()) +print(""safe"" if s > w else ""unsafe"")" +p03107,s877718695,Wrong Answer,"S = input() + +S = list(S) + +from collections import Counter +c = Counter(S) +keys, values = zip(*c.most_common()) + +print(2*min(values))" +p03951,s356690497,Accepted,"N = int(input()) +S = input() +T = input() +for i in range(N, 0, -1): + if S[-i:] == T[:i]: + print(2 * N - i) + break +else: + print(2 * N) +" +p03433,s724890879,Wrong Answer,"N = int(input()) +A = int(input()) + +ans = 0 + + +while ans<(N-500): + ans += 500 + +while A>0: + ans += 1 + A -= 1 + if ans==N: + print('Yes') + break + +if ans!=N: + print('No') + + +" +p03910,s098477802,Accepted,"n = int(input()) + +s = 0 +i = 0 +while s < n: + s += i + i += 1 + +if i == 1: + print(1) +else: + ans = list(range(1,i)) + if s - n != 0: ans.remove(s-n) + print('\n'.join(map(str,ans))) +" +p03645,s191852400,Accepted,"N, M = map(int, input().split()) +l = [False]*N +for _ in range(M): + a = list(map(int, input().split())) + j = [1,N] + for i in [0,1]: + if a[i] == j[i]: + if l[a[1-i]-1]: + print('POSSIBLE') + exit() + else: + l[a[1-i]-1] = True +print('IMPOSSIBLE') +" +p03103,s129916145,Wrong Answer,"N, M = map(int, input().split()) + +A = [] +for i in range(N): + a, b = map(int, input().split()) + A.append([a, b]) + +A.sort(key=lambda x:x[0]) + +money = 0 +cnt = 0 +for i in range(N): + for j in range(A[i][1]): + money += A[i][0] + if cnt == N: + print(money) + break" +p02847,s704566946,Accepted,"s = input() +days = {""SUN"":7, + ""MON"":6, + ""TUE"":5, + ""WED"":4, + ""THU"":3, + ""FRI"":2, + ""SAT"":1, + } +if s in days: + print(days[s])" +p02820,s056313187,Wrong Answer,"# d +import numpy as np +n, k = [int(i) for i in input().split()] +r, s, p = [int(i) for i in input().split()] +t = np.array(list(input())) +t = np.where(t == 'r', p, t) +t = np.where(t == 's', r, t) +t = np.where(t == 'p', s, t) +t = t.astype(dtype='int64') +tt = t +for i in range(n-k): + if t[i] == t[i+k]: + tt[i+k] = 0 + elif t[i] != t[i+k]: + pass + +print(np.sum(tt))" +p03495,s821995363,Accepted,"import sys + +n, k = map(int, input().split()) + +a = list(map(int, input().split())) + +num_flag = [0 for i in range(n)] + +for item in a: + num_flag[item - 1] += 1 + +# while 0 in num_flag: +# num_flag.remove(0) + +# num_flag.sort() + +# cnt = 0 +# while len(num_flag) > k: +# print(len(num_flag)) +# cnt += num_flag[0] +# num_flag.pop(0) + +num_flag.sort(reverse=True) + +cnt = 0 +for i in range(k): + cnt += num_flag[i] + +print(""{}"".format(n - cnt))" +p02833,s094375105,Accepted,"def f(n): + ans = 0 + while n>0: + n//=5 + ans+=n + return ans + +x = int(input()) +print(0 if x%2 else f(x//2))" +p02596,s245599915,Wrong Answer,"K = int(input()) # ぜんぜんちがう +ans = -1 + +def moduloseven(K): + for i in range(1000): + sev = int(str(7)*(i+1)) + if sev % K == 0: + ans = i+1 + break + else: + ans = K-1 + return(ans) + +if K % 2 != 0: + if K % 5 != 0: + ans = moduloseven(K) +print(ans)" +p03797,s340497629,Accepted,"n, m = map(int, input().split()) +ans = min((n*2 + m)//4, m//2) +print(ans)" +p03645,s249398471,Wrong Answer,"n,m = map(int,input().split()) +one_li = [] +to_n_li = [] +for _ in range(m): + a,b = map(int,input().split()) + if a == 1: + one_li.append(b) + if b == n: + to_n_li.append(a) +for o in one_li: + if o in to_n_li: + print('POSSIBLE') +else: + print('IMPOSSIBLE')" +p02899,s383140609,Wrong Answer,"from operator import itemgetter + +N = int(input()) +A = list(map(int,input().split())) +B =[] +for i,c in enumerate(A): + B.append([i+1,c]) + +B = sorted(B, key=itemgetter(1)) +print(B) +ans =[] +for i in range(N): + ans.append(B[i][0]) + +C =map(str,ans) +C =' '.join(C) +print(C)" +p03804,s329334876,Accepted,"import numpy as np +N, M = map(int, input().split()) +A = np.array([list(input()) for _ in range(N)]) +B = np.array([list(input()) for _ in range(M)]) +# print('AB', A, B) +for i in range(N - M + 1): + for j in range(N - M + 1): + # print('i j', i, j) + A_subset = A[i:i + M, j:j + M] + # print('A_subset', A_subset) + if np.all(A_subset == B): + print('Yes') + exit() +print('No') +" +p02661,s258891443,Accepted,"n=int(input()) + +s=[] +e=[] +for i in range(n): + a,b=map(int,input().split()) + s.append(a) + e.append(b) + + +s=sorted(s) +e=sorted(e,reverse=True) + +if n%2==1: + x=n//2 + ans=(e[x]-s[x]+1) + +else: + x=n//2 + ts=(s[x]+s[x-1])/2 + te=(e[x]+e[x-1])/2 +# print(ts,te) + ans=(te-ts)//0.5+1 + + +print(int(ans))" +p03069,s530229419,Accepted,"N = int(input()) +S = input() + +white = [0] * (N + 1) +for i in range(N): + if S[i] == ""."": + white[i + 1] = white[i] + 1 + else: + white[i + 1] = white[i] + +ans = N +for i in range(N + 1): + tmp = (i - white[i]) + (white[-1] - white[i]) + if tmp < ans: + ans = tmp + +print(ans) +" +p02719,s287318832,Wrong Answer,"N, K = map(int, input().split()) +if N >= K: + c = N - (int(N/K)-1)*K + print(min(c, abs(c-K))) +else: + print(N)" +p02664,s082116783,Accepted,"t = list(input()) +for i in range(len(t)): + if t[i] == '?': + t[i] = 'D' +print(''.join(t))" +p02723,s662556737,Accepted,"s = input() +if s[2] == s[3] and s[4] == s[5]: + print(""Yes"") +else: + print(""No"") +" +p03077,s060712507,Wrong Answer,"n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +m = min(a,b,c,d,e) + +print(n // m + 5)" +p03281,s938379790,Accepted,"n=int(input()) +if 104>=n: + print(0) +elif 105<=n<=134: + print(1) +elif 135<=n<=164: + print(2) +elif 165<=n<=188: + print(3) +elif 189<=n<=194: + print(4) +else: + print(5)" +p02994,s706420329,Accepted,"N,L=map(int,input().split()) + +Apple_List1=[] +Apple_List2=[] +for i in range(N): + Apple_List1.append(L+i) + Apple_List2.append(abs(L+i)) + +#Apple_List=abs(Apple_List) +Apple_List2.sort() + +flag=0 +if Apple_List2[0] in Apple_List1: + flag=1 +elif -Apple_List2[0] in Apple_List1: + flag=-1 + +print(sum(Apple_List1)-flag*Apple_List2[0])" +p02548,s743661599,Wrong Answer,"from math import sqrt + +N = int(input()) +count = 0 +for c in range(1,N): + for a in range(1,int(sqrt(c))): + if c % a == 0: + if c == a*a: + count += 1 + else: + count += 2 +print(count)" +p03632,s666624635,Wrong Answer,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import math + + +def main(): + A, B, C, D = map(int, input().split()) + print(min(B, D) - max(A, C) if B > C else 0) + + +if __name__ == ""__main__"": + main() +" +p03632,s128574958,Wrong Answer,"a,b,c,d = map(int,input().split()) +if b<=c or a>=d :# 1,2 + print(0) +else: + if (a<=c and bd: + print(""b"",d-c) + elif a>c and b<=d: + print(""c"",b-a) + elif a==c and b==d: + print(0)" +p03723,s783067238,Accepted,"a, b, c = map(int, input().split()) + +cnt = 0 + +while True: + if a % 2 != 0 or b % 2 != 0 or c % 2 != 0: + break + if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b and b == c and c == a: + cnt = -1 + break + + a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2 + cnt += 1 + +print(cnt) +" +p02713,s443380776,Accepted,"import math +import itertools +def gcd(lst): + return math.gcd(math.gcd(lst[0],lst[1]), lst[2]) + +k = int(input()) +lst = [i for i in range(1,k+1)] +itr = itertools.combinations_with_replacement(lst, 3) +ans = 0 + +for i in itr: + st = set(i) + num = len(st) + if num == 1: + ans += i[0] + elif num == 2: + a,b = st + ans += math.gcd(a,b) * 3 + else: + ans += math.gcd(math.gcd(i[0],i[1]), i[2]) * 6 + +print(ans)" +p02622,s000734709,Accepted,"s = input() +t = input() +count = 0 +for i in range(len(s)): + if s[i] != t[i]: + count += 1 +print(count)" +p02553,s422947521,Accepted,"a,b,c,d = (int(x) for x in input().split()) + +ac = a * c +ad = a * d +bc = b * c +bd = b * d + +print(max([ac,ad,bc,bd]))" +p03077,s448015248,Accepted,"from math import * + +N=int(input()) +abcde=[int(input()) for _ in range(5)] +print(ceil(N/min(abcde))+4) +" +p03087,s567060760,Wrong Answer,"from itertools import accumulate +N,Q = map(int,input().split()) +S = str(input()) +lr = [list(map(int,input().split())) for _ in range(Q)] +sl = [0]*N +for i in range(N): + if S[i:i+2] == ""AC"": + sl[i] = 1 +slr = [0]+list(accumulate(sl)) +ans = 0 +for l,r in lr: + l -= 1 + r -= 1 + ans = slr[r]-slr[l] + if slr[r] == slr[r-1]: + ans -= 1 + if slr[l] != slr[l-1]: + ans += 1 + print(ans)" +p02726,s844308807,Wrong Answer,"N, X, Y = map(int, input().split()) +ans = [0] * N + +for i in range(1, N + 1): + for j in range(i + 1, N + 1): + d = min( + j - i, + abs(i - X) + (Y - X - 1) + abs(j - Y), + abs(j - X) + (Y - X - 1) + abs(i - Y) + ) + ans[d] += 1 + +print(*ans[1:]) +" +p02630,s465342175,Wrong Answer,"from collections import Counter + +n = int(input()) +a_L = list(map(int,input().split())) +q = int(input()) + +L = Counter(a_L) +print(0) +# all_sum = sum(a_L) + + + +# ans_L = [] +# for i in range(q): +# b,c = map(int,input().split()) +# if L[b] != 0: +# diff = (c-b) * L[b] +# all_sum = all_sum+diff +# L[c] += L[b] +# ans_L.append(all_sum+1) + + +# for i in ans_L: +# print(i)" +p02988,s885030603,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +ans = 0 +for i in range(n): + if a[i-2] < a[i-1] < a[i]: + ans += 1 +print(ans) + " +p03495,s651143040,Wrong Answer,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +D = {} +for a in A: + if a not in D: + D[a] = 1 + else: + D[a] += 1 +E = sorted(D.items()) +c = 0 +i = 0 +l = len(D) +while l > K: + if (K - l) in D.values(): + c += K - c + l -= K - c + else: + c += E[-1 -i][1] + l -= E[-1 -i][1] + i += 1 +print(c)" +p02996,s087639309,Wrong Answer,"import sys +import math + + +N = int(input()) + +timelis = [] +for _ in range(N): + A,B = map(int, input().split()) + timelis.append([A,B]) + +timelis = sorted(timelis,key=lambda x: x[1]) + +sum_time = 0 +for i in timelis: + need = i[0] + deadline = i[1] + + sum_time = sum_time + need + + if sum_time > deadline: + print(sum_time,need,deadline) + print(""No"") + sys.exit() + +print(""Yes"")" +p02789,s623981909,Accepted,"# coding: utf-8 +N, M = map(int, input().split()) +print(""Yes"" if N == M else ""No"")" +p03759,s301861046,Accepted,"# ι⊥l +def ABC_58_A(): + A,B,C = map(int, input().split()) + + if B == (A+C)/2: + print('YES') + else: + print('NO') + +if __name__ == '__main__': + + ABC_58_A()" +p03324,s590690462,Wrong Answer,"d,n = map(int,input().split()) + +if d == 0: + print(n) +elif d == 1: + print(100*n) +else: + print(1000*n)" +p02775,s919437136,Accepted,"s=input()[::-1]+'0' +n=len(s) +ans=0 +flg=False +for i in range(n): + a=int(s[i]) + if flg: + a+=1 + if a==5: + if int(s[i+1])>=5: + ans+=5 + flg=True + else: + ans+=5 + flg=False + elif a>5: + ans+=10-a + flg=True + else: + ans+=a + flg=False +if flg: + ans+=1 +print(ans)" +p03773,s944031950,Wrong Answer,"a,b= input().split() +a,b=int(a),int(b) +if a+b <24: + print(a+b) +elif a+b>24: + print(a+b-24)" +p02700,s972181229,Accepted,"A,B,C,D = map(int,input().split()) + +if C % B != 0: + ans_A = ((C // B) + 1) +else: + ans_A = C // B + +if A % D != 0: + ans_C = A // D + 1 +else: + ans_C = A // D + + +if ans_A <= ans_C: + print('Yes') +else: + print('No')" +p02694,s672899044,Accepted,"x = int(input()) + +result = 100 +count = 0 +while True: + count += 1 + result = int(result * 1.01) + if result >= x: + break +print(count) +" +p02555,s674918259,Accepted,"from scipy.special import comb +s = int(input()) +l = s // 3 +# print(l) +mod = pow(10, 9) + 7 +ans = 0 +last = s % 3 +for i in range(l, 0, -1): + ans += comb(i+last-1, last, exact=True) % mod + # print(comb(i+last-1, last, exact=True)) + # ans += pow(i, last, mod) + ans %= mod + last += 3 +print(ans) +" +p02881,s910118660,Accepted,"N=int(input()) +can=[] +for i in range(1,int(N**0.5)+1): + if N%i==0: + can.append(i-1+N//i-1) + + +print(min(can)) +" +p02606,s786420287,Wrong Answer,"L, R, d = map(int, input().split()) + +num_lower = int(L / d) +num_upper = int(R / d) +ans = num_upper - num_lower + +print(ans)" +p02717,s578662236,Wrong Answer,"inputline = list(map(lambda x:int(x), input().split("" ""))) +print(inputline[1], inputline[2], inputline[0])" +p02570,s354937932,Wrong Answer,"D, T, S = map(int,input().split()) + +t = D // S + +if t < T: + print(""Yes"") +else: + print(""No"")" +p02689,s867142857,Wrong Answer,"n,m=map(int,input().split()) +h=list(map(int,input().split())) +count=[1]*n +for i in range(m): + a,b=map(int,input().split()) + if h[a-1]>h[b-1]: + count[b-1]=0 + elif h[a-1]==h[b-1]: + count[a-1]=0 + count[b-1]=0 + else: + count[b-1]=0 +print(sum(count)) + +" +p03633,s902157917,Accepted,"import fractions +from functools import reduce + +N=int(input()) +T = [int(input()) for i in range(N)] + +def lcm_base(x, y): + return (x * y) // fractions.gcd(x, y) + +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +print(lcm_list(T))" +p03723,s455725878,Wrong Answer,"cookie = list(map(int,input().split())) + +if len(set(cookie)) == 1: + print(-1) +else: + con = 0 + while True: + a = cookie[0] // 2 + b = cookie[1] // 2 + c = cookie[2] // 2 + cookie[0] = b + c + cookie[1] = c + a + cookie[2] = a + b + con += 1 + if any([i % 2 != 0 for i in cookie]): + break + + print(con)" +p02598,s304349934,Accepted,"from sys import stdin +import numpy as np +n, k = map(int, stdin.readline().split()) +a = np.array(stdin.readline().split(), dtype=np.int64) + +ng = 0 +ok = 10 ** 9 + 1 +while ok - ng > 1: + mid = (ok + ng) >> 1 + if np.sum(0 - - a // mid - 1) <= k: + ok = mid + else: + ng = mid +print(ok) +" +p02888,s421461711,Accepted,"### a<=b<=cととることとし、a,bを固定すると +### cは c K: + print(1 + K) +else: + rest = K - A + 1 + b = (rest // 2) * (B - A) + rest % 2 + A + print(max(1 + K, b)) +" +p02756,s973568038,Wrong Answer,"from collections import deque + +S = input() +Q = int(input()) + +que = deque() + +for s in S: + que.append(s) + +for _ in range(Q): + query = input().split() + + if query[0] == ""1"": + r = que.pop() + l = que.popleft() + que.append(l) + que.appendleft(r) + else: + if query[1] == ""1"": + que.appendleft(query[2]) + else: + que.append(query[2]) + + +print("""".join(list(que))) +" +p03254,s093728307,Accepted,"N,x = map(int,input().split()) +A = sorted(list(map(int,input().split()))) +ans = 0 +for a in A: + x = x-a + if x<0: + break + ans+=1 +print(ans-(x>0))" +p02873,s046446726,Accepted,"S = input() +N = len(S) + 1 +a = [0] * N +b = [0] * N +for i in range(0, N-1): + if S[i] == '<': + a[i+1] = a[i] + 1 + +for i in range(N-2, -1, -1): + if S[i] == '>': + b[i] = b[i+1] + 1 + +res = [max(x, y) for x, y in zip(a, b)] + +print(sum(res)) +" +p03417,s851303946,Accepted,"import sys + +N, M = list(map(int, input().split())) + +if N == M == 1: + print(1) + sys.exit() +elif N == 1 or M == 1: + print(max(max(N, M)-2, 0)) + sys.exit() + +N = max(0, N-2) +M = max(0, M-2) + +print(N*M)" +p03293,s066276105,Accepted,"from collections import deque + +s = deque(input()) +t = deque(input()) +n=len(s) + +yes = False +for _ in range(n): + if s == t: + yes = True + break + s.rotate() + +print('Yes' if yes else 'No')" +p03075,s854694155,Accepted,"a = int (input ()) +b = int (input ()) +c = int (input ()) +d = int (input ()) +e = int (input ()) +k = int (input ()) +if k >= e-a: + print ('Yay!') +else: + print (':(')" +p03386,s854497168,Accepted,"A, B, K = map(int, input().split()) +SA = list(range(A, min(B, A + K))) +SB = list(range(max(A, B - K + 1), B + 1)) + +ans = sorted(set(SA + SB)) +for a in ans: + print(a) +" +p03239,s978767298,Wrong Answer,"n,T=map(int,input().split()) +C=1000 +for i in range(n): + c,t=map(int,input().split()) + if T>=t: + C=min(c,C) +print(C if C<1000 else ""TLE"")" +p02548,s041508577,Accepted,"N = int(input()) + +sigma = 0 +for i in range(1, N): + sigma += (N-1) // i + +print(sigma) +" +p03679,s070447218,Accepted,"X, A, B = map(int, input().split()) +if X-B+A < 0: + print('dangerous') +elif B <= A: + print('delicious') +else: + print('safe')" +p03592,s479927645,Accepted,"N, M, K = map(int, input().split()) + +# nは行で押したボタンの数、mは列で押したボタンの数。 +for n in range(N+1): + for m in range(M+1): + if n * (M - m) + m * (N - n) == K: + print(""Yes"") + exit() +else: + print(""No"")" +p03449,s022476368,Accepted,"def main(): + from itertools import accumulate + N = int(input()) + A = [int(i) for i in input().split()] + B = [int(i) for i in input().split()] + accA = list(accumulate(A)) + accB = list(accumulate([0] + B)) + ans = 0 + for i in range(N): + cur = accA[i] + (accB[N] - accB[i]) + ans = max(ans, cur) + print(ans) + + +if __name__ == '__main__': + main() +" +p03437,s923273781,Wrong Answer,"A,B = map(int,input().split()) +if(B % A == 0): + print(-1) + exit() +else: + print(A)" +p02600,s260991979,Accepted,"import os +import sys +from collections import defaultdict, Counter +from itertools import product, permutations,combinations, accumulate +from operator import itemgetter +from bisect import bisect_left,bisect +from heapq import heappop,heappush,heapify +from math import ceil, floor, sqrt +from copy import deepcopy + + +def main(): + x = int(input()) + ans = 8 + for i in range(400, 2000, 200): + if i <= x <= i+199: + break + ans -= 1 + + print(ans) + +if __name__ == '__main__': + main() +" +p02689,s953402911,Wrong Answer,"from sys import stdin +N,M= list(map(int,stdin.readline().strip().split())) +H=[int(x) for x in input().split()] +road=[] +hig=[] +ans=[] +kari=[] +count=[0]*N +for i in range(M): + road.append(max(list(map(int,input().split())))) +print(len(set(road))) +" +p02911,s511336285,Accepted,"n,k,q=map(int,input().split()) +a=[0]*q +for i in range(q): + a[i]=int(input()) + +b=[0]*n +for i in range(q): + b[a[i]-1]+=1 + +for i in range(n): + if b[i]+k-q>0: + print('Yes') + else: + print('No') + + +" +p03471,s202803287,Accepted,"N, Y = map(int, input().split()) +a = min(Y // 10000, N) + 1 +for i in range(a): + b = min((Y - (10000 * i)) // 5000, N - i) + 1 + for j in range(b): + if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y: + print(i, j, N - i - j) + break + else: + continue + break +else: + print('-1 -1 -1')" +p02777,s043320103,Accepted,"s, t = input().split() +a, b = map(int,input().split()) +u = input() +if u == s: + print(a-1, b) +else: + print(a, b-1)" +p03639,s363051197,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +for i in range(n): + if a[i] % 4 == 0: + a[i] = 2 + elif a[i] % 2 == 0: + a[i] = 1 + else: + a[i] = 0 +# print(a) + +if a.count(0)+(1 if 1 in a else 0) <= a.count(2)+1: + print('Yes') + exit(0) +print('No') +" +p03625,s529379884,Accepted,"from collections import Counter + +N = int(input()) +A = Counter(list(map(int, input().split()))) + +bar = [] +for k, v in A.items(): + bar += [k]*(v//2) +bar.sort(reverse=True) + +if len(bar) < 2: + print(0) +else: + print(bar[0]*bar[1])" +p02755,s616010094,Wrong Answer,"import math + +a,b=map(int,input().split()) +if a%2==0: + s=a*12.5 + s=math.floor(s) + if s-b*10==5: + print(s) + elif b*10-s==5: + print(b*10) + elif b*10==s: + print(s) + else: + print(-1) +else: + t=a*12.5 +0.5 + if t-b*10==3: + t=math.floor(t) + print(t) + + elif b*10-t==7: + print(b*10) + else: + print(-1) +" +p02681,s947671957,Accepted,"s = input() +t = input() + + +if len(s) > 10: + print(""No"") + exit() + +if s != t[:-1] : + print(""No"") + exit() + +alp = list('abcdefghijklmnopqrstuvwxyz') +for i in t: + if i not in alp: + print(""No"") + exit() + +print(""Yes"") + + +" +p02848,s661803339,Wrong Answer,"N = int(input()) +S = list(input()) + +S = ''.join([chr((ord(s)+N-ord('A')%26)+ord('A')) + for s in S]) +print(S)" +p02729,s784610931,Accepted,"N = list(map(int, input().split())) +print(int((N[0] * (N[0] - 1) / 2) + (N[1] * (N[1] - 1) / 2)))" +p02793,s552711951,Wrong Answer,"import numpy as np + +N=int(input()) +A=np.array(list(map(int,input().split()))) +mod = 10**9+7 + +A = np.where(A >= mod, A % mod, A) + +LCM = np.lcm.reduce(A) + +print((LCM//A).sum() % mod)" +p02923,s288433485,Wrong Answer,"N = int(input()) +H = [int(i) for i in input().split()] + +res = 0 +cur_cnt = 0 +for i in range(N-1): + if H[i] >= H[i+1]: + cur_cnt += 1 + else: + if cur_cnt > res: + res = cur_cnt + cur_cnt = 0 + +print(res)" +p03705,s545182271,Accepted,"def main(): + n, a, b = map(int, input().split()) + print(0 if (n == 1 and a != b) or a > b else (b - a) * (n - 1) + a - b + 1) + +if __name__ == '__main__': + main() +" +p03261,s906636063,Accepted,"n = int(input()) +W = list() +ans = ""Yes"" +for i in range(n): + w = input() + W.append(w) +for j in range(1,n): + if W[j][0] != W[j-1][-1] or (W[j] in W[:j]): + ans = ""No"" +print(ans)" +p03221,s215476814,Accepted,"n,m = map(int,input().split()) +all_town = [[] for i in range(n)] +for i in range(m): + p_y = list(map(int,input().split())) + p_y.append(i) + all_town[p_y[0]-1].append(p_y) + +i_id = [] +for town in all_town: + town.sort(key=lambda x: x[1]) + for i in range(len(town)): + left = ""{:0=6}"".format(town[i][0]) + right = ""{:0=6}"".format(i+1) + i_id.append([town[i][2],left+right]) + +i_id.sort(key=lambda x: x[0]) +for id in i_id: + print(id[1]) + " +p03821,s727869506,Wrong Answer,"N = int(input()) +x = [list(map(int, input().split())) for i in range(N)] +ans = 0 +for i in range(N): + a = x[N-i-1][1] - (x[N-i-1][0] % x[N-i-1][1]) + if ans <= a: + ans = a + else: + while (x[N-i-1][0] + ans) % x[N-i-1][1] != 0: + ans += 1 +print(ans)" +p03071,s163844918,Accepted,"a,b = [int(x) for x in input().split()] + +ans = 0 + +for _ in range(2): + if a >= b: + ans += a + a -= 1 + else: + ans += b + b -= 1 + +print(ans)" +p02584,s341670196,Accepted,"# cook your dish here +x,k,d=map(int,input().split()) +l=0 +r=k +while (l0): r=m + else: l=m +ans1=x-k*d+2*l*d; +ans2=x-k*d+2*r*d; +print(min(abs(ans1),abs(ans2))) " +p03345,s687025752,Accepted,"a,b,c,k=map(int,input().split()) +Unfair=10**18 + +if k==0: + print(a-b) + exit() +elif k%2==0: + k=2 +else: + k=1 + +for i in range(k): + a2=b+c + b2=a+c + c2=a+b + a,b,c=a2,b2,c2 + +if a-b>Unfair: + print(""Unfair"") +else: + print(a-b)" +p02601,s180944197,Wrong Answer,"a,b,c = map(int,input().split()) +k = int(input()) +if b<=a: + x = 0 + for i in range(k): + b*=2 + if a < b: + x += (i+1) + break + y = 2*(k-x) if k-x > 0 else 1 +else: + y = 0 + y += k +print(['No','Yes'][b 10 **18: + print(-1) + break +else: + print(answer)" +p03427,s184102380,Wrong Answer,"import sys +import itertools +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +import math +import collections +import copy +import decimal + + +if __name__ == ""__main__"": + n = int(input()) + if len(str(n)) == 1: + print(n) + sys.exit() + n = list(str(n)) + if n[0] == ""1"": + c = ""9""*(len(n)-1) + else: + c = str(int(n[0])-1)+ ""9""*(len(n)-1) + ans = 0 + for i in c: + ans += int(i) + print(ans)" +p03998,s404144879,Accepted,"from collections import deque +Sa = deque(input()) +Sb = deque(input()) +Sc = deque(input()) + +game = ""a"" +answer = """" +while True: + try: + if game == ""a"": + game = Sa.popleft() + elif game == ""b"": + game = Sb.popleft() + elif game == ""c"": + game = Sc.popleft() + except: + answer = game + break + +print(answer.upper())" +p02640,s593538640,Accepted,"x, y = map(int, input().split()) +a = (4 * x - y) / 2 +b = (y - 2 * x) / 2 +if ((a >= 0) & (b >= 0) & (a.is_integer() == True) & (b.is_integer() == True)): + print('Yes') +else: + print('No')" +p02789,s332006608,Wrong Answer,"# !/usr/nbin/python3 + +"""""" +https://atcoder.jp/contests/abc152/tasks/abc152_a +AC or WA. +"""""" + +def solve(n, m): + if n == m: print(""YES"") + else: print(""NO"") + +if __name__ == ""__main__"": + n, m = list(map(int, input().split())) + + solve(n, m) +" +p02881,s034461141,Wrong Answer,"n = int(input()) +diff_min = 100000000000 +for a in range(1, n + 1): + if n % a == 0: + b = n // a + diff = a + b - 2 + diff_min = min(diff_min, diff) + if a * a > n: + break +print(diff_min) +" +p03286,s032334304,Accepted,"n=int(input()) +x = """" +while n!=0: + x = str(n%2) + x + n = -(n//2) +if x == """": + print(0) +else: + print(x) +" +p03785,s558713890,Accepted,"N,C,K = map(int,input().split()) +T = [int(input()) for _ in range(N)] +T.sort() +time = T.pop(0) +people = 1 +ans = 1 +for t in T: + if t <= time + K and people < C: + people += 1 + else: + time = t + people = 1 + ans += 1 +print(ans)" +p02880,s725731268,Wrong Answer,"N = int(input()) +num = [2, 3, 4, 5, 6, 7, 8, 9] +i = 2 +for i in range(8): + if N/(i+2) in num: + print(""Yes"") + break + else: + print(""No"") + break + " +p02701,s806141004,Accepted,"#!/usr/bin/env python3 + +import sys + +DEBUG = False + +def read(t): + return t(sys.stdin.readline().rstrip()) + + +def read_list(t, sep = "" ""): + return [t(s) for s in sys.stdin.readline().rstrip().split(sep)] + + +def dprint(*args, **kwargs): + if DEBUG: + print(*args, **kwargs) + return + + +def main(): + n = read(int) + s = set() + for _ in range(n): + s.add(read(str)) + print(len(s)) + + +if __name__ == ""__main__"": + main() +" +p03835,s304661224,Wrong Answer,"k, s = map(int, input().split()) + +if s==3*k: + print(1) +else: + ans=0 + for i in range(k+1): + if i>s: + break + for j in range(k+1): + if i+j+k>=s and s-i-j>=0: + ans+=1 + else: + break + + print(ans)" +p02923,s163620867,Accepted,"n=int(input()) +h=list(map(int,input().split())) +a=[0]*n + +for i in range(n-1): + if h[i]>=h[i+1]: + a[i+1]=a[i]+1 + else: + a[i+1]=0 + +print(max(a))" +p03761,s963187051,Accepted,"from string import* +from collections import* +_, *s = map(Counter, open(0)) +a = """" +for i in ascii_lowercase: + a += i * min(c.get(i, 0) for c in s) +print(a)" +p02948,s936740164,Accepted,"import heapq + +n, m = map(int, input().split()) +lis = [[] for _ in range(m + 1)] + +for i in range(n): + a, b = map(int, input().split()) + if a <= m: + lis[a].append(-b) + +cnd = [] +res = 0 + +for j in range(1, m + 1): + for e in lis[j]: + heapq.heappush(cnd, e) + if cnd: + res += -heapq.heappop(cnd) +print(res) +" +p02888,s230814516,Accepted,"import bisect + +n = int(input()) +L = list(map(int,input().split())) +L.sort() + +ans = 0 +for a in range(0,n): + for b in range(a+1,n): + p = bisect.bisect_left(L, L[a]+L[b]) + ans += max(p-(b+1),0) + +print(ans)" +p02899,s188335736,Accepted,"import sys +input = sys.stdin.readline + +def readlines(n): + for _ in range(n): + yield map(int, input().split()) + + +def main(): + N = int(input()) + A = sorted(enumerate(map(int, input().split()), 1), key=lambda x: x[1]) + print("" "".join(str(i) for i, a in A)) + +main() +" +p02627,s342029063,Accepted,"s=input() + +if s in ""abcdefghijklmnopqrstuvwxyz"": + print(""a"") +else: + print(""A"")" +p03309,s890764699,Accepted,"import numpy as np + +N = int(input()) +A = np.array(list(map(int, input().split(' ')))) +i = np.arange(1, N + 1) + +b = int(np.median(sorted(A - i))) + +print(np.sum(np.abs(A - (i + b)))) +" +p03380,s393814867,Accepted,"import bisect + +n = int(input()) +A = [int(_) for _ in input().split()] + +A.sort() +x = A[-1] +y = bisect.bisect(A, x / 2) + +if abs(A[y] - x / 2) < abs(A[y-1] - x / 2): + print(x, A[y]) +else: + print(x, A[y-1]) +" +p02792,s441394579,Accepted,"n=int(input()) +a=[[0]*10 for i in range(10)] +for i in range(1,n+1): + a[int(str(i)[0])][i%10]+=1 +def N(x,y): # no of x...y < n + return a[x][y] + +ans=0 +for x in range(1,10): + ans+=N(x,x)*N(x,x) + for y in range(x+1,10): + ans+=N(x,y)*N(y,x)*2 +print(ans)" +p02705,s142229680,Accepted,"import math +R = int(input()) +print(R*2*math.pi)" +p02797,s157954021,Wrong Answer,"# -*- coding: utf-8 -*- + +n,k,s = list(map(int,input().split())) +a = [] +count = 0 +st = """" + +for i in range(k): + a.append(s) + +for i in range(n-k): + if s != 2: + a.append(s-1) + else: + a.append(s-2) + +for i in range(n): + if st == """": + st = str(a[count]) + else: + st += "" "" + str(a[count]) + count += 1 + +print(st) +" +p02608,s701547345,Accepted,"def main(): + N = int(input()) + ans = [0]*(N+1) + for x in range(1, 101): + for y in range(1, 101): + for z in range(1, 101): + a = x*x + y*y + z*z + x*y + y*z + z*x + if a <= N: + ans[a] += 1 + for i in range(1, N+1): + print(ans[i]) + + +if __name__ == ""__main__"": + main() +" +p02730,s981560237,Wrong Answer,"def palindrome(s): + return s == """".join(list(reversed(s))) + +S = input() +N = len(S) + +s1 = S[:(N-1)//2] +s2 = S[(N+1)//2:] +print(""Yes"" if palindrome(s1) and palindrome(s2) else ""No"")" +p03264,s451846405,Accepted,"K = int(input()) +print(int((K/2)**2) if K%2==0 else int(((K+1)/2)*((K-1)/2)))" +p03624,s864758548,Wrong Answer,"l=set(input()) +allalphabet=[] +#print(l) +flag=1 +for i in range(97,123,1): + allalphabet.append(chr(i)) +allalphabet=set(allalphabet) +sub=list(allalphabet-l) +#print(sub) +if len(sub)>0: + print(sub[0]) +else: + print(""None"")" +p03524,s698128186,Accepted,"S = input() + +X = [S.count(ch) for ch in ""abc""] + +T = (""ABC"" * (len(S) // 3 + 1))[:len(S)] +Y = [T.count(ch) for ch in ""ABC""] + +if set(X) == set(Y): + print(""YES"") +else: + print(""NO"") + +" +p03696,s176008767,Accepted,"#!/usr/bin/env python +# coding: utf-8 + +# In[1]: + + +N = int(input()) +S = input() + + +# In[2]: + + +l = 0 +r = 0 +for s in S: + if s == ""("": + r += 1 + else: + if r > 0: + r -= 1 + else: + l += 1 +ans = """".join([""(""*l , S, "")""*r]) +print(ans) + + +# In[ ]: + + + + +" +p03680,s070316629,Wrong Answer,"# ABC 065: B – Trained? +n = int(input()) +a = [int(input()) - 1 for _ in range(n)] + +lightned = [] +lightning = 0 + +while a[lightning] not in lightned: + lightning = a[lightning] + + if lightning== 1: + break + + lightned.append(lightning) + +print(len(lightned) + 1 if a[lightning] == 1 else -1)" +p02641,s573708286,Accepted,"x, n = map(int, input().split()) + +ret = 0 +diff = 10 ** 9 + +if n == 0: + s = input() + print(x) + exit() +else: + p = set(list(map(int, input().split()))) + for i in range(102): + if i in p: + continue + else: + tmp_d = abs(x - i) + if diff > tmp_d: + ret = i + diff = tmp_d + +print(ret) +" +p03759,s966432151,Wrong Answer,"a,b,c = map(int,input().split()) +if b-a == c-b: + print(""Yes"") +else: + print(""No"")" +p02676,s351945304,Accepted,"datanum = int(input()) +mojiretu = input() + +if len(mojiretu) <= datanum: + print(mojiretu) + +else: + print(mojiretu[:datanum] + ""..."")" +p03380,s405814644,Accepted,"n=int(input()) +A=list(map(int,input().split())) +ma = max(A) +mid = ma / 2 +l = 10000000000 +f = 0 +for i in range(n): + if ((ma == A[i]) and (f==0)): + f = 1 + continue + if abs(l) > abs(A[i]-mid): + l = A[i]-mid +print(ma, int(mid+l)) +" +p02691,s247959132,Wrong Answer,"from collections import defaultdict +n = int(input()) + +ij = defaultdict(int) +ji = defaultdict(int) + +As = list(map(int, input().split())) +for j in range(n): + ij[j+As[j]] += 1 + ji[j-As[j]] += 1 +print(sum(ij[k] * ji[k] for k in ji.keys() if k > 1))" +p02677,s865099553,Wrong Answer,"import math + +A, B, H, M=map(int,input().split()) + +a = int(A) +b = int(B) +h = int(H) +m = int(M) +ang = 6*m - (30*h + 0.5*m) + +cosa =math.cos(ang) + +c = math.sqrt(a**2 + b**2 - 2 * a * b * cosa) + + +print(c) +" +p02577,s270809591,Accepted,"n = input() +sum = 0 +for i in n: + sum += int(i) +if sum%9 ==0: + print(""Yes"") +else: + print(""No"")" +p02866,s984275970,Accepted,"from collections import Counter +N = int(input()) +D = list(map(int, input().split())) +MOD = 998244353 + + +if D[0] != 0: + print(0) + exit() + + +if D.count(0) != 1: + print(0) + exit() + + +ans = 1 +C = Counter(D) +for k, v in C.items(): + if k == 0: + continue + ans *= pow(C[k - 1], v, MOD) + ans %= MOD + +print(ans % MOD) +" +p02911,s440439211,Accepted,"def solve(): + N, K, Q = map(int, input().split()) + l = [K-Q] * N + for _ in range(Q): + a = int(input()) + l[a-1] += 1 + for i in l: + ans = 'Yes' if i > 0 else 'No' + print(ans) + +# print(solve()) + +# def solve()が@return voidのとき +solve()" +p03309,s643602554,Accepted,"N = int(input()) +*A, = map(int, input().split()) + +for i in range(N): + A[i] = A[i] - (i+1) + +A.sort() + +b = A[N//2] + +ans = 0 +for i in range(N): + ans = ans + abs(A[i]-b) + +print(ans) +" +p03623,s502244511,Wrong Answer,"x, a, b = map(int, input().split()) +i = a-x +j = b-x +if i < 0: + if i > j: + print('A') + if i < j: + print('B') +elif j < 0: + if i < j: + print('A') + if i > j: + print('B') +else: + if i < j: + print('A') + if i > j: + print('B') +" +p03095,s332710466,Accepted,"from collections import Counter +def main(): + n = int(input()) + s = input() + mod = 1000000007 + c = Counter(s) + ans = 1 + for v in c.values(): + ans = ans * (v + 1) % mod + print(ans - 1) +if __name__ == '__main__': + main() +" +p02690,s298953468,Accepted,"X = int(input()) + +#x^5-y^5=(x-y)(x^4+x^3y+x^2y^2+xy^3+y^4) + +#for x in range(1, 121): +# if ((x**5) - ((x-1)**5)) >= 1000000000: +# print(x) + +for a in range(0, 121): + for b in reversed(range(-122, 120)): + if b**5 == a**5-X: + print(a, b) + exit() + +" +p03239,s708471128,Accepted,"N, T=map(int, input().split()) + +min_cost=10000 +for i in range(N): + c, t=map(int, input().split()) + + if t<=T and c>j) & 1): + for k in range(m): + l[k] += s[j][k] + for check in l: + if check < x: + flag = 1 + if flag == 0: + mini = min(mini, l[0]) +print(mini) " +p02548,s483419737,Wrong Answer,"N = int(input()) +count = 0 + +for a in range(1, N): + tmp = (N-1) // a + if a < (N) // 2: + count += tmp + else: + count += 1 + +print(count)" +p03136,s150097505,Accepted,"n=int(input()) +l=list(map(int,input().split())) +m=max(l) +l.remove(m) +print('Yes' if m=b or a>=k: + ans=k+1 +else: + k-=a-1 + ans+=a-1 + ans+=(k//2)*(b-a) + if k%2==1: + ans+=1 +print(ans) + +" +p02607,s156192362,Accepted,"how_many = int(input()) +results = [] +index = 0 +numbers = {index+1:int(item) for index,item in zip(range(how_many),input().split())} +for key_value in numbers.items(): + if key_value[0] % 2 == 1 and key_value[1] % 2 == 1: + results.append(True) +print(len(results)) +" +p02820,s217579543,Accepted,"n, k = map(int, input().split()) +r, s, p = map(int, input().split()) +T = list(input()) + + +for i in range(k, n): + if T[i] == T[i - k]: + T[i] = ""x"" + +answer = 0 +for t in T: + if t == ""r"": + answer += p + elif t == ""s"": + answer += r + elif t == ""p"": + answer += s + + +print(answer) +" +p03324,s833314810,Accepted,"def main(): + D, N = map(int, input().split("" "")) + answer = 100 ** D * N + i = 1 + flag = True + while flag: + if not answer % 100 ** (D + i): + answer += 100 ** D + else: + flag = False + print(answer) + + +if __name__ == '__main__': + main()" +p02988,s581451039,Wrong Answer,"n = int(input()) +p = list(map(int, input().split())) + +cnt = 0 +for i in range(1,n-1): + print(p[i-1], p[i], p[i+1]) + if (p[i] > p[i-1]) and (p[i] < p[i+1]): cnt += 1 + if (p[i] < p[i-1]) and (p[i] > p[i+1]): cnt += 1 +print(cnt)" +p02797,s176298495,Accepted,"#%% for atcoder uniittest use +import sys +input= lambda: sys.stdin.readline().rstrip() +def pin(type=int): + return map(type,input().split()) + +#%%code + +def resolve(): + bigint=10**9 + N,K,S=pin() + if S!=bigint: + print(*([bigint]*(N-K)+[S]*(K))) + return + print(*([1]*(N-K)+[bigint]*K)) + + +#%%submit! +resolve()" +p03665,s381334288,Accepted,"N, P = map(int, input().split()) +A_li = list(map(int, input().split())) +for i, a in enumerate(A_li) : + if a % 2 == 1 : + break + if i == N - 1 : + if P == 0 : + print(2 ** N) + else : + print(0) + exit() +print(2 ** (N - 1)) +" +p02677,s485131639,Accepted,"import math +A, B, H, M = map(int, input().split()) + +long = H * 30 + M * 0.5 +short = M * 6 +angle = abs(long-short) +if angle > 180: + angle = 360 - angle + +ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle)) +ans = (ans) ** (1/2) +print(ans)" +p02633,s998628297,Accepted,"def main(): + n = int(input()) + i = 1 + now = n + while True: + if now % 360 == 0: + print(i) + break + else: + i += 1 + now += n + + +main()" +p03352,s896073745,Accepted,"import math +X=int(input()) +x=int((X**(1/2))//1) +A=[] +y=int(math.log2(X)//1) +for i in range(x+1): + for j in range(y+1): + if i**j<=X: + A.append(i**j) +print(max(A))" +p02731,s450985290,Accepted,"l = int(input()) +print((l / 3)**3)" +p03486,s407166555,Accepted,"s = list(input()) +t = list(input()) +s.sort() +t.sort(reverse=True) +print(""Yes"") if s < t else print(""No"")" +p03012,s752404430,Accepted,"import os, sys, re, math + +N = int(input()) +W = [int(n) for n in input().split()] + +result = 10000 +for i in range(1, len(W)): + result = min(result, abs(sum(W[:i]) - sum(W[i:]))) + +print(result) +" +p02717,s026674677,Accepted,"x,y,z=map(int, input().split()) +buf=y +y=x +x=buf +buf=z +z=x +x=buf +print(x,y,z)" +p03380,s946706309,Accepted,"n=int(input()) +a=list(map(int,input().split())) +a.sort(reverse=True) +cand=a[1] +for i in range(1,n-1): + if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]): + cand = a[i+1] + else: + break +print(a[0], cand)" +p02699,s395019495,Accepted,"import sys +s,w=map(int, input().split()) +if s > w: + print(""safe"") +else: + print(""unsafe"")" +p03448,s162941105,Accepted,"A, B, C, X = [int(input()) for i in range(4)] +print(sum(500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))" +p03665,s840442955,Accepted,"import functools + + +@functools.lru_cache(maxsize=None) +def num_counts(size, P): + if size == 1: + return 1 + (A[size - 1] + 1) % 2 if P == 0 else A[size - 1] % 2 + if A[size - 1] % 2 == 0: + return num_counts(size - 1, P) * 2 + else: + return num_counts(size - 1, P) + num_counts(size - 1, (P + 1) % 2) + + +if __name__ == ""__main__"": + N, P = [int(x) for x in input().split("" "")] + A = [int(x) for x in input().split("" "")] + print(num_counts(len(A), P)) +" +p02802,s070542587,Accepted,"n, m = map(int, input().split()) + +ac_check = [0 for _ in range(n)] +wa_check = [0 for _ in range(n)] + +for i in range(m): + i, judge = input().split() + i = int(i)-1 + if judge == 'AC': + if ac_check[i] == 0: + ac_check[i] = 1 + + elif judge == 'WA': + if ac_check[i] == 0: + wa_check[i] += 1 +wa = 0 +for i in range(n): + if ac_check[i] == 1 and wa_check != 0: + wa += wa_check[i] + +print(sum(ac_check), wa) +" +p03659,s905633596,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +X = sum(a) +ans = 10 ** 9 +x = 0 +for i in range(n): + x += a[i] + if (i + 1) < n: + ans = min(ans, abs(X - 2 * x)) + +print(ans)" +p02786,s852643594,Accepted,"p=int(input()) + +count=0 +ans=1 + +while p>1: + count += 1 + p = p//2 + ans += 2**(count) + +print(ans) +" +p04030,s398832660,Accepted,"t="""" +for x in input(): + if x==""B"":t=t[:-1] + else:t+=x +print(t)" +p03665,s204478764,Wrong Answer,"n, p = map(int, input().split()) +a = list(map(int, input().split())) +flag = True +for i in a: + if i % 2 == 0: + continue + else: + flag = False + break + +if n == 1 and a[0] % 2 == 0: + if p == 0: + print(2) + else: + print(0) +elif n == 1 and a[0] % 2 == 1: + print(1) + +else: + if flag: + print(2 ** n) + else: + print(2 ** n // 2)" +p03962,s551661329,Accepted,"#入力 +lst = input().split() + +#整数値化 +for i in range(len(lst)): + lst[i] = int(lst[i]) + +#ソート +lst.sort() + +#出力 +if lst[0] == lst[2]: + print(1) +elif lst[0] == lst[1] or lst[1] == lst[2]: + print(2) +else: + print(3)" +p02772,s764345531,Accepted,"n = int(input()) + +a = list(map(int,input().split())) + +for i in a: + if(i % 2 == 0): + if(i % 3 != 0 and i % 5 != 0): + print('DENIED') + exit() +print('APPROVED')" +p02695,s009997065,Accepted,"from itertools import combinations_with_replacement +def main(): + n,m,q=map(int,input().split()) + ABCD=[list(map(int,input().split())) for _ in range(q)] + ans=0 + L=list(range(1,m+1)) + for Q in combinations_with_replacement(L,n): + Q=list(sorted(Q)) + tmp=0 + for a,b,c,d in ABCD: + if Q[b-1]-Q[a-1]==c: + tmp+=d + ans=max(ans,tmp) + print(ans) + +if __name__=='__main__': + main()" +p02713,s985506268,Accepted,"k = int(input()) + +def gcd_(a, b): + if a < b: + a, b = b, a + while not a % b == 0: + a, b = b, a % b + return b + +s = 0 +for i in range(1, k + 1): + for j in range(1, k + 1): + p = gcd_(i, j) + if p == 1: + s += k + else: + for h in range(1, k + 1): + s += gcd_(p, h) + +print(s)" +p02989,s493347970,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + n=int(input()) + l=list(map(int,input().split())) + l.sort() + num=n//2 + print(l[num]-l[num-1]) +resolve()" +p02657,s842282970,Wrong Answer,"A,B = map(int, input().split()) + +answer = A * B +print('answer')" +p03607,s419413555,Wrong Answer,"ans = 0 +n = int(input()) +l = [int(input()) for _ in range(n)] +l.sort() +c = 1 +for i in range(n-1): + if l[i] == l[i+1]: + c += 1 + else: + if c%2 != 0: + ans += 1 + c = 1 +print(ans)" +p03455,s413834939,Accepted,"a,b=(int(x) for x in input().split()) +print(""Even"" if (a*b) % 2 == 0 else ""Odd"" )" +p03000,s132249155,Accepted,"icase=0 +if icase==0: + n,x=map(int,input().split()) + l=list(map(int,input().split())) + d=0 + for i in range(n): + d=d+l[i] + if d>x: + print(i+1) + break + if d<=x: + print(n+1)" +p02952,s578600021,Accepted,"s=input() +n=int(s) +s=list(s) +d=len(s) +r=0 +for ii in range(d-1): + if ii%2==0: + r+=10**(ii+1)-10**ii +if d%2==1: + r+=n-10**(d-1)+1 +print(r) + " +p02946,s193249905,Accepted,"k,x = map(int,input().split()) +print("" "".join(map(str,list(range(x-k+1,x+k)))))" +p03317,s152315138,Wrong Answer,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +mini = a.index(1) +l = mini // (k-1) +lm = mini % (k-1) +r = (n - mini - 1) // (k-1) +rm = (n - mini - 1) % (k-1) +# print(l, r, lm, rm) +print(l + r + ((lm + rm + 1) // k + ((lm + rm + 1) % k != 0)))" +p03836,s930982703,Accepted,"sx,sy,tx,ty = map(int,input().split()) + +dx = tx-sx +dy = ty-sy + +print(dy*""U""+dx*""R""+dy*""D""+dx*""L""+""L""+(dy+1)*""U""+(dx+1)*""R""+""D""+""R""+(dy+1)*""D""+(dx+1)*""L""+""U"") +" +p03106,s544968492,Wrong Answer,"split = input().split() +a = int(split[0]) +b = int(split[1]) +c = int(split[2]) +nums = [] + +check = a if a < b else b + +for i in range(1, check + 1, 1): + if a % i == 0 and b % i == 0: + nums.append(i) +print(nums[c-1])" +p03479,s977197508,Accepted,"temp=list(map(int, input().split())) +X=temp[0] +Y=temp[1] + +ans=0 +while True: + ans+=1 + X*=2 + if X>Y: + break +print(ans)" +p03456,s503725641,Wrong Answer,"a,b=map(str,input().split()) +c=int(a+b) +for i in range(1,101): + if i**2==c: + print(""Yes"") + exit() +print(""No"") +" +p02687,s933800569,Wrong Answer,"s = input() + +if s == ""ABC"": + print (""ARC"") +else: + print (s)" +p03219,s860795243,Accepted,"x, y = map(int, input().split()) +print(x + y//2)" +p02594,s880008668,Wrong Answer,"x=int(input()) + +if x >= 30: + print(""yes"") +else: + print(""No"")" +p02989,s103270718,Accepted,"N = int(input()) +List = list(map(int,input().split())) + +List.sort() + +a = List[int(N/2-1)] +b = List[N//2] + +print(int(b-a)) +" +p03475,s640456427,Accepted,"N=int(input()) +csf=[list(map(int,input().split()))for _ in range(N-1)] +i=0 +while i= M: + ans = M//2 +else: + ans = N + M -= N*2 + ans += M//4 + +print(ans)" +p03680,s981167425,Accepted,"n = int(input()) +a = [int(input()) for _ in range(n)] +cnt = 0 +b = a[0] +while cnt <= n: + cnt += 1 + if b==2: + print(cnt) + exit() + b = a[b-1] + +print(-1)" +p03435,s518410733,Accepted,"c=[list(map(int,input().split())) for _ in range(3)] +s=0 +for i in range(3): + for j in range(3): + s+=c[i][j] +if 3*(c[0][0]+c[1][1]+c[2][2])==s: + print(""Yes"") +else: + print(""No"")" +p02829,s184985883,Accepted,"A=int(input()) +B=int(input()) +print(6-(A+B))" +p02723,s013421152,Wrong Answer,"s = input() + +if s[2]== s[3] and s[4] == s[5]: + print(""yes"") +else: + print(""No"")" +p03030,s643072287,Wrong Answer,"n=int(input()) +sp=[0]*n +for i in range(n): + s,p=input().split() + p=str(100-int(p)) + if len(p)==1: + p=""0""+p + sp[i]=[s+p,i+1] +sp.sort() +for i in range(n): + print(sp[i][1])" +p02970,s976804081,Wrong Answer,"a,b=map(int,input().split()) +b=b*2+1 +c=0 +while 1: + if a-b>0: + c+=1 + else: + break + +print(c) " +p03795,s514220796,Wrong Answer,"import math +N = int(input()) +print(math.factorial(N)%(10**9+7))" +p03037,s856366307,Wrong Answer,"N,M=map(int, input().split()) +list_lr=[list(map(int, input().split())) for _ in range(M)] +a=list_lr[0][1]-list_lr[-1][0]+1 +print(a if a<=N else N)" +p02860,s577514057,Accepted,"n=int(input()) +a=input() +if n%2==0 and a[:n//2]==a[n//2:]: + print(""Yes"") +else: + print(""No"")" +p03208,s586456885,Accepted,"n, k = map(int, input().split()) +H = sorted(int(input()) for _ in range(n)) +tmp = H[k - 1] - H[0] +best = tmp +for i in range(1, n - k + 1): + tmp = H[k + i - 1] - H[i] + if tmp < best: + best = tmp +print(best)" +p03760,s020539973,Accepted,"o = str(input()) +e = str(input()) + +ans = """" +judge = False +if len(o)-len(e) == 1: + judge = True + +for i in range(len(e)): + ans += o[i] + ans += e[i] +if judge: + ans += o[-1] + +print(ans)" +p03998,s316779039,Wrong Answer,"s = {s: list(input()) for s in [""a"",""b"",""c""]} +x = s[""a""][0] +del s[""a""][0] +if s[""a""] == []: + a = False + x = ""a"" + +a = True +while(a): + if s[x] == []: + break + x = s[x][0] + del s[x][0] +print(x.upper())" +p03001,s745020399,Wrong Answer,"W,H,w,h = map(int, input().split()) +ans =0 +if w*H+h*W ==W*H: + ans =1 +elif H*w==h*W: + ans =1 + +print(str(W*H/2)+' '+ str(ans))" +p02706,s185445339,Wrong Answer,"n,m = map(int,input().split()) +grid = [] +a = list(map(int, input().strip().split())) + +res = n - sum(a) +if(res <= 0): + res = -1 +print(res) + +" +p02783,s510396563,Accepted,"h, a = [int(i) for i in input("""").split("" "")] +print((h+a-1)//a)" +p03013,s968674969,Accepted,"n,m,*a=map(int,open(0).read().split()) +mod=10**9+7 +p=[1] +a=iter(a) +b=next(a,-1) +if 1==b: + p.append(0) + b=next(a,-1) +else: + p.append(1) +for i in range(2,n+1): + if i==b: + p.append(0) + b=next(a,-1) + else: + p.append((p[i-1]+p[i-2])%mod) +print(p[-1])" +p03339,s214856976,Accepted,"n = int(input()) +S = input() +re = 0 +for s in S: + if s == 'E': + re += 1 +lw = 0 +c = 3*10**5 +for i in range(n): + if S[i] == 'E': + re -= 1 + c = min(c, re+lw) + + if S[i] == 'W': + lw += 1 +print(c) +" +p03241,s094551324,Accepted," +N,M = map(int, input().split()) + +ans = [] +for i in range(1, int(M**0.5)+1, 1): + if M%i==0: + ans.append([i,M//i]) + +a = 0 +for x,y in ans: + if x>=N: + a = max(a, y) + if y>=N: + a = max(a, x) + +print(a)" +p03419,s768424913,Accepted,"n,m=map(int,input().split()) +n,m=min(n,m),max(n,m) +if n>1 and m>1: + print((n-2)*(m-2)) +else: + if m==1: + print(1) + else: + print(m-2)" +p03778,s390312257,Accepted,"w,a,b=map(int,input().split()) +print(max(0,abs(a-b)-w))" +p03001,s567955422,Accepted,"W,H,x,y=map(int,input().split()) +S = H*W/2 +res = 0 +if x*2 == W and y*2 == H: + res = 1 +print(S,res)" +p02859,s941196995,Accepted,"r = int(input()) + +print(r**2)" +p02546,s275918122,Wrong Answer,"s = input() + +if s[-1] != 's': + print(s) +else: + print(s + 'es')" +p02772,s045204771,Accepted,"def solve(): + N = int(input()) + A = list(map(int,input().split())) + for i in range(N): + if A[i] % 2 == 0: + if A[i] % 3 != 0 and A[i] % 5 != 0: + print('DENIED') + exit() + print('APPROVED') + + +if __name__ == '__main__': + solve() +" +p02790,s422673841,Accepted,"a, b = map(int, input().split()) +a_s = str(a) * b +b_s = str(b) * a + +if a_s == b_s: + print(a_s) +elif a_s < b_s: + print(a_s) +else: + print(b_s)" +p02547,s856449591,Accepted,print('NYoe s'[' 1 1 1'in' '.join(str(len({*t.split()}))for t in open(0))::2]) +p04033,s439744489,Accepted,"import sys +def rs(): return sys.stdin.readline().rstrip() +def ri(): return int(rs()) +def rs_(): return [_ for _ in rs().split()] +def ri_(): return [int(_) for _ in rs().split()] + +a, b = ri_() +if a == 0 or b == 0 or (a < 0 and b > 0): + ans = 'Zero' +elif a > 0 and b > 0: + ans = 'Positive' +else: + if (b - a + 1) % 2 == 0: + ans = 'Positive' + else: + ans = 'Negative' +print(ans)" +p02612,s561988032,Accepted,"a = int(input()) +print(1000 - (a % 1000) if a % 1000 != 0 else 0)" +p02995,s277373307,Accepted,"import fractions +def div_cnt(x): + return b//x-(a-1)//x + +a,b,c,d = map(int,input().split()) +e = c*d//fractions.gcd(c,d) +cnt = b-a+1 +c_cnt = div_cnt(c) +d_cnt = div_cnt(d) +e_cnt = div_cnt(e) +print(cnt-c_cnt-d_cnt+e_cnt)" +p03126,s715449323,Accepted,"N,M = map(int,(input().split())) +K = [[] for _ in range(N)] +for i in range(N): + K[i] = list(map(int,(input().split()))) + +like = [0]*M +for i in range(N): + for j in range(1,len(K[i])): + like[K[i][j]-1] += 1 + +c = 0 +for i in range(M): + like[i] -= N + + +for i in range(M): + if like[i] == 0: + c += 1 + +print(c)" +p03077,s659797755,Wrong Answer,"import sys +#import numpy as np +import math +#from fractions import Fraction +#import itertools +from collections import deque +#import heapq +from fractions import gcd + +input=sys.stdin.readline +n=int(input()) +x=[int(input()) for _ in range(5)] +t=[0]*5 +t[0]=math.ceil(n/x[0]) +for i in range(1,5): + if x[i]>=x[i-1]: + t[i]=t[i-1]+1 + else: + t[i]=i+1+math.ceil(n/x[i]) +print(t[-1])" +p02982,s640782079,Accepted," +import numpy as np +n,d=map(int,input().split()) +zahyo=[0]*n +count=0 + +# 入力受けて多次元アレイ作成 +for i in range(n): + zahyo[i]=list(map(int,input().split())) +arr=np.array(zahyo) + +# +for i in range(n): + for j in range(i+1,n): + dis=sum((arr[i]-arr[j])**2) + if (dis**0.5).is_integer(): + count+=1 +print(count) +" +p03351,s956731799,Wrong Answer,"# a,b,c,d(距離) :標準入力 +a, b, c, d = map(int, input().split()) + + +# 直接的に会話可↓ +# AさんとCさんが直接会話可→ a-c <= d +# 間接的に可↓ +# AさんとBさんが直接会話可→ a-b <= d +# BさんとCさんが直接会話可→ b-c <= d +if (a - c) <= d: + print('yes') +elif (a - b) <= d and (b - c) <= d: + print('yes') +else: + print('no')" +p02748,s931165083,Wrong Answer,"A,B,M=[int(x) for x in input().split()] + +a = [int(x) for x in input().split()] +b = [int(x) for x in input().split()] + +waribiki = [[0 for i in range(A)]for j in range(B)] + +for i in range(M): + x,y,c=[int(x) for x in input().split()] + waribiki[y-1][x-1] = min(c,waribiki[y-1][x-1]) + +ans = 1000000007 +for i in range(A): + for j in range(B): + p = a[i]+b[j]-waribiki[j][i] + if p +# +S = input() +print(S[:3]) +" +p02553,s445833418,Accepted,"a,b,c,d = map(int, input().split()) + +print(max( + a*c, + a*d, + b*c, + b*d +))" +p02753,s572755328,Accepted,"s = input() + +if len(set(s)) == 1: + print(""No"") +else: + print(""Yes"")" +p02897,s135525478,Wrong Answer,"n = int(input()) +if n%2 == 0: + #print(format(n/(2*n), '.10f')) + print(n/(2*n)) +else: + #print(format((n+1)/2*n, '.10f')) + print((n+1)/2*n)" +p02552,s853568975,Wrong Answer,"print(""O"" if input()==""1"" else ""1"")" +p03282,s973888896,Wrong Answer,"s = input() +n = int(input()) + +one_cnt = [] +ans = 0 +for i in range(len(s)): + if s[i] == ""1"": + one_cnt = i + else: + ans = s[i] + break + +print(ans if n - 1 != one_cnt else 1)" +p03719,s220579739,Wrong Answer,"a,b,c=input().split() +a=int(a) +b=int(b) +c=int(c) +if c>=a: + if c<=b: + print('Yes') + else: + print('No') +print('No')" +p02833,s045763847,Wrong Answer,"import math + +# n = 1000000000000000000 +n = int(input()) + +# nが奇数ならば必ず0 +if n % 2 or n < 10: + print(0) +else: + s = 0 + for p in range(0, 26): + s += math.floor(n / (10 * (5 ** p))) + + print(s) + +# 298023223876953125 +# 1490116119384765625 +# 1000000000000000000 + +# dividers = [(p, 5 ** p) for p in range(1, 26)] + + +" +p02836,s159990004,Accepted,"s = input() +cnt = 0 +l = int(len(s)/2) + +for i in range(l): + if s[i] != s[-(i+1)]: + cnt += 1 +print(cnt)" +p02843,s717424400,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + X = int(input()) + + if X < 100: + ans = 0 + else: + q, r, = divmod(X, 100) + if r <= 5 * q: + ans = 1 + else: + ans = 0 + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03252,s157505970,Wrong Answer,"s = input() +t = input() + +s_set = set(s) +t_set = set(t) + +if len(s_set) == len(t_set): + print('Yes') +else: + print('No')" +p03474,s307834870,Wrong Answer,"a, b = map(int, input().split()) +s = input() +if ""-"" not in s[:a] and s[a] == ""-"" and ""-"" not in s[b:]: + print (""Yes"") +else: + print (""No"")" +p02756,s224860721,Wrong Answer,"from collections import deque +s = input() +d = deque() +d.append(s) +n = int(input()) +count = 0 +for i in range(n): + j = list(input().split()) + if j[0] == '1': + count+=1 + else: + if (count + int(j[1])) % 2 == 1: + d.appendleft(j[2]) + else: + d.append(j[2]) +ans = """" +if count % 2 == 1: + while d: + ans += d.pop() +else: + while d: + ans += d.popleft() +print(ans)" +p02795,s476257463,Wrong Answer,"h = int(input()) +w = int(input()) +n = int(input()) +count = 0 +if(h >= w): + while(n > h): + h += h + count += 1 + print(count) +else: + while(n > w): + w += w + count += 1 + print(count) +" +p02820,s029338803,Wrong Answer,"#149_d:greedy +n,k = [int(i) for i in input().split()] +r,s,p =[int(i) for i in input().split()] +t = input() + +dic = dict() +dic[""r""]=p +dic[""s""]=r +dic[""p""]=s + +ans = [] +for i in range(k): + ans.append(dic[t[i]]) + +for i in range(n-k): + char = t[k+i] + ans.append(dic[char]) + if ans[-1]==ans[-1-k]: + ans[-1]=0 + +print(sum(ans))" +p03416,s835371176,Accepted,"def checkpalindrome(n): + s=str(n) + a=[] + for i in range(len(s)): + a.append(s[i]) + a.reverse() + if ''.join(a)==s: + return 1 + else: + return 0 +a,b=map(int,input().split()) +ans=0 +for i in range(a,b+1): + ans+=checkpalindrome(i) +print(ans)" +p03698,s328920601,Wrong Answer,"u = input() +for i in range(len(u)): + for j in range(len(u)-i): + if u[i]==u[j]: + print(""no"") + exit() +print(""yes"")" +p02583,s489377496,Wrong Answer,"N = int(input()) + +Ls = list(map(int, input().split())) +L = sorted(Ls, reverse=True) + + +cnt = 0 +for i in range(len(L)-2): + for j in range(i+1, len(L)-1, 1): + for k in range(j+1, len(L), 1): + if L[i] < L[j] + L[k] and L[j] != L[k]: + #print(L[i], L[j], L[k], i, j, k) + cnt += 1 +print(cnt) +" +p03127,s297820578,Accepted,"import fractions + +n = int(input()) +a = list(map(int, input().split())) + +ans = a[0] + +for i in range(1,n): + ans = fractions.gcd(ans,a[i]) + + +print(ans) +" +p02780,s213484188,Accepted,"N, K = map(int, input().split()) +p = list(map(int, input().split())) + +ans, ai = 0, -1 +sum = 0 +for i in range(N-K+1): + if i == 0: + for k in range(K): + sum += p[i+k] + else: + sum = sum - p[i-1] + p[i+k] + ans = max(ans, sum) + if ans == sum: + ai = i + +dp = [0]*1001 +dp[0] = 0 +for i in range(1000): + dp[i+1] = i+1 + dp[i] + +ans = 0.0 +for i in range(ai, ai+K): + ans += dp[p[i]]/p[i] + +print(ans)" +p03126,s534370038,Wrong Answer,"import collections +n, m = map(int, input().split()) +a_list = sum([list(map(int, input().split()))[1:] for _ in range(n)], []) +col = collections.Counter(a_list) +print(sum([k for k, v in col.items() if v == n]))" +p03774,s063878816,Wrong Answer,"N, M = map(int, input().split()) +ab = [map(int, input().split()) for _ in range(N)] +a, b = zip(*ab) +cd = [map(int, input().split()) for _ in range(M)] +c, d = zip(*cd) + +for i in range(N): + tmp_dist = 10 ** 8 * 2 + tmp_point = 0 + for j in range(M): + if tmp_dist > abs(a[i] - c[j]) + abs(b[i] - d[j]): + tmp_point = j + 1 + tmp_dist = min(tmp_dist, abs(a[i] - c[j]) + abs(b[i] - d[j])) + else: + print(tmp_point)" +p02879,s576365280,Accepted,"A, B = map(int,input().split()) + +if (A > 9) or (B > 9): + print(-1) +else : + print(A*B) + +" +p02778,s237790798,Accepted,"S = input() + +ans = 'x' * len(S) + +print(ans)" +p02723,s790747114,Accepted,"# -*- coding: utf-8 -*- +S= input() +S_list = list(S) +if S_list[2] == S_list[3]: + if S_list[4] == S_list[5]: + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p03377,s800765409,Wrong Answer,"A,B,X=map(int,input().split()) +if ((AX)): + print(""Yes"") +else: + print(""No"")" +p03456,s548707686,Accepted,"a,b=input().split() +print(""Yes"" if (int(a+b)**.5).is_integer() else ""No"")" +p02678,s412075501,Accepted,"N,M = map(int,input().split()) #n:頂点数 w:辺の数 + + +way = [[] for i in range(N)] +depth = [float(""inf"") for i in range(N)] +visited = [False for i in range(N)] +que=[0] + +for i in range(M): + x,y = map(int,input().split()) + way[x-1].append(y-1) + way[y-1].append(x-1) + +for i in que: + for j in way[i]: + if visited[j]: + continue + que.append(j) + visited[j]=True + depth[j] = min(i+1,depth[j]) +print(""Yes"") +for i in range(1,N): + print(depth[i])" +p02621,s266884472,Accepted,"a = int(input()) + +print(a+a*a+a*a*a)" +p02577,s009405157,Wrong Answer,"import math +N = int(input()) +if N == 0: + print('No') +else: + log10_N = int(math.log10(N)) + 1 + sum_keta = 0 + + for i in range(log10_N): + sum_keta += N % 10 + N = N // 10 + + if sum_keta % 9 == 0: + print('Yes') + else: + print('No') +" +p03013,s059796996,Accepted,"from sys import stdin +nii=lambda:map(int,stdin.readline().split()) +lnii=lambda:list(map(int,stdin.readline().split())) + +n,m=nii() + +mod=10**9+7 + +dp=[-1 for i in range(n+1)] +dp[0]=1 +dp[1]=1 +for i in range(m): + a=int(input()) + dp[a]=0 + +for i in range(2,n+1): + if dp[i]==0: + continue + num=dp[i-2]+dp[i-1] + num%=mod + dp[i]=num + +print(dp[-1])" +p02647,s599895323,Accepted,"n,k = map(int,input().split()) +a = list(map(int,input().split())) +imos = [0 for _ in range(n+1)] +"""""" +座標xに光の強さdの電球→[x-d, x+d] てらす +強さ0でもそれには適用. +"""""" +for _ in range(k): + imos = [0 for _ in range(n+1)] + for i in range(n): + imos[max(i-a[i], 0)] += 1 + imos[min(i+a[i]+1, n)] -= 1 + cnt = 0 + alln = 0 + for i in range(n): + cnt += imos[i] + a[i] = cnt + if a[i] == n: + alln += 1 + if alln == n: + break +print(*a)" +p02696,s544568963,Accepted,"A, B, N = map(int, input().split()) +ans = int(A*(min(N, B-1)/B))-A*int(min(N, B-1)/B) +print(ans) +" +p03804,s569028700,Wrong Answer,"N, M = map(int,input().split()) +A = [str(input()) for _ in range(N)] +B = [str(input()) for _ in range(M)] + +res = ""No"" + +for i in range(N-M+1): + for j in range(N-M+1): + if A[i][j:j+M] == B[0]: + for k in range(1,M): + if A[k][j:j+M] == B[k]: + pass + else: + break + res = ""Yes"" + +print(res)" +p03274,s076474554,Accepted,"N,K = map(int, input().split()) +*X, = map(int, input().split()) + +min = float('inf') +for i in range(N-K+1): + left_cost = X[i] + right_cost = X[i+K-1] + right_course = abs(right_cost)+abs(right_cost-left_cost) + if min > right_course: + min = right_course + left_course = abs(left_cost)+abs(right_cost-left_cost) + if min > left_course: + min = left_course + +print(min)" +p02621,s699492096,Accepted,"# import sys +# input = sys.stdin.readline + +def mp(): return map(int, input().split()) +def lmp(): return list(map(int, input().split())) + + +a = int(input()) +print(a+a*a+a*a*a) + +" +p03087,s782846409,Accepted,"N,Q = map(int,input().split()) + +S = input() + +T = S.replace(""AC"",""!?"") + +csum = [0]*N + +s = 0 + +for i in range(N): + if T[i] == ""?"": + s += 1 + csum[i] = s + +for i in range(Q): + l,r = map(int,input().split()) + print(csum[r-1]-csum[l-1])" +p02879,s342200881,Accepted,"a,b = map(int,input().split()) +if a < 10 and b < 10: + print(a*b) +else: + print(-1)" +p02789,s738248085,Wrong Answer,"NM=input(""N M"") +N,M=NM.split() +N=int(N) +M=int(M) +if(N==M): + print(""Yes"") +else: + print(""NO"")" +p02731,s986675367,Accepted,"from math import * +l=int(input()) +k=3*(log10(l)-log10(3)) +print(pow(10,k))" +p03073,s993840221,Wrong Answer,"a=input() +b=int(len(a)) +c=0 +d=0 +for i in range(b//2): + if a[2*i]==""1"": + c=c+1 + if a[2*i+1]==""0"": + c=c+1 +for i in range(b//2): + if a[2*i]==""0"": + d=d+1 + if a[2*i+1]==""1"": + d=d+1 +if c>d: + print(d) +else: + print(c)" +p03479,s745094945,Accepted,"# https://atcoder.jp/contests/abc083/tasks/arc088_a + +X, Y = map(int, input().split()) + +res = 1 +while X*2 <= Y: + X *= 2 + res += 1 + +print(res)" +p02848,s405706239,Wrong Answer,"N=int(input()) +S=list(input()) +cha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'*2) +for i in range(len(S)): + S[i]=cha[cha.index(S[i])+2] +print("""".join(S))" +p02639,s071408765,Accepted,"S = [int(x) for x in input().split()] +for i in range(5): + if S[i]==0: + print(i+1) + exit()" +p02802,s495412076,Accepted,"n, m = map(int, input().split()) +p = [0] * m +s = [0] * m +for i in range(m): + p[i], s[i] = input().split() + p[i] = int(p[i]) +c = [0] * (n + 1) +w = [0] * (n + 1) +for i in range(m): + if c[p[i]] == 0 and s[i] == 'AC': + c[p[i]] = 1 + elif c[p[i]] == 0 and s[i] == 'WA': + w[p[i]] = w[p[i]] + 1 + +for i in range(1, n+1): + if c[i] == 0: + w[i] = 0 +print(sum(c), sum(w))" +p02711,s254468521,Accepted,"n=list(map(int,input())) +if 7 in n: + print(""Yes"") +else: + print(""No"") +" +p03803,s094258163,Accepted,"a,b = map(int,input().split()) +if a == b : + print(""Draw"") +elif a == 1 : + print(""Alice"") +elif b == 1 : + print(""Bob"") +elif a > b : + print(""Alice"") +elif a < b : + print(""Bob"") " +p02682,s139222458,Accepted,"a, b, c, k = map(int, input().split()) + +if k < a: + print(k) +elif k <= a + b: + print(a) +else: + print(a - (k - a - b))" +p03644,s656555890,Wrong Answer,"a = int(input()) + +print(len(str(bin(int(a))))-3)" +p03943,s550965215,Wrong Answer,"abc = list(map(int, input().split())) +if abc[0]+abc[1] == abc[2]: + print('Yes') +else: + print('No')" +p03329,s443672161,Accepted,"n=int(input()) +dp=[0]*100010 + +for i in range(1,100010): + dp[i]=float('inf') + +for i in range(1,100010): + power6=1 + while power6<=i: + dp[i]=min(dp[i-power6]+1,dp[i]) + power6*=6 + power9=1 + while power9<=i: + dp[i]=min(dp[i-power9]+1,dp[i]) + power9*=9 + +print(dp[n])" +p02982,s500099588,Accepted,"import math + +N,D=map(int,input().split()) + +arr=[list(map(int,input().split())) for i in range(N)] +count=0 + +def dis(x,y): + a=0 + for i in range(len(x)): + a+=(x[i]-y[i])*(x[i]-y[i]) + return math.sqrt(a) + +for i in range(N-1): + for j in range(i+1,N): + if dis(arr[i],arr[j])%1==0: + count+=1 + +print(count) +" +p03206,s951704579,Wrong Answer,"a=int(input()) +print(""Christmas"",""Eve""*3)" +p02628,s357934225,Accepted,"from collections import Counter, defaultdict +# for use in beginner level contests where speed is key + +_,k = list(map(int,input().split())) +lst = list(map(int,input().split())) + +print(sum(sorted(lst)[:k]))" +p02659,s276003176,Wrong Answer,"lst = input().split() +a = int(lst[0]) +b = float(lst[1]) +if a == 0 or b == 0: + print(0) +else: + print(int(a*b))" +p02748,s853606405,Accepted,"a,b,m=map(int, input().split()) +ai=list(map(int, input().split())) +bi=list(map(int, input().split())) + +#xyc=[] +xymin=min(ai)+min(bi) + +for i in range(m): +# xyc.append(list(map(int, input().split())) + x,y,c=map(int, input().split()) + xy=ai[x-1]+bi[y-1]-c + if xymin>xy: + xymin=xy + +print(xymin) +" +p03103,s503858596,Wrong Answer,"n,m = map(int,input().split()) +a,b = [0 for _ in range(n)],[0 for _ in range(n)] + +for i in range(n): + a[i] = list(map(int,input().split())) + +bought = 0 +ans = 0 + +if len(a) == 1: + print(a[0][0]*m) + exit() + +a.sort(key = lambda a:a[0]) + +for i in range(n): + remain = m - bought + if a[i][0] < remain: + ans += a[i][0] * a[i][1] + bought += a[i][1] + else: + ans += a[i][0]*remain + break + +print(ans)" +p02801,s983703487,Accepted,"C = input() +print(chr(ord(C) + 1))" +p02814,s691414981,Accepted,"import numpy as np +from fractions import gcd +def lcm(a,b): + return a*b//gcd(a,b) +N,M=map(int,input().split()) +a=[i//2 for i in map(int,input().split())] +b=np.array(a) +cnt=0 +while all(b%2==0): + b//=2 +if any(b%2==0): + print(0) + exit() +ans=1 +for i in a: + ans=lcm(ans,i) +print((M//ans-1)//2+1)" +p02696,s318102778,Accepted,"A,B,N=map(int, input().split()) +def f(n): + return A*n//B-A*(n//B) +ans=f(N) +ans=max(ans,f(N//B*B)) +x=N//B*B-1 +if x>0: + ans=max(ans,f(x)) +print(ans) +" +p02554,s581640088,Accepted,"int_n = int(input()) + +ans = 10**int_n -2*(9**int_n) +8**int_n + +ans_divide = ans % (10**9 + 7) + +print(ans_divide)" +p02682,s431363139,Accepted,"# coding:utf-8 +a, b, c, k = map(int, input().split()) +point = 0 + +if k <= a: + point += k +elif k > a and (k - a) <= b: + point += a +elif k > a and (k - a) > b: + point = a + (-1) * (k - a - b) + +print(point) +" +p03352,s272062109,Wrong Answer,"X = int(input()) +Max = 0 +for i in range(2,10): + b = int(X**(1/i)) + B = b**i + if Max < B: + Max = B +print(Max)" +p03455,s098864961,Accepted,"a,b = map(int,input().split()) +print(""Even"" if a * b % 2 == 0 else ""Odd"") + " +p02765,s451363040,Wrong Answer,"# int +# A = list(map(int, input().split())) +# string +# S = input().split() + +N, R = map(int, input().split()) + +if N >= 10: + print(R) +else: + print(R - 100 * (10-N))" +p02658,s989192650,Wrong Answer,"N = int(input()) +str_num = input().split() + +num_list = [] +for i in str_num: + num_list.append(int(i)) + +num_list.sort(reverse=True) + +ans = num_list[0] + +LIMIT_NUM = 10**18 + +for i in range(1,N): + ans *= num_list[i] + if ans > LIMIT_NUM: + break + +if ans > LIMIT_NUM: + print(-1) +else: + print(ans) +" +p02699,s110489265,Accepted,"if __name__ == ""__main__"": + S, W = map(int, input().split()) + print(""unsafe"" if S <= W else ""safe"")" +p02641,s719355973,Accepted,"x, n = map(int, input().split()) + + +p = list(map(int, input().split())) + +a = 0 + + +while True: + if x - a not in p: + print(x - a) + break + elif x + a not in p: + print(x + a) + break + a += 1 +" +p02819,s549976158,Wrong Answer,"from collections import deque + +X = int(input()) +N = 10**5+4 +N_sq=N**(1/2) + +check = deque(range(2,N+1)) +search = deque([]) + +for n in range(N): + if len(check)<=0: + break + + c = check.popleft() + search.append(c) + + check = deque([ _ for _ in check if _%c != 0]) + + if c > N_sq: + search.extend(check) + break + +for s in search: + if X < s: + print(s)" +p02910,s483149205,Accepted,"from sys import stdin + +s = [x for x in stdin.readline().rstrip()] + +ans = ""Yes"" + +for i in range(len(s)): + if ((i + 1) % 2 == 0) and (s[i] == ""R""): + ans = ""No"" + break + elif ((i + 1) % 2 != 0) and (s[i] == ""L""): + ans = ""No"" + break +print(ans) +" +p03639,s495549090,Wrong Answer,"n=int(input()) +a=list(map(int, input().split())) +cnt_2=0 +cnt_1=0 +cnt_0=0 + +for num in a: + if num%4==0: + cnt_2+=1 + elif num%2==0: + cnt_1+=1 + else: + cnt_0+=1 + +if cnt_2>=cnt_0: + print(""Yes"") +else: + print(""No"")" +p03485,s862676773,Wrong Answer,"def calc(): + rem = (a + b)%2 + ans = 0 + + if rem == 0: + ans = (a+b)/2 + return ans + else: + ans = ((a+b)//2) + 1 + return ans + +a, b = map(int,input().split()) +print(calc()) +" +p02600,s786191942,Accepted,"x=int(input()) +ans=8 +x-=400 +ans-=x//200 +print(ans)" +p03557,s974177692,Accepted,"import bisect + +ans = 0 +N = int(input()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) +C=list(map(int,input().split())) + +A.sort() +B.sort() +C.sort() + + +#A= k*d or x <= -k*d: + print(str(abs(x - k * d ))) +else: + for i in range(k): + if abs(a + d) > abs(a - d): + a = a-d + else: + a = a+d + print(str(abs(a)))" +p02554,s557138414,Accepted,"print((pow(10,n:=int(input()),M:=10**9+7)-pow(9,n,M)*2+pow(8,n,M))%M)" +p03644,s466627169,Accepted,"n = int(input()) +for i in range(7): + if 2**i<=n<2**(i+1): + print(2**i) + break + elif n==1: + print(n) + break" +p03657,s363577544,Accepted,"a,b=map(int,input().split()) + +if a%3==0 or b%3==0 or (a+b)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p03137,s141599112,Accepted,"n,m = map(int, input().split()) +T = list(map(int, input().split())) + +if n >= m: + print(0) + exit() + +T.sort() +diff = [] +for i in range(1,m): + diff.append(T[i]-T[i-1]) +diff.sort(reverse=True) +print(sum(diff[n-1:])) +" +p02682,s323313852,Accepted,"A, B, C, K = map(int, input().split()) + +if K <= A: + print(K) +else: + ans = A + if K <= A + B: + print(ans) + else: + ans = ans - (K - A - B) + print(ans)" +p03127,s353004890,Accepted,"n = int(input()) +List = list(map(int, input().split())) + +def euclid(a, b): + while True: + r = a % b + a, b = b, r + if r == 0: + return(a) + +List.sort(reverse = True) +res = euclid(List[0], List[1]) +for i in range(1, n): + res = euclid(res, List[i]) + if res == 1: + break + +print(res)" +p03994,s489539112,Accepted,"s = input() +k = int(input()) +slen = len(s) +new_s = """" + +for i in range(slen): + val = (ord(""z"") + 1 - ord(s[i])) % 26 + if k >= val: + k -= val + new_s += ""a"" + else: + new_s += s[i] + +if k > 0: + tmp_val = ord(new_s[slen-1]) + k % 26 + if tmp_val > ord(""z""): + tmp_val -= 26 + new_s = new_s[:-1] + chr(tmp_val) + +print(new_s)" +p04012,s820274968,Wrong Answer,"w=input() +count1=0 +for i in range(0,len(w)): + a=w.count(w[i]) + if(a%2==0): + count1+=1 + elif(a%2 != 0): + count1-=1 + +if(count1>0): + print(""Yes"") +elif(count1<0): + print(""No"") +" +p03137,s504164400,Accepted,"n,m = map(int,input().split()) +x = list(map(int,input().split())) +x.sort() +x_sa = [] +for i in range(len(x)-1): + x_sa.append(abs(x[i]-x[i+1])) +x_sa.sort() +ans = 0 +if n >= m: + print(0) +else: + for i in range(m-n): + ans += x_sa[i] + print(ans)" +p02624,s337901251,Accepted,"def solve(string): + n = int(string) + return str(sum(i * (n // i) * (n // i + 1) // 2 for i in range(1, n + 1))) + + +if __name__ == '__main__': + import sys + print(solve(sys.stdin.read().strip())) +" +p03548,s958500813,Accepted,"x,y,z=map(int,(input().split())) +ans=1 +x-=(y+2*z) +print(ans+x//(y+z))" +p02912,s732095290,Wrong Answer,"n, m = map(int, input().split()) +a = list(map(int, input().split())) +a.sort() +for _ in range(m): + p = a.pop()//2 + up=n-1 + low=0 + while up-low > 1: + nb = low+(up-low)//2 + if p >= a[nb]: + low = nb + else: + up = nb + a.insert(up, p) +print(sum(a))" +p03479,s360596295,Accepted,"X, Y = [int(item) for item in input().split()] +cnt = 0 + +while X <= Y: + X *= 2 + cnt +=1 + +print(cnt)" +p02952,s015715607,Accepted,"n = int(input()) +ans = 0 +for i in range(0, 3): + for j in range(1*(100**i), 10*(100**i)): + if j<=n: + ans += 1 + else: + print(ans) + exit() +print(ans)" +p02554,s741396420,Accepted,"N = int(input()) + +print((10**N-2*9**N+8**N)%1000000007)" +p03617,s840366006,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) + +if H > Q*2: + H = Q*2 +if S > H*2: + S = H*2 +if D > S*2: + D = S*2 + +if N % 2 == 0: + print((N//2)*D) +else: + print((N//2)*D+S)" +p02948,s506984520,Accepted,"import sys +input = sys.stdin.readline +from collections import * +from heapq import * + +N, M = map(int, input().split()) +d = defaultdict(list) + +for _ in range(N): + A, B = map(int, input().split()) + d[M-A].append(B) + +pq = [] +ans = 0 + +for i in range(M-1, -1, -1): + for v in d[i]: + heappush(pq, -v) + + if len(pq)>0: + ans += -heappop(pq) + +print(ans)" +p03803,s817494567,Accepted,"a, b = map(int, input().split()) + +if a == 1: + a += 13 +if b == 1: + b += 13 + +if a < b: + ans = 'Bob' +elif a == b: + ans = 'Draw' +else: + ans = 'Alice' +print(ans) +" +p02772,s165903858,Accepted,"n = int(input()) +for a in list(map(int, input().split())): + if not a % 2 and a % 3 and a % 5: + print(""DENIED"") + break +else: print(""APPROVED"") +" +p02780,s855600125,Accepted,"import itertools + +def solve(): + N, M = map(int, input().split()) + A = list(map(int, input().split())) + # スコアの累積和 + l = list(itertools.accumulate(A)) + + score = sum(A[:M]) + for i in range(1, N-M): + score = max(score, l[i+M] - l[i]) + + ans = (M + score) / 2 + + return ans + +print(solve()) +" +p03695,s774999178,Accepted,"n = int(input()) +arr = list(map(int, input().split())) +r = 0 +cols = [0] * 8 +for i in arr: + color = i // 400 + if color <= 7: + cols[color] = 1 + else: + r += 1 +c = sum(cols) +print(max(1, c), r+c)" +p02833,s455313061,Wrong Answer,"import math +n = int(input()) +if n == 0: + print(0) +if n == 1: + print(0) +else: + if n % 2 ==1: + print(0) + else: + ans = 0 + l = 5 + while n>=l: + ans += n//(l*2) + l *= 5 + print(ans)" +p03861,s928533407,Accepted,"def main(): + import sys + input = sys.stdin.readline + sys.setrecursionlimit(10**7) + from collections import Counter, deque + #from collections import defaultdict + from itertools import combinations, permutations, accumulate, groupby + #from itertools import product + from bisect import bisect_left,bisect_right + from heapq import heapify, heappop, heappush + from math import floor, ceil + #from operator import itemgetter + + #inf = 10**17 + #mod = 10**9 + 7 + + a,b,x = map(int, input().split()) + + print(b//x - (a-1)//x) + +if __name__ == '__main__': + main()" +p03324,s794078932,Accepted,"d, n = map(int, input().split()) + +if n == 100: + ans = (100**d)*(n+1) +else: + ans = (100**d)*n +print(ans)" +p02687,s593313920,Accepted," +#イコールは==とすることVBA特別する + +s = input() + +if s == ""ABC"": + print(""ARC"") +else: + print(""ABC"")" +p03745,s835027602,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +ans = 1 +up = dn = False +for a,b in zip(A,A[1:]): + if a < b: + if up: continue + up = True + if dn: + ans += 1 + up = dn = False + elif a > b: + if dn: continue + dn = True + if up: + ans += 1 + up = dn = False +print(ans)" +p03327,s282092378,Accepted,"N = int(input()) + +if N >= 1999: # 不等号は=の手前に + print('The contest has not been held') + +elif N < 1000: + print('ABC') + +elif N >= 1000: + print('ABD') +" +p02897,s354246859,Accepted,"import math + +def main(): + n=int(input()) + print(math.ceil(n/2)/n) + +if __name__ == '__main__': + main()" +p02785,s521722098,Wrong Answer,"n,k,*h=map(int,open(0).read().split()) +print(sum(sorted(h)[:min(n,n-k)]))" +p03720,s417081647,Accepted,"N, M = map(int, input().split()) +counter = [0]*N +for _ in range(M): + a, b = map(int, input().split()) + counter[a-1] += 1 + counter[b-1] += 1 + +for c in counter: + print(c)" +p02767,s503632223,Wrong Answer,"def main(): + N = int(input()) + x_line = list(map(int, input().split(' '))) + max_x = max(x_line) + min_x = min(x_line) + result = 10000 + for i in range(min_x, max_x + 1): + hash_result = 0 + for x in x_line: + hash_result += (x - i) ** 2 + if hash_result < result: + result = hash_result + print(result) + + +if __name__ == '__main__': + main() +" +p02836,s012514138,Wrong Answer,"import numpy as np +S = list('abcdabc')#input()) +print(float(np.sum([1 for a, b in zip(S[:int(np.floor(len(S)/2))], list(reversed(S[int(np.ceil(len(S)/2)):]))) if not a == b])))" +p03137,s879235972,Accepted,"import sys +def input(): return sys.stdin.readline().rstrip() +def main(): + n,m=map(int,input().split()) + X=[int(_) for _ in input().split()] + if m<=n: + print(0) + else: + X.sort() + XX=[0]*(m-1) + for i in range(m-1): + XX[i]=X[i+1]-X[i] + XX.sort(reverse=True) + print(X[-1]-X[0]-sum(XX[:n-1])) + +if __name__=='__main__': + main()" +p02555,s933405387,Accepted,"s = int(input()) +a = [0]*(s+5) +a[0] = 1 +mod = 10**9 + 7 +for i in range(3 , s+1): + if i < 3 : + continue + + a[i] = (a[i-1] + a[i-3]) % mod + +print(a[s])" +p03043,s929001214,Accepted,"n, k = map(int, input().split()) +ans = 0 +for i in range(1, n+1): + x = 1/n + while i N を満たす最小のxは? +# x_min = ceil(N/(2D+1)) + +print(math.ceil(N/(2*D+1)))" +p03632,s431936965,Accepted,"def answer(a: int, b: int, c: int, d: int) -> int: + return len(set(range(a, b)) & set(range(c, d))) + + +def main(): + a, b, c, d = map(int, input().split()) + print(answer(a, b, c, d)) + + +if __name__ == '__main__': + main()" +p02957,s141989277,Accepted,"a,b=map(int,input().split()) + +if (a+b)%2==0: + print(int((a+b)/2)) +else: + print(""IMPOSSIBLE"")" +p03329,s267441054,Accepted,"N = int(input()) +dp = [1000000] * (N + 1) +dp[0] = 0 +for i in range(1, N + 1): + dp[i] = dp[i - 1] + 1 + x = 6 + while i - x >= 0: + dp[i] = min(dp[i], dp[i - x] + 1) + x *= 6 + x = 9 + while i - x >= 0: + dp[i] = min(dp[i], dp[i - x] + 1) + x *= 9 + +print(dp[N]) +" +p02946,s634482199,Accepted,"k, x = map(int, input().split()) +num = [x] + +for i in range(1, k): + num.append(x + i) + num.append(x * 2 - (x + i)) + +print(' '.join(map(str, sorted(num)))) +" +p02817,s488402380,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + S, T = readline().strip().split() + print(T + S) + + return + + +if __name__ == '__main__': + main() +" +p02748,s335168620,Accepted,"import sys +readline = sys.stdin.readline +a, b, m = map(int, readline().split()) +a = list(map(int, readline().split())) +b = list(map(int, readline().split())) +xyc = [list(map(int, readline().split())) for _ in range(m)] + +ans = min(a) + min(b) +for x, y, c in xyc: + price = a[x-1] + b[y-1] - c + if price < ans: + ans = price +print(ans) +" +p03035,s493768258,Accepted,"A, B = map(int, input().split()) +if A <= 12: + B //= 2 +if A < 6: + B = 0 +print(B) +" +p03854,s060675398,Accepted,"def resolve(): + w = ['dream', 'dreamer', 'erase', 'eraser'] + for i in range(len(w)): + w[i] = w[i][::-1] + s = input()[::-1] + t = '' + for i in s: + t += i + if t in w: + t = '' + if len(t): + print(""NO"") + else: + print(""YES"") +resolve()" +p03644,s002381845,Accepted,"N = int(input()) +n=0 +ans = 0 +ans2 =0 +for i in range(1,N+1): + n=i + res = 0 + while n % 2 ==0: + n=n//2 + res = res + 1 + if ans < res: + ans = res + ans2 =i +if ans2==0: + print(1) +else: + print(ans2)" +p03379,s991955067,Accepted,"N = int(input()) +X_list = list(map(int, input().split())) +tmp = X_list.copy() + +tmp.sort() +a = tmp[int(N/2)-1] +b = tmp[int(N/2)] +for i in range(N): + if(X_list[i] <= a): + print(b) + else: + print(a)" +p02785,s296272546,Wrong Answer,"N, K = map(int, input().split()) +H = list(map(int, input().split())) +H.sort() +print(sum(H[:N-K]))" +p03720,s722506551,Wrong Answer,"n, m = map(int, input().split()) + +a = [] + +for i in range(m): + a1, a2 = map(int, input().split()) + a.append(a1) + a.append(a2) + +for s in range(n): + print(a.count(s))" +p02854,s074872723,Accepted,"import numpy as np +N = int(input()) +A = np.array(list(map(int, input().split()))) + +A_cs = A.cumsum() +A_cs = A_cs - A_cs[-1]/2 +div = np.abs(A_cs).argmin() + +print(abs(A[:div+1].sum() - A[div+1:].sum()))" +p03254,s317738064,Accepted,"# A - Candy Distribution Again +N,x = map(int,input().split()) +A = list(map(int,input().split())) +A.sort() +ans = 0 +for a in A: + x -= a + if x<0 or (ans==N-1 and x!=0): + break + ans += 1 +print(ans)" +p02814,s662967633,Accepted,"import fractions + + +def main(): + n, m = map(int, input().split()) + a = list(map(int, input().split())) + mul = a[0] + for i in range(1, n): + mul = mul * a[i] // fractions.gcd(mul, a[i]) + for i in a: + if mul // i % 2 == 0: + print(0) + exit() + if m >= mul // 2: + ans = (m - mul // 2) // mul + 1 + print(int(ans)) + else: + print(0) + + +if __name__ == '__main__': + main() +" +p04012,s365989229,Accepted,"#print#!/usr/bin/env python3 +#%% for atcoder uniittest use +import sys +input= lambda: sys.stdin.readline().rstrip() +sys.setrecursionlimit(10**9) +def pin(type=int):return map(type,input().split()) +def tupin(t=int):return tuple(pin(t)) +def lispin(t=int):return list(pin(t)) +#%%code +from collections import Counter +def resolve(): + w=input() + a=Counter(w) + for j in a.values(): + if j%2:print(""No"");return + print(""Yes"") +#%%submit! +resolve() +" +p03417,s135518404,Accepted,"N,M = map(int,input().split()) +print(abs((N-2)*(M-2)))" +p03971,s130720584,Accepted,"N, A, B = map(int, input().split()) +S = input() + +import sys + +T = A + B +Ta = B + +for p in S: + if p == ""c"": + print(""No"") + continue + + elif p == ""a"": + if T > 0: + print(""Yes"") + T -= 1 + else: + print(""No"") + + else: + if T > 0 and Ta > 0: + print(""Yes"") + Ta -= 1 + T -= 1 + else: + print(""No"") +" +p02571,s304755786,Wrong Answer,"S,T = input(),input() +num = len(T) +ans = num +for i in range(num): + for j in range(i+1,num+1): + str = T[i:j] + if str in S[i:-(num-j)]: + ans = min(ans,num - len((T[i:j]))) + # print(i,j,ans,T[i:j]) + +print(ans) +" +p03062,s538005138,Accepted,"n,*a=map(int,open(0).read().split()) +b=sum(i<0 for i in a)%2 +a=list(map(abs,a)) +print(sum(a)-min(a)*2*b)" +p03146,s778988424,Accepted,"#ABC116 + +s = int(input()) + +l = [s] +for i in range(1000000): + if l[-1] % 2 == 0: + if l[-1] // 2 in l: + print(len(l) + 1) + break + l.append(l[-1] // 2) + else: + if 3 * l[-1] + 1 in l: + print(len(l)+1) + break + l.append(3 * l[-1] + 1) + " +p02755,s116005343,Accepted,"import sys +import math +A,B=map(int,input().split()) +for i in range(1,10001): + if int(i*0.08)==A: + if int(i*0.1)==B: + print(i) + sys.exit() +print(-1)" +p03419,s183997622,Wrong Answer,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + n,m=map(int, input().split()) + if n==1: + ans=max(0,m-2) + elif m==1: + ans=max(0,n-2) + else: + ans=(n-2)*(m-2) + print(ans) +resolve()" +p03860,s441187813,Accepted,"l=input().split() +print(list(l[0])[0]+list(l[1])[0]+list(l[2])[0]) +" +p02571,s307255777,Accepted,"s = list(input()) +t = list(input()) + +min = len(t) + +for i in range(len(s) - len(t) + 1): + + diff = 0 + + for j in range(len(t)): + if t[j] != s[i + j]: + diff += 1 + + if diff < min: + min = diff + + +print(min)" +p02743,s403075793,Accepted,"#!/usr/bin/env python3 +import math +a,b,c = map(int,input().split()) +# a + b + 2r(ab) < c +# a + b - c < -2r(ab) +# c - a - b > 2r(ab) +# (c - a - b)**2 > 4ab +if c - a - b > 0 and (c - a - b)**2 > 4*a*b: + print(""Yes"") + exit() +print(""No"") +" +p03435,s467391229,Accepted,"s=[] +yoko=[] +ans=""Yes"" +for i in range(3): + a, b, c=map(int, input().split()) + s.append([a,b,c]) + yoko.append([a-b, b-c, c-a]) +if yoko[0]!=yoko[1] or yoko[1]!=yoko[2]: + ans=""No"" +tate=[] +for i in range(3): + tate.append([s[i][0]-s[i][1], s[i][1]-s[i][2], s[i][2]-s[i][0]]) +if tate[0]!=tate[1] or tate[1]!=tate[2]: + ans=""No"" +print(ans) + " +p03836,s042775124,Accepted,"# Python3 (3.4.3) +import sys +input = sys.stdin.readline + +# ------------------------------------------------------------- +# function +# ------------------------------------------------------------- + + +# ------------------------------------------------------------- +# main +# ------------------------------------------------------------- +Sx,Sy,Tx,Ty = map(int,input().split()) + +dx = Tx - Sx +dy = Ty - Sy + +ans1 = ""U""*dy + ""R""*dx +ans2 = ""D""*dy + ""L""*dx +ans3 = ""L"" + ""U""*(dy+1) + ""R""*(dx+1) + ""D"" +ans4 = ""R"" + ""D""*(dy+1) + ""L""*(dx+1) + ""U"" + +print(ans1 + ans2 + ans3 + ans4)" +p02571,s136451202,Wrong Answer,"# from math import + +s = input() +t = input() + +def distance(s, t): + assert(len(s) == len(t)) + return len(s) - sum([c1 == c2 for c1, c2 in zip(s, t)]) + + +min_d = len(s) + +for i in range(len(s) - len(t)): + min_d = min(min_d, distance(s[i:i+len(t)], t)) + +print(min_d) +" +p02835,s033555531,Accepted,"#入力値の格納 +a1,a2,a3 = map(int, input().split()) + +#判別 +if a1 + a2 + a3 <= 21: + text = ""win"" +else: + text = ""bust"" + +#表示 +print(text) +" +p04005,s604643093,Accepted,"cube = list(map(int, input().split())) +cube.sort() +if any([i % 2 == 0 for i in cube]): + print(0) +else: + print(cube[0] * cube[1])" +p03059,s706289613,Accepted,"A, B, T = map(int, input().split()) + +cnt = 0 +while T >= A: + cnt += B + T -= A +print(cnt)" +p02817,s340896084,Wrong Answer,"s, t = map(str, input().split()) +print(s+t)" +p02753,s560517587,Wrong Answer,"temp = set(input()) + +judgment1 = 'A' in temp +judgment2 = 'B' in temp + +if judgment1 == True: + if judgment2 == True: + print(""Yes"") +else: + print('No')" +p02645,s251181803,Accepted,"S = input() + +print(S[:3]) + +" +p03286,s693534505,Accepted,"n=int(input()) +ans="""" +while n!=0: + if (n%2)!=0: + n-=1 + ans=""1""+ans + else: + ans=""0""+ans + n/=-2 +if ans=="""": + ans=""0"" +print(ans)" +p03607,s448895260,Accepted,"from collections import Counter +n = int(input()) +a = Counter([int(input()) for i in range(n)]) +print(sum([v%2 == 1 for v in a.values()]))" +p02833,s362907769,Accepted,"N = int(input()) +if N % 2 == 1: + print(0) +else: + ans = 0 + for i in range(1, 26): + ans += N // (5 ** i) // 2 + print(ans)" +p03239,s841280484,Accepted,"n,t=map(int,input().split()) + +c=[] +for i in range(n): + c_=list(map(int,input().split())) + c.append(c_) + +c.sort() + +for i in range(n): + if c[i][1]<=t: + print(c[i][0]) + exit() + + else: + continue + +print('TLE')" +p02996,s116849315,Accepted,"import sys + +n = int(input()) +work = [list(map(int, input().split())) for i in range(n)] +work = sorted(work, key=lambda x:x[1]) + +sum = 0 + +for i in range(n): + sum += work[i][0] + if sum > work[i][1]: + print('No') + sys.exit() + +print('Yes')" +p03449,s656018915,Accepted,"n = int(input()) +a = [] +for i in range(2): + aa = list(map(int, input().split())) + a.append(aa) + +ans = 0 +for i in range(n): + ans = max(ans, sum(a[0][:i+1])+sum(a[1][i:n])) + +print(ans)" +p03998,s766728774,Wrong Answer,"from collections import defaultdict + +data = defaultdict() +for i in range(3): + s = input() + data[chr(ord(""a"") + i)] = s + +cnt = [0] * 3 +cnt[0] = 1 +turn = ""a"" +while 1: + if cnt[ord(turn) - ord(""a"")] == len(data[chr(ord(turn))]): + ans = ord(turn) - (ord(""a"") - ord(""A"")) + break + + turn = data[chr(ord(turn))][cnt[ord(turn) - ord(""a"")]] + cnt[ord(turn) - ord(""a"")] += 1 +print(chr(ans))" +p02627,s107757105,Wrong Answer,"M = input() +print(""A"" if M.islower else ""a"")" +p02995,s559065799,Accepted,"A, B, C, D = list(map(int, input().split())) +c1 = (A - 1) // C +c2 = B // C +d1 = (A - 1) // D +d2 = B //D +import math +E = (C * D) // math.gcd(C, D) +e1 = (A - 1) // E +e2 = B //E + +print(B - A + 1 -(c2 - c1 + d2 - d1 - (e2 - e1))) +" +p03639,s549726045,Wrong Answer,"N = int(input()) +a = [int(x) for x in input().split()] +is_2 = len(list(filter(lambda x : x == 2, a))) +multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, a))) +not_4 = N - multiple_of_4 + +if is_2 + multiple_of_4 == N: + print('Yes') +else: + print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')" +p03852,s079923788,Wrong Answer,"c = input() + +if c == ""a"" or c == ""e"" or c == ""i"" or c == ""o"" or c == ""o"": + print(""vowel"") +else: + print(""consonant"") +" +p03146,s263318500,Accepted,"def f(n): + if n%2 == 0: + return n//2 + return 3*n+1 + +s = int(input()) +ans = 1 +used = set() +while True: + if s in used: + break + + used.add(s) + ans += 1 + s = f(s) +print(ans) +" +p03815,s825357597,Accepted,"x = int(input()) +if x % 11 == 0: + print((x//11) * 2) +elif x % 11 <= 6: + print((x//11) * 2 + 1) +else: + print((x//11) * 2+2)" +p03434,s554175440,Accepted,"n = int(input()) +card_list = list(map(int,input().split("" ""))) + +card_list_ex = sorted(card_list, reverse=True) + + +alice,bob = 0,0 +for i,j in enumerate(card_list_ex): + if i % 2 == 0: + alice += j + else: + bob += j +res = alice - bob +print(res)" +p02933,s000901323,Wrong Answer,"a=int(input()) +b=int() +if a>=3200: + print(""red"") +else: + print(b)" +p03720,s997810814,Accepted,"n,m=map(int,input().split()) +ans=[0]*n +for i in range(m): + a,b=map(int,input().split()) + ans[a-1]+=1 + ans[b-1]+=1 +for i in range(n): + print(ans[i])" +p04012,s605657271,Accepted,"a = input() +dic = {} +for i in a: + if i in dic: + dic[i] += 1 + else: + dic[i] = 1 +for i in dic: + if dic[i] % 2 != 0: + print(""No"") + exit() +print(""Yes"")" +p02784,s696174462,Accepted,"h, n = map(int, input().split()) +a = list(map(int, input().split())) + +sm = 0 + +for tmp in a: + sm+=tmp + +if sm >=h: + print(""Yes"") +else: + print(""No"")" +p03471,s495042968,Wrong Answer,"n,y=map(int,input().split()) +ans=[] +flag=False +for i in range(0,n): + for j in range(0,n): + if (9000*i+4000*j)==(y-1000*n) and n>=(i+j): + ans=[i,j,n-i-j] + flag=True + break +if flag: + print(*ans) +else: + print(-1,-1,-1)" +p03309,s104064590,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = sorted([A[i]-(i+1) for i in range(N)]) +b = B[N//2] +print(sum([abs(B[i]-b) for i in range(N)]))" +p02694,s196777571,Wrong Answer,"X = int(input()) + +yen = 100 +ret = 0 +while yen= 2: + return (k)*(k-1)/2 + else: + return 0 +def selfset(k): + if k >= 2: + return (k-1)*(k-2)/2 + else: + return 0 + +setnum={i:set(num[i]) for i in range(N)} +a=sum(setnum.values()) +print(setnum,A) + +selfsetnum={i:selfset(num[i]) for i in range(N)} + + +for i in range(N): + print(int(a-setnum[A[i]-1]+selfsetnum[A[i]-1]))" +p02624,s722571612,Accepted,"N=int(input()) +ans = 0 + +for i in range(1, N+1): + num = N // i + if num == 1: + ans += i + else: + ans += num * (i + num * i) / 2 + +print(int(ans))" +p03457,s024779255,Wrong Answer,"n = int(input()) +l = [list(map(int, input().split())) for _ in range(n)] + +x = y = t = 0 +for i in range(n): + dx, dy, dt = l[i][1], l[i][2], l[i][0] + dist = abs((dx - x) + (dy - y)) + + if abs(dt - t) < dist or dt - dist % 2: + print(""No"") + exit() + + x, y, t = dx, dy, dt +print(""Yes"")" +p02601,s152063866,Accepted,"a, b, c = map(int, input().split()) +aa, bb, cc = a, b, c +p = 0 +q = 1 +k = int(input()) + +for i in range(1,k + 2): + a, b, c = aa, bb, cc + b = b * (2 ** (k - i + 1)) + c = c * (2 ** (i - 1)) + if c <= 0: + c = cc + if b <= 0: + b = bb + if a < b and b < c: + p += 1 + +if p != 0: + print(""Yes"") +else: + print(""No"")" +p02873,s701483453,Accepted,"s = list(input()) +data = [0] * (len(s) + 1) +for i in range(len(s)): + if s[i] == ""<"": + data[i + 1] = data[i] + 1 + +for i in range(len(s) - 1, -1, -1): + if s[i] == "">"": + data[i] = max(data[i], data[i + 1] + 1) +print(sum(data))" +p03289,s896600820,Accepted,"s = input() +is_a = False +cnt_c = s[2:-1].count(""C"") +cnt_l = 0 +if s[0] == ""A"": + is_a = True +else: + pass +for letter in s: + if letter.isupper(): + cnt_l += 1 + else: + continue +if is_a == True and cnt_c == 1 and cnt_l == 2: + print(""AC"") +else: + print(""WA"")" +p02819,s746807254,Accepted,"x = int(input()) +while any(x % i < 1 for i in range(2, x)): + x += 1 +print(x)" +p02723,s703178401,Accepted,"str1 = str(input()) +if str1[2] == str1[3] and str1[4] == str1[5]: + print('Yes') +else: + print('No')" +p02789,s523356923,Wrong Answer,"x,y=map(int,input().split()) +if x==y: + print('YES') +else: + print(""NO"") " +p03486,s721037409,Wrong Answer,"s = list(str(input())) +t = list(str(input())) +s.sort() +t.reverse() +S = str() +T = str() +for i in s: + S += i +for k in t: + T += k +print('Yes' if S= 0: + print(a) +else: + print(-1) + +" +p02785,s262181111,Accepted,"n, k = map(int, input().split()) +h = list(map(int,input().split())) +ans = 0 + +h = sorted(h,reverse=True) + +for i in range(k,n): + ans += h[i] + +print(ans)" +p03910,s735517533,Wrong Answer,"N = int(input()) +def su(n): + s = 0 + for i in range(1,n+1): + s += i + return s + +if N == 1: + print(1) + +else: + for i in range(N): + if N - su(i) <= i: + j = i-1 + k = N-su(i-1) + break + + for i in range(1,j+1): + print(i) + print(k)" +p04044,s389394957,Wrong Answer,"import sys + + +def getN(): + return int(input()) + + +def getNM(): + return map(int, input().split()) + + +def getList(): + return list(map(int, input().split())) + + +def input(): + return sys.stdin.readline().rstrip() + + +############# +# Main Code # +############# + +n, m = getNM() +ords = [] +for _ in range(m): + s = input() + ords.append([[ord(x) for x in s]]) + ords[-1].append(s) + +ords.sort(key=lambda x: x[0]) + +for _, s in ords: + print(s, end='') +" +p02780,s667289516,Accepted,"n, k = map(int, input().split()) +P = list(map(int, input().split())) + + +E = [0] * 1001 + +total = 0 +for i in range(1, 1001): + total += i + e = total / i + E[i] = e + +P_to_E = [E[p] for p in P] + + +candidate = sum(P_to_E[:k]) +candidates = [candidate] + +for i in range(n-k): + drop = P_to_E[i] + add = P_to_E[i+k] + candidate += add - drop + candidates.append(candidate) + +print(max(candidates))" +p02694,s514019290,Accepted,"def solve(string): + i, c = 0, 100 + while c < int(string): + i += 1 + c = c * 1.01 // 1 + return str(i) + + +if __name__ == '__main__': + import sys + print(solve(sys.stdin.read().strip())) +" +p03043,s435251741,Wrong Answer,"n,K = map(int,input().split()) +p = min(n,K-1) +ans = 0 +chk = [1]*(K-1) +k = K +for i in range(14): + k /= 2 + if k == int(k): + q = int(k*2-k-1) + else: + q = int(k*2-k) + for i in range(q): + chk[i] += 1 + if k <= 1: + break + +#print(chk) +for i in range(p): + ans += float(1/(2**chk[i]*n)) + #print(ans) +ans += max(0,(n-K+1)/n) +print(ans)" +p03377,s789566624,Wrong Answer,"a,b,x=map(int,input().split()) +print(""YES"" if a+b>=x else ""NO"")" +p02759,s976504042,Wrong Answer,"n = int(input()) // 2 +print(n)" +p03760,s347496148,Accepted,"o = list(input()) +e = list(input()) +oe = [] +for i in range(len(e)): + oe.append(o[i]) + oe.append(e[i]) +if len(o) != len(e): + oe.append(o[len(o)-1]) +ans = ''.join(oe) +print(ans) +" +p03146,s239862444,Wrong Answer,"lis=[int(input())] +for i in range(1000): + if lis[i]%2==0: + a=lis[i]//2 + lis.append(a) + if a==lis[0]: + break + else: + a=lis[i]*3+1 + lis.append(a) + if a==lis[0]: + break + def has_duplicates(x): + return len(x) != len(set(x)) + if has_duplicates(lis)==True: + break +print(len(lis))" +p02723,s332596044,Accepted,"from sys import stdin + +def main(): + + a = stdin.readline().rstrip() + + if a[2] == a[3] and a[4] == a[5]: + print(""Yes"") + else: + print(""No"") + + + +if __name__ == ""__main__"": + main()" +p02629,s275290046,Wrong Answer,"N = (int)(input()) + +count = 1 +loop = 26 +lo = 26 + +N -= 1 + +while 1: + if lo > N: + break + count += 1 + lo = loop + loop *= 26 + lo += loop + +ss = """" + +for i in range(count): + loop //= 26 + print(""N:"" + (str)(N) ) + print(""loop : "" + (str)(loop)) + tmp = N // loop + N %= loop + tmp += 96 + ss += chr((int)(tmp)) + +ss =ss[0:-1] + chr((int)(tmp)+1) + +print(ss) +" +p02663,s108712965,Wrong Answer,"a,b,c,d,e=(int(x)for x in input().split()) +x=(c-a)*60 +z1=b-d +z2=abs(z1) +if z2>=30: + y=x-e+30 +if z2<30: + y=x-e + +if y0: + l.append(k) + k=0 + while s[i]=='>' if i0: + l.append(k) +sm=0 +for i in l: + sm+=(i*(i+1))//2 +for i in range(0 if s[0]=='<' else 1,len(l)-1,2): + sm-=min(l[i],l[i+1]) + + +print(sm)" +p02695,s500258050,Accepted,"def n0():return int(input()) +def n1():return [int(x) for x in input().split()] +def n2(n):return [int(input()) for _ in range(n)] +def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] + +import itertools +n,m,q=n1() +s=n3(q) + +Alist=list(itertools.combinations_with_replacement(range(1,m+1), n)) +ans=0 +for A in Alist: + tmp=0 + for r in s: + if A[r[1]-1]-A[r[0]-1]==r[2]: + tmp+=r[3] + ans=max(ans,tmp) +print(ans)" +p03281,s898459167,Wrong Answer,"N = int(input()) +if(N >= 195): + print(3) +elif(N >= 165): + print(2) +elif N>=105: + print(1) +else: + print(0) +" +p02759,s268406615,Wrong Answer,"#A +n = int(input()) +print(n // 2 + 1)" +p03471,s852843599,Accepted,"import sys +N,Y = map(int,input().split()) +for x in range(min(N,Y//10000)+1): + for y in range(min(N-x,(Y-10000*x)//5000)+1): + z = N-x-y + if 10000*x+5000*y+1000*z == Y: + print(x,y,z) + sys.exit() +print(-1,-1,-1)" +p02773,s195798476,Accepted,"import sys +readline = sys.stdin.readline +from collections import Counter +N = int(readline()) +C = Counter() + +for _ in range(N): + S = readline().strip() + C[S] += 1 + +ma = max(C.values()) +K = [k for k, v in C.items() if v == ma] +K.sort() +print('\n'.join(K)) +" +p04019,s902814570,Accepted,"s = input() +N = s.count(""N"") +W = s.count(""W"") +S = s.count(""S"") +E = s.count(""E"") +flag = -1 +if (S > 0 and N > 0) or (S == 0 and N == 0) : + if (E > 0 and W > 0) or (E == 0 and W == 0) : + flag = 1 +if flag == 1 : + print(""Yes"") +else : + print(""No"") +" +p04029,s037808162,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + N = int(input()) + ans = N * (N+1) // 2 + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02775,s463837079,Accepted,"# https://atcoder.jp/contests/abc155/submissions/10175015 + +def main(): + n = list(map(int, input()[::-1])) + [0] + s = 0 + res = 0 + for i, ni in enumerate(n[:-1]): + k = ni + s + if k < 5 or (k == 5 and int(n[i + 1]) < 5): + res += k + s = 0 + else: + res += 10 - k + s = 1 + res += s + print(res) + + +if __name__ == '__main__': + main()" +p02994,s736073982,Wrong Answer,"def main(): + n,l = list(map(int,input().split())) + ans=0 + if l>0: + for i in range(2,n+1): + print(l+i-1) + ans+= l+i-1 + else: + for i in range(1,n+1): + ans+=l+i-1 + print(ans) +main()" +p02707,s503072666,Wrong Answer,"'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ''' +#codeforces +from collections import Counter +gi = lambda : list(map(int,input().split())) +n, = gi() +occ = Counter(gi()) +for k in range(1, n + 1): + if k not in occ: + occ[k] = 0 +for k in occ: + print(occ[k])" +p03286,s498861404,Accepted,"n = int(input()) +gu = [1] +ki = [0] +for i in range(0, 20): + gu.append(gu[-1] + (-2)**(2 + 2*i)) + ki.append(ki[-1] + (-2)**(1 + 2*i)) +ans = [] +for i in range(20): + if gu[-2-i] < n <= gu[-1-i]: + ans.append('1') + n-= (gu[-1-i]-gu[-2-i]) + else: + ans.append('0') + if ki[-1-i] <= n < ki[-2-i]: + ans.append('1') + n -= (ki[-1-i]-ki[-2-i]) + else: + ans.append('0') +ans.append(str(n)) +print(str(int(''.join(ans))))" +p03680,s020294389,Wrong Answer,"N = int(input()) +a = [int(input()) for i in range(N)] +print(a) +M = [] +cn = 1 +for i in range(N): + if i == 0: + Z = a[0] + else: + Z = a[Z-1] + cn = cn + 1 + M.append(Z) + if Z == 2: + print(cn) + exit() + +print(-1) " +p02972,s187283785,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = [0] * n +for i in range(n-1, -1, -1): + cnt = 0 + for j in range(i, n, i+1): + cnt += ans[j] + if cnt % 2 != a[i]: + ans[i] = 1 + +print(sum(ans)) +print(' '.join(str(i+1) for i in range(n) if ans[i])) +" +p02778,s862133381,Wrong Answer," +s = input() + +print([""x""] * len(s)) +" +p02897,s734195623,Wrong Answer,"n=int(input()) +if n!=1: + print(float((n/2+1)/n)) +else: + print(float(n)) + " +p03206,s144194276,Wrong Answer,"x = int(input()) +print(""christmas""+"" Eve""*(25-x))" +p03077,s696995354,Accepted,"N = int(input()) +L = [int(input()) for _ in range(5)] +L.sort() +if N%L[0]: + ans = N//L[0] + 1 + 4 +else: + ans = N//L[0] + 4 +print(ans)" +p02766,s463786531,Accepted,"import sys +import math +import itertools +from collections import deque +import copy +import bisect + +MOD = 10 ** 9 + 7 +INF = 10 ** 18 + 7 +input = lambda: sys.stdin.readline().strip() + +N, K = map(int, input().split()) +print(int(((math.log(N, K)) // 1) + 1)) +" +p03284,s063773236,Accepted,"#!/usr/bin/env python3 + +N, K = map(int, input().split()) + +if N % K == 0: + print(0) +else: + print(1)" +p02705,s592726080,Accepted,"n = int(input()) +print(2*n*(3.141592)) +" +p02754,s320268803,Accepted,"import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline +from math import floor, ceil, sqrt, factorial, log +from collections import Counter, defaultdict +from operator import itemgetter +INF = float('inf'); MOD = 10**9+7 +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(MI()) +def LIR(n): return [LI() for i in range(n)] +def S(): return input().rstrip() + +def main(): + N, A, B = MI() + ans = N//(A+B)*A + rem = N%(A+B) + print(ans+min(rem, A)) +if __name__ == '__main__': + main()" +p03696,s656535780,Wrong Answer,"N = int(input()) +S = input() +nl = 0 +nr = 0 +for i in S: + if i == ')': + if nr > 0: + nr -= 1 + else: + nl += 1 + else: + nr += 1 +print(nr) +print(nl) +print('('*nl + S + ')'*nr) +" +p02916,s012458120,Wrong Answer,"N = int(input()) +A = [int(s) for s in input().split(' ')] +B = [int(s2) for s2 in input().split(' ')] +C = [int(s3) for s3 in input().split(' ')] + +#satisfaction start value +satis = 0 + +#find two countinuously incremental numbers +for j in A[:]: + for k in A[1:]: + if j+1 == k: + satis += C[j-1] + +for i in A: + satis += B[i-1] + +print(satis) +" +p03471,s439363909,Accepted,"N,Y = map(int, input().split()) +for i in range(N+1): + for j in range(N-i+1): + if 10000*i + 5000*j + 1000*(N-(i+j)) == Y: + print(i,j,(N-(i+j))) + exit() +print(-1,-1,-1)" +p03038,s904193726,Accepted,"def main(): + import sys + input = sys.stdin.readline + N, M = map(int, input().split()) + A = sorted(list(map(int, input().split()))) + BC = sorted([tuple(map(int, input().split())) for _ in range(M)], key=lambda x: x[1], reverse=True) + ind = 0 + for b, c in BC: + for i in range(b): + if ind == N or A[ind] >= c: + break + A[ind] = c + ind += 1 + print(sum(A)) + + +if __name__ == '__main__': + main()" +p02727,s469290534,Accepted,"x, y, a, b, c = map(int, input().split()) +pa = sorted(list(map(int, input().split())), reverse=True) # 赤 +qb = sorted(list(map(int, input().split())), reverse=True) # 緑 +rc = list(map(int, input().split())) # 透明 + +ans = [] +ans += pa[:x] +ans += qb[:y] +ans += rc + +print(sum(sorted(ans, reverse=True)[:x+y])) +" +p03723,s885846789,Wrong Answer,"A,B,C = map(int, input().split()) +cnt = 0 +if A == B and B == C: + print(-1) + exit() +while True: + if A%2 or B%2 or C%2: + print(cnt) + break + temp_a = A//2 + temp_b = B//2 + temp_c = C//2 + A += 2*temp_a + temp_b + temp_c + B += 2*temp_b + temp_a + temp_c + C += 2*temp_c + temp_a + temp_b + cnt += 1" +p03817,s026875561,Accepted,"def solve(): + x = int(input()) + n = x // 11 + + if x == 6: + return 1 + elif x == n * 11: + return 2 * n + elif n * 11 < x <= n * 11 + 6: + return 2 * n + 1 + elif n * 11 + 6 < x <= (n + 1) * 11: + return 2 * (n + 1) + +print(solve())" +p02777,s462739027,Accepted,"S,T = input().split() +A,B = map(int, input().split()) +U = input() + +if S == U: + A -= 1 +else: + B -= 1 + +print(A,B)" +p03469,s125428227,Wrong Answer,"print(""input().replace(2017, 2018)"")" +p04030,s262702689,Wrong Answer,"given = [x for x in input()] +rets = '' +for i, v in enumerate(given): + if v == ""B"" and i != 0: + rets = rets[:-1] + else: + rets += v +print(rets) + +" +p03665,s831712186,Wrong Answer,"n, p = map(int, input().split()) +a = [1 if i%2==0 else 0 for i in map(int,input().split())] +sum_a = sum(a) + +if p==0: + print(n*(n-1)-sum_a*(n-sum_a)) +else: + print(sum_a*(n-sum_a))" +p03699,s862096358,Accepted,"N = int(input()) +S = [] +a = 101 +for i in range(N): + s = int(input()) + if s % 10 != 0: + a = min(s,a) + S.append(s) +S.sort() +ans = sum(S) +if ans % 10 == 0: + if a != 101: + ans = ans - a + else: + ans = 0 +print(ans)" +p03408,s851388535,Wrong Answer,"n = int(input()) +s = [input() for i in range(n)] +m = int(input()) +t = [input() for j in range(m)] +S = list(set(s)) +T = list(set(t)) + +for x in range(len(S)): + a = s.count(S[x]) - t.count(S[x]) + ans = max(0, a) +print(ans)" +p03998,s824307603,Wrong Answer,"a = list(map(str, input().split())) +b = list(map(str, input().split())) +c = list(map(str, input().split())) + +n = 'a' + +while True: + if n == 'a': + if len(a) == 0: + print('A') + break + else: + n = a.pop(0) + elif n == 'b': + if len(b) == 0: + print('B') + break + else: + n = b.pop(0) + else: + if len(c) == 0: + print('C') + break + else: + n = c.pop(0)" +p03778,s979374462,Accepted,"w,a,b=map(int,input().split()) + +if a<=b: + if a+w= a: + break +num -= a +print(num)" +p04034,s658297119,Wrong Answer,"n,m = map(int,input().split()) + +red = [0 for i in range(n)] +amount = [1 for i in range(n)] +red[0] = 1 +for _ in range(m): + x,y = map(int,input().split()) + amount[x-1] -= 1 + amount[y-1] += 1 + if red[x-1]: + red[y-1] = 1 + +ans = 0 +for r,a in zip(red, amount): + if r > 0 and a > 0: + ans += 1 + +print(ans)" +p02922,s971955757,Accepted,"import math +A,B=map(int, input().split()) + +print(1+math.ceil((B-A)/(A-1)))" +p03106,s858537213,Accepted,""""""" +author : halo2halo +date : 16, Jan, 2020 +"""""" + +import sys +import numpy as np + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10 ** 7) + +A, B, K = map(int, readline().split()) +lis=[] +for i in range(1, min(A, B) + 1): + + if A % i == 0 and B % i == 0: + lis.append(i) +lis.reverse() +print(lis[K-1]) +" +p03243,s327347394,Accepted,"#python3 +from collections import Counter +n = int(input()) +a = [str(i) for i in range(100, 1000) if len(Counter(str(i))) == 1] +for i in a: + if n <= int(i): + print(i) + break" +p02720,s351555714,Accepted,"K = int(input()) + + +def dfs(d, n, buf): + buf.append(n) + + if d == 10: + return + + lsd = n % 10 + + if lsd != 0: + dfs(d + 1, n * 10 + lsd - 1, buf) + + dfs(d + 1, n * 10 + lsd, buf) + + if lsd != 9: + dfs(d + 1, n * 10 + lsd + 1, buf) + + +buf = [] + +for n in range(1, 10): + dfs(1, n, buf) + +print(sorted(buf)[K - 1]) +" +p02873,s482483679,Wrong Answer,"s = input() +ans = [0 for i in range(len(s)+1)] + +for i in range(1,len(s)): + if s[i] == '<': + ans[i+1] = ans[i]+1 +for i in range(len(s)-1,-1,-1): + if s[i] == '>': + ans[i] = max(ans[i],ans[i+1]+1) + +print(sum(ans)) +" +p03017,s769624871,Accepted,"n,a,b,c,d = map(int,input().split()) +s = input() +if d= N: + break + +A.sort() +print(sum(A[-N:]))" +p03796,s226808208,Wrong Answer,"n = int(input()) +M = 10**9+7 +sum = 1 +for i in range(1,n): + sum *= i%M +print(sum%M)" +p03162,s495952897,Accepted,"n = int(input()) +abc_list = [list(map(int, input().split())) for i in range(n)] +dp = [[0] * 3 for i in range(n)] +dp[0] = [abc_list[0][0], abc_list[0][1], abc_list[0][2]] + +for i in range(1, n): + dp[i][0] = abc_list[i][0] + max(dp[i - 1][1], dp[i - 1][2]) + dp[i][1] = abc_list[i][1] + max(dp[i - 1][0], dp[i - 1][2]) + dp[i][2] = abc_list[i][2] + max(dp[i - 1][0], dp[i - 1][1]) + +print(max(dp[n - 1]))" +p03607,s251382784,Accepted,"n = int(input()) +a = [int(input()) for _ in range(n)] + +a.sort() +a.append(0) +ans = 0 +flag = True +for i in range(1,n+1): + if a[i] == a[i-1]: + flag = not flag + else: + if flag: + ans += 1 + flag = True + #print(flag) + #print(a[i]) +print(ans)" +p02909,s316386854,Accepted,"S = input() + +if S==""Sunny"": + print(""Cloudy"") +elif S==""Cloudy"": + print(""Rainy"") +else: + print(""Sunny"")" +p03821,s340084900,Accepted,"n = int(input()) +abl = [] +for _ in range(n): + a,b = map(int,input().split()) + abl.append((a,b)) + +abl = reversed(abl) + +ans = 0 +for a,b in abl: + a += ans + if a % b != 0: + ans += b - (a % b) + +print(ans)" +p02723,s497701090,Accepted,"ipt = input() +input_list = list(ipt) +if input_list[2] == input_list[3] and input_list[4] == input_list[5]: + print('Yes') +else: + print('No')" +p03456,s491613340,Accepted,"a,b=map(str,input().split()) +if int(a+b)**0.5%1: + print('No') +else: + print('Yes')" +p02664,s534445203,Accepted,"s=input() +print(s.replace(""?"", ""D""))" +p02948,s183749422,Accepted,"import heapq + +N, M = list(map(int,input().split())) +A = [] +for i in range(N): + in1, in2 = list(map(int,input().split())) + A.append([in1, in2]) + +A = sorted(A) +ans = 0 +day = 1 +cnt = 0 +x = [] + +for i in range(M): + while(cnt < N): + if A[cnt][0] == day: + heapq.heappush(x, -A[cnt][1]) + cnt += 1 + else: + break + if x: ans -= heapq.heappop(x) + day += 1 + +print(ans)" +p02699,s860934917,Accepted,"def resolve(S: int, W: int) -> str: + if S <= W: + return 'unsafe' + else: + return 'safe' + +if __name__ == '__main__': + S, W = map(int, input().split()) + res = resolve(S, W) + print(res) +" +p02970,s558560641,Wrong Answer,"n , d = map(int, input().split()) +count = 0 + +for i in range(n): + if n > 2*d+1: + count += 1 + n = n - 2*d+1 +if n != 0: + count += 1 + +print(count)" +p03220,s247946172,Accepted,"n=int(input()) +t,a=map(int,input().split()) +h=list(map(int,input().split())) +list=[] +for hh in h: + list.append(t-0.006*hh) +ans=[] +for l in list: + ans.append(abs(a-l)) +print(ans.index(min(ans))+1) + " +p02759,s596984784,Accepted,"def main(): + hoge = int(input()) + print(-(-hoge // 2)) + +if __name__ == '__main__': + main()" +p02854,s991595354,Accepted,"from itertools import accumulate + +n = int(input()) +a = list(accumulate(map(int, input().split()))) + +ans = a[-1] +for i in a: + ans = min(ans,abs(2*i-a[-1])) +print(ans)" +p03309,s125018109,Accepted,"import statistics +n = int(input()) +A = [int(i) for i in input().split()] +A_list = [] +ans_l,ans_h = 0,0 +Min = 10**9 + +for i in range(n): + A_list.append(A[i]-(i+1)) + +b_lowkey = statistics.median_low(A_list) +b_highkey = statistics.median_high(A_list) + +for i in range(n): + ans_l += abs(A_list[i]-b_lowkey) + ans_h += abs(A_list[i]-b_highkey) +print(min(ans_l,ans_h)) +" +p03472,s078245634,Wrong Answer,"from collections import deque +N, H = map(int, input().split()) +a, b = [], [] +for _ in range(N): + a_, b_ = map(int, input().split()) + a.append(a_) + b.append(b_) +a.sort() +b.sort() +maxa = a[-1] +que = deque(b) +cnt = 0 +while H >= 0: + if not que: + cnt += -(-H//maxa) + break + maxb = que.pop() + if maxb > maxa: + cnt += 1 + H -= maxb + else: + cnt += -(-H//maxa) + break +print(cnt)" +p03206,s635181994,Accepted,"import sys +input = sys.stdin.buffer.readline + +D = int(input()) + +print(""Christmas"" + "" Eve"" * (25 - D))" +p02556,s117325076,Accepted,"n = int(input()) +xy = [list(map(int, input().split())) for _ in range(n)] +def f(x): + return x[0]-x[1] +def g(x): + return x[0]+x[1] +ans = max(f(max(xy, key=f))-f(min(xy, key=f)), + g(max(xy, key=g))-g(min(xy, key=g)),) +print(ans)" +p03059,s712899975,Accepted,"a, b, t = map(int, input().split()) +print(t // a * b)" +p03862,s982544258,Accepted,"N, X = map(int, input().split()) +A = list(map(int, input().split())) + +answer = 0 +for i in range(N - 1): + d = A[i] + A[i+1] - X + if d <= 0: + continue + if d > A[i+1]: + A[i] -= d - A[i+1] + A[i+1] = 0 + else: + A[i+1] -= d + answer += d + +#print(A) +print(answer)" +p03345,s031242975,Accepted,"a,b,c,k = map(int, input().split()) + +ans=a-b +if k%2==1: + ans=b-a +if ans > 10**18: + print(""Unfair"") +else: + print(ans)" +p03803,s824011219,Accepted,"# aアリス   bボブ +a, b = map(int, input().split()) +if a == b: + print(""Draw"") +elif a == 1: + print(""Alice"") +elif b == 1: + print(""Bob"") +elif a < b: + print(""Bob"") +elif b < a: + print(""Alice"") +" +p02768,s157194702,Accepted,"n,a,b=map(int,input().split()) +m=10**9+7 +def c(x,r=1): + for i in range(x):r=r*(n-i)*pow(i+1,m-2,m)%m + return r +print((pow(2,n,m)-1-c(a)-c(b))%m)" +p03086,s451349309,Accepted,"if __name__ == '__main__': + #全探索 + S = input() + s_len = len(S) + s1 = {""A"",""C"",""G"",""T""} + + m_len = 0 + for x in range(s_len): + for y in range(x+1,s_len+1): + s2 = set(S[x:y]) + s_union = s1.union(s2) + if len(s_union) == 4: + m_len = max(m_len,len(S[x:y])) + print(m_len) +" +p02888,s743002368,Accepted,"import bisect + +n = int(input()) +l = sorted(list(map(int, input().split()))) +ans = 0 + +for a in range(n): + for b in range(a): + over_c = l[a] + l[b] + over_c_index = bisect.bisect_left(l,over_c) + quantity = over_c_index - a - 1 + ans += max(quantity,0) +print(ans)" +p03038,s627702518,Wrong Answer,"N, M = map(int, input().split()) +A = list(map(str, input().split())) +total = 0 +for i in A: + total += int(i) + + +for i in range(M): + count = 0 + b, c = map(str, input().split()) + + for n in A: + if n == b: + count += 1 + total += (int(c)-int(b))*count + + +print(total)" +p02783,s356376295,Accepted,"H, A = map(int, input().split()) +print(H // A if H % A == 0 else H // A + 1) +" +p03565,s183916885,Wrong Answer,print('UNRESTORABLE') +p03012,s575189617,Accepted,"ans = [] +n = int(input()) +w = list(map(int, input().split())) + +for t in range(n): + s1 = [] + s2 = [] + for i in range(len(w)): + if t >= i: + s1.append(w[i]) + elif t < i: + s2.append(w[i]) + ans.append(abs(sum(s1) - sum(s2))) + +print(min(ans)) +" +p03481,s450363628,Accepted,"x,y = map(int, input().split()) + +cnt = 0 +while x <= y: + x *= 2 + cnt += 1 +print(cnt) +" +p02546,s236708075,Accepted,"S = input() + +if S[-1] == 's': + P = S + ""es"" +else: + P = S + ""s"" + +print(P)" +p03210,s006150487,Accepted,"def main(X): + list753 = [3,5,7] + return 'YES' if X in list753 else 'NO' + +X = int(input()) +print(main(X))" +p03943,s317517929,Accepted,"a, b, c = sorted(map(int, input().split())) +print((""No"", ""Yes"")[a + b == c])" +p03815,s563076117,Accepted,"x = int(input()) + +ans = (x//11)*2 +remainder = x%11 +if remainder == 0: + print(ans) +elif 1 <= remainder <= 6: + print(ans+1) +else: + print(ans+2)" +p03699,s939676305,Accepted,"N = int(input()) +s = [] + +for i in range(N): + s.append(int(input())) + +S = sum(s) + +if S%10 != 0: + print(S) +else: + b = True + for j in range(N): + if s[j]%10 == 0: + continue + else: + b = False + if b: + print(0) + else: + s.sort() + for k in range(N): + if s[k]%10 != 0: + print(S-s[k]) + break" +p03043,s055978310,Accepted,"from collections import Counter +from collections import defaultdict +from collections import deque +import math +import itertools +import heapq +import sys +sys.setrecursionlimit(10**6) + +#n=int(input()) +#n,m=list(map(int,input().split())) +#a=list(map(int,input().split())) +input_list = lambda : list(map(int,input().split())) + + +n,k=input_list() + +ans=0 + +for i in range(1,n+1): + cal=math.ceil(math.log(k/i,2)) + cal=max(0,cal) + ans+=(1/2)**(cal) + +print(ans/n)" +p03419,s151059538,Accepted,"N, M = map(int, input().split()) +print(abs(N-2)*abs(M-2))" +p03637,s273051235,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +count = 0 +count2 = 0 +for i in a: + if i%4==0: + count += 1 + elif i%2==0: + count2 += 1 + +if count2 <= 1: + count2 = 0 + +if count >= N//2-count2: + print('Yes') +else: + print('No') + +2228187" +p03331,s344669374,Wrong Answer,"def f(x): + sum = 0 + for i in str(x): + sum += int(i) + return sum +n = int(input()) +aim = 1000000000 +for i in range(2,n-1): + sum = f(i)+f(n-i) + aim = min(aim,sum) +print(aim)" +p03495,s078021648,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +cnt = [0] * (n+1) +for i in range(n): + cnt[a[i]] += 1 +cntl = sorted(cnt) +print(sum(cntl[:-k]))" +p03698,s774977179,Accepted,"s = input() +print('yes' if len(list(s)) == len(set(s)) else'no')" +p03994,s165652177,Wrong Answer,"s=input() +l=len(s) +k=int(input()) +z='' +for i in range(l): + t=123-ord(s[i]) + if t<=k: + z+='a' + k-=t + else: + z+=s[i] +k=k%26 +z=z[:l-1]+chr((ord(z[l-1])+k)%26) +print(z)" +p03644,s587661043,Accepted,"n = int(input()) + +if n == 1: + ans = 1 +else: + i = 0 + now = 1 + while now < n: + now *= 2 + i+=1 + if now > n: + ans = now//2 + else: + ans = now +print(ans)" +p02624,s414033040,Wrong Answer,"import math + +n = int(input()) +result = 0 +for k in range(1, n+1): + result += k + + +print(result) +" +p02756,s501444587,Accepted,"import sys +from collections import deque + + +reverse = 0 +S = deque(list(input())) +q = int(input()) + +for query in sys.stdin: + if query[0] == '1': + reverse = 1 - reverse + continue + + _, f, c = query.split() + f = int(f) + action = (reverse + f) % 2 + if action: + S.appendleft(c) + else: + S.append(c) + +if reverse: + S.reverse() + +print(''.join(S))" +p02916,s852809071,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +c=list(map(int,input().split())) +ans=sum(b) +for i in range(n-1): + if a[i+1]==a[i]+1: + ans+=c[a[i]-1] +print(ans)" +p03797,s147835560,Wrong Answer,"n, m = map(int, input().split()) + +cnt = n * 2 + m * 1 +print(cnt // 4)" +p03745,s698293509,Wrong Answer," +N = int(input()) + +A = list(map(int,input().split())) + +ans = 1 +f = False + +for i in range(N-2): + + i += 1 + + if f: + f = False + continue + + if A[i-1] > A[i] and A[i] < A[i+1]: + ans += 1 + f = True + + elif A[i-1] < A[i] and A[i] > A[i+1]: + ans += 1 + f = True + +print (ans) +" +p03317,s498543440,Accepted,"import math +n,k=map(int,input().split()) +a=list(map(int,input().split())) +print(math.ceil((n-1)/(k-1)))" +p03371,s523674111,Accepted,"a, b, c, x, y = map(int, input().split()) +ans1 = a * x + b * y #そのまま +ans2 = 0 +if x > y: #少ない方をABで補う + ans2 = c * min(x, y) * 2 + a * (x - y) +else: + ans2 = c * min(x, y) * 2 + b * (y - x) +ans3 = c * max(x, y) * 2 #すべてABで +print(min(ans1, ans2, ans3))" +p03804,s765269625,Accepted,"N, M = map(int, input().split()) +A = [] +B = [] +C = [] +flag = 0 + +for i in range(N): + A.append(input()) +for i in range(M): + B.append(input()) + +for i in range(N- M+ 1): + for j in range(N- M+ 1): + C = [] + for k in range(M): + C.append(A[j+ k][i:i+ M]) + if(B == C): + print(""Yes"") + flag = 1 + break + if(flag == 1): + break +else: + print(""No"")" +p04045,s690771995,Accepted,"def main(): + num = list(map(int,input().split())) + bad = list(map(int,input().split())) + + while True : + flg=0 + + for i in range(0,len(str(num[0]))): + stnum=str(num[0]) + if int(stnum[i]) in bad: + flg=1 + break + + if flg==1: + num[0]+=1 + continue + else: + break + + print(num[0]) + +main()" +p02695,s269619467,Accepted,"from collections import deque +import itertools + +n,m,q = list(map(int,input().split())) +l = [] +for i in range(q): + line = list(map(int,input().split())) + l.append(line) +ans = 0 + +comb = itertools.combinations_with_replacement(range(1,m+1),n) +for s in comb: + tmp = 0 + for j in range(q): + a,b,c,d = l[j] + if c == s[b-1]-s[a-1]: + tmp += d + ans = max(ans,tmp) + +print(ans) + +" +p02833,s804425029,Wrong Answer,"N = int(input()) + +k = 10 +ans = 0 +if N % 2 != 0: + ans = 0 +elif N == 0: + ans = 1 +else: + while k <= N: + ans += N // k + k *= 5 + +print(ans)" +p02820,s426919048,Wrong Answer,"n,k=map(int,input().split()) +r,s,p=map(int,input().split()) +t=input() + +score=0 +scorei=0 +myans=[] +myansi="""" +for i in range(n): + if(t[i]==""r""): + myansi=""p"" + scorei=p + elif(t[i]==""s""): + myansi=""r"" + scorei=r + else: + myansi=""s"" + scorei=s + + if(i>=k and myansi==myans[i-k]): + myansi=t[i] + scorei=0 + + myans.append(myansi) + score+=scorei +print(score)" +p03145,s066848211,Accepted,"a,b,c=map(int,input().split()) +print(int(a*b/2))" +p02779,s241940397,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +c=0 +for i in range(len(A)): + if A.count(A[i])==0: + c=c+1 + +if c==0: + print(""NO"") +else: + print(""YES"")" +p02618,s781143882,Accepted,"def resolve(): + d = int(input()) + ci = list(map(int, input().split())) + si = [list(map(int, input().split())) for _ in range(d)] + answers = [] + for i in range(d): + certain_date_s = si[i] + answers.append(certain_date_s.index(max(certain_date_s))+1) + [print(answer) for answer in answers] +resolve()" +p02835,s004713562,Accepted,"import sys +input = lambda: sys.stdin.readline().rstrip() + +def main(): + a = list(map(int, input().split())) + if sum(a) >= 22: + print('bust') + else: + print('win') + +if __name__ == '__main__': + main()" +p03035,s704212199,Accepted,"a, b = map(int, input().split()) +if a >= 13: + print(b) +elif a >= 6: + print(b // 2) +else: + print(0)" +p02601,s751444421,Wrong Answer,"A, B, C = map(int, input().split()) +K = int(input()) +while A > B: + B *= 2 + K -= 1 +while B > C: + C *= 2 + K -= 1 +if K >= 0 and A < B < C: + print('Yes') +else: + print('No')" +p02989,s848637070,Accepted,"N=int(input()) +l=[int(x) for x in input().rstrip().split()] +l.sort() +if l[len(l)//2-1]==l[len(l)//2]: + print(0) +else: + print(l[len(l)//2]-l[len(l)//2-1]) +" +p03861,s080450226,Accepted,"a,b,x=map(int,input().split()) + +if a==0: + fl=-1 +else: + fl=(a-1)//x + +cl=b//x + +print(cl-fl)" +p02724,s403629665,Accepted,"x = int(input()) + +ans = 0 +syo1 = x // 500 +ans += syo1 * 1000 +x = x - 500 * syo1 +ans = ans + (x // 5) * 5 +print(ans)" +p02712,s993597141,Accepted,"N = input() +lit_N = [] +for i in range(int(N)+1): + if i % 5 == 0 and i % 3 == 0: + lit_N.append(""FizzBuzz"") + elif i % 3 == 0: + lit_N.append(""Fizz"") + elif i % 5 == 0: + lit_N.append(""Buzz"") + else: + lit_N.append(i) +print(sum(list(filter(lambda x: isinstance(x,int), lit_N))))" +p02793,s450223830,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +MOD = 10 ** 9 + 7 + +def gcd(x, y): + while y: x, y = y, x % y + return x + +def lcm(x, y): + return x * y // gcd(x, y) + +tmp = A[0] +for i in range(1, N): + tmp = lcm(A[i], tmp) +tmp %= MOD + +answer = 0 +for a in A: + answer += tmp * pow(a, MOD - 2, MOD) + +print(answer % MOD) +" +p02993,s714634079,Wrong Answer,"s = input() + +ans = 'Good' if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else 'Bad' +print(ans) +" +p03285,s637021537,Wrong Answer,"N = int(input()) + +cake = [i for i in range(4, N+1, 4)] + +dons = [i for i in range(7, N +1, 7)] + +ans = ""No"" +for i in range(N//4): + for j in range(N//7): + if cake[i] + dons[j] == N: + ans = ""Yes"" + break + +ans" +p03759,s382167117,Accepted,"a, b, c = map(int, input().split()) + +if b-a==c-b: + print('YES') +else: + print('NO')" +p02795,s213251817,Accepted,"def main(): + H = int(input()) + W = int(input()) + N = int(input()) + long = max(H, W) + cnt = N // long + if N % long != 0: + cnt += 1 + print(cnt) + + +if __name__ == ""__main__"": + main() +" +p02724,s359542781,Accepted,"x = int(input()) +res = 0 +if(x>=500): + p = x//500 + res = p*1000 + x = x-(p*500) +if(x>=5): + z = x//5 + res = res+(z*5) +print(res)" +p02696,s944232569,Accepted,"import math as m +A, B, N = map(int, input().split()) +if N >= B: print(m.floor(A * -1 / B) - A * m.floor(-1 / B)) +else: print(m.floor(A * N / B) - A * m.floor(N / B))" +p02957,s708149117,Wrong Answer,"a, x =map(int, input().split()) +if (a+x)%2 ==0: + print((a+x)/2) +else: + print('IMPOSSIBLE')" +p02786,s197766645,Wrong Answer,"H = int(input()) +flag = 0 +while H !=1: + if H%2 == 1: + H+=1 + H =H/2 + flag +=1 + +S =0 +for i in range(flag): + S +=2**(i) + +print('{}'.format(2**(flag+1)-1)) +" +p03681,s760374781,Accepted,"n, m = map(int,input().split()) + +if abs(n-m) <= 1: + sumN = 1 + sumM = 1 + for i in range(2,n+1): + sumN = sumN*i % (10**9+7) + for i in range(2,m+1): + sumM = sumM*i % (10**9+7) + if n==m: + print(2*sumM*sumN % (10**9+7)) + else: + print(sumM*sumN % (10**9+7)) +else: + print(0) +" +p03711,s383221706,Accepted,"x,y=map(int,input().split()) +a={1,3,5,7,8,10,12} +b={4,6,9,11} +c={2} +if x in a: + group_x=0 +elif x in b: + group_x=1 +else: + group_x=2 + +if y in a: + group_y=0 +elif y in b: + group_y=1 +else: + group_y=2 + +if group_x==group_y: + print(""Yes"") +else: + print(""No"") +" +p02754,s127452594,Accepted,"n, a, b = [int(i) for i in input().split()] + +x = int(n/(a+b)) +y = int(n%(a+b)) + +if y > a: + y = int(a) + + +print(int((x*a)+y))" +p02811,s543833934,Accepted,"K, X = list(map(int, input().split())) + +if K * 500 >= X: + print('Yes') +else: + print('No')" +p02789,s734463722,Accepted,"N, M = map(int, input().split()) + +if N==M: + print(""Yes"") +else: + print(""No"")" +p03472,s225948509,Wrong Answer,"import bisect +import math + +n, m = map(int, input().split()) +a = [] +b = [] +for i in range(n): + aa, bb = map(int, input().split()) + a.append(aa) + b.append(bb) + +ma = max(a) +b = sorted(b) +mab = bisect.bisect_left(b, ma) +sb = sum(b[mab:]) + +def cut_throw(ma, sb): + res = math.ceil((m - sb) / ma) + return res + +if sb <= m: + print(cut_throw(ma, sb) + n - mab) +else: + print(bisect.bisect_left(b, m))" +p02642,s007162422,Accepted,"import collections,sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +N = I() +A = sorted(LI()) +counter_A = collections.Counter(A) +sequence = [0]*(10**6+1) +ans = 0 +for k,v in counter_A.items(): + if sequence[k]==1: + continue + if v==1: + ans += 1 + for i in range(k,10**6+1,k): + sequence[i] = 1 +print(ans) +" +p03380,s371490119,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +max_a = max(a) +a.remove(max_a) +da = [abs(ai - max_a/2) for ai in a] +med_i = da.index(min(da)) +print(max_a, a[med_i])" +p03211,s058650393,Accepted,"s = list(input()) + +ans = float(""inf"") +for i in range(len(s)-2): + t = int("""".join(s[i:i+3])) + ans = min(ans, abs(t-753)) +print(ans) +" +p02873,s324087720,Wrong Answer,"s = list(input()) +num = 0 +n = len(s) +l = [] +i = 0 +while i < n: + if s[i] == '<': + l.append(num) + num+=1 + i+=1 + if i==n: + l.append(num) + else: + cur = 0 + while i < n and s[i]=='>': + l.append(cur) + i+=1 + cur+=1 + num = 1 + if i==n: + l.append(cur) +print(sum(l))" +p02755,s416298543,Accepted,"A,B=map(int,input().split()) + +ansA=A*(100/8)#この数か、この数よりでかI数となる +if ansA==int(ansA):#小数点以下0なら + ansA=int(ansA) +else: + ansA=int(ansA)+1 + + +ansB=B*10#この数か、この数よりでかい数となる + +if ansA>=ansB: + ans=ansA +else: + ans=ansB + +if int(ans*(8/100))==A and int(ans*(10/100))==B: + print(ans) +else: + print(-1)" +p03705,s335366381,Wrong Answer,"#AGC015-A +n,a,b = map(int,input().split()) + +mi = a * (n-2) +ma = b * (n-2) +result = ma - mi + 1 +if a > b: + print(0) +elif a == b and n != 1: + print(0) + +elif n == 2: + print(1) +elif result < 0: + print(0) + +else: + print(result)" +p02717,s156578459,Accepted,"X,Y,Z = map(int,input().split()) +print(Z,X,Y)" +p02693,s971525261,Wrong Answer,"k = int(input()) +a, b = list(map(int, input().split())) + +for i in range(a, b): + if i % k == 0: + print('OK') + exit() +print('NG') +" +p03329,s780758752,Wrong Answer,"import math,numpy, collections + +n = int(input()) +ans = n +cnt = 0 +for i in range(n): + cnt = 0 + x = i + while x >0: + cnt += x%6 + x = x//6 + y = n-i + while y >0: + cnt += y%9 + y = y//9 + ans = min(ans,cnt) + +print(ans)" +p03264,s265228921,Wrong Answer,"a = int(input()) +print((a//2) * (a+1)//2) +" +p02600,s683901512,Accepted,"X = int(input()) +for i in range(8): + if X >= 1800 - 200 * i: + print(1 + i) + exit()" +p03485,s606994886,Wrong Answer,"def calc(): + rem = (a + b)%2 + ans = 0 + + if rem == 0: + ans = (a+b)/2 + return ans + else: + ans = (a+b)//2 + 1 + return ans + +a, b = map(int,input().split()) +print(calc()) +" +p03086,s104434816,Accepted,"S = str(input()) + +data = ['A','C','G','T'] + +acgt = '' +for s in S: + if s not in data: + acgt += '.' + else: + acgt += s + +ans = 0 +for s in acgt.split('.'): + ans = max(ans, len(s)) +print(ans)" +p03673,s837930224,Accepted,"from collections import deque +N = int(input()) +A = [int(x) for x in input().split()] +if N%2==0: + queue = deque() + for i in range(0, N, 2): + queue.append(A[i]) + queue.appendleft(A[i+1]) +else: + queue = deque([A[0]]) + for i in range(1, N, 2): + queue.append(A[i]) + queue.appendleft(A[i+1]) + +print(*queue) + + + + " +p02786,s363084464,Wrong Answer,"h = int(input()) + +dp = [0, 1] + +for i in range(2, 100001): + x = 1 + 2 * dp[i // 2] + dp.append(x) + + +if h < 100001: + print(dp[h]) + + + +else: + l = [] + y = h + while y >= 100001: + l = [x] + l + y = y// 2 + ans = 1 + 2 * dp[l[0] // 2] + if len(l) > 1: + for i in range(len(l) - 1): + ans = 1 + 2 * ans + print(ans)" +p02677,s401069983,Accepted,"A, B, H, M = map(int,input().split()) + +import numpy as np +theta_h=2*np.pi*(H/12 + M/720)#rad +theta_m=2*np.pi*M/60#rad +theta=min((max(theta_h, theta_m)-min(theta_h, theta_m)), 2*np.pi-(max(theta_h, theta_m)-min(theta_h, theta_m))) +print(np.sqrt(A**2 + B**2 - 2*np.cos(theta)*A*B))" +p03657,s540583041,Accepted,"a,b = map(int, input().split()) + +if a%3==0 or b%3==0 or (a+b)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p04030,s121503378,Accepted,"def main(): + S = list(input()) + ans = [] + for s in S: + if s == '0': + ans.append('0') + elif s == '1': + ans.append('1') + else: + if len(ans) > 0: + ans.pop() + print(''.join(ans)) + +if __name__ == ""__main__"": + main() +" +p02691,s552942074,Wrong Answer,"import collections +N = int(input()) +A = list((map(int,input().split()))) + +index = list(range(1,N+1)) + +R = [index[i] - A[i] for i in range(N)] +L = [index[j] + A[j] for j in range(N)] + +R_dict = collections.Counter(R) +L_dict = collections.Counter(L) + +ans=0 +for i in R_dict.keys()&L_dict.keys(): + # print(R_dict[i]) + # print(L_dict[i]) + ans+=L_dict[i] + +print(ans)" +p03745,s125951540,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +if N == 1: + print(1) +else: + ans = 0 + i = 0 + while i < N: + while i + 1 < N and A[i] == A[i + 1]: + i += 1 + if i + 1 < N and A[i] < A[i + 1]: + while i + 1 < N and A[i] <= A[i + 1]: + i += 1 + elif i + 1 < N and A[i] > A[i + 1]: + while i + 1 < N and A[i] >= A[i + 1]: + i += 1 + + ans += 1 + i += 1 + + print(ans)" +p03059,s199461573,Wrong Answer,"a,b,t=map(int,input().split()) +for i in range(20): + if a*i < t+0.5: + k=i + else: + break + +print(b*k)" +p02663,s364848430,Accepted,"h1, m1, h2, m2, k = map(int, input().split()) + +ans = (h2-h1)*60 + (m2-m1) - k +print(ans) +" +p02811,s370478972,Accepted,"K, X = map(int, input().split()) + +if 500 * K >= X: + print('Yes') +else: + print('No')" +p03814,s871975632,Accepted,"S = input() + +N = len(S) +Aflag = -1 +Zflag = 0 +for i in range(N): + if Aflag == -1 and S[i] == 'A': + Aflag = i + elif S[i] == 'Z': + Zflag = i + +print(Zflag-Aflag+1) +" +p02658,s686155037,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +ans=1 +for a in A: + ans=ans*a + if ans>10**18: + print(-1) + exit() +print(ans)" +p03435,s025239804,Wrong Answer,"import numpy as np + +c = [list(map(int, input().split())) for i in range(3)] +c = np.array(c) +flag = False +for a1 in range(min(c[0] + 1)): + b1 = c[0, 0] - a1 + b2 = c[0, 1] - a1 + b3 = c[0, 2] - a1 + if c[1, 0] - b1 == c[1, 1] - b2 == c[1, 2] - b3 > 0 and c[2, 0] - b1 == c[2, 1] - b2 == c[2, 2] - b3 > 0: + print('Yes') + flag = True + +if not flag: + print('No') +" +p03328,s675462371,Accepted,"a, b = [int(x) for x in input().split()] + +s = ss = 0 +for i in range(1000): + s += i + if s-ss == b-a: + break + ss = s +print(s-b)" +p02899,s898687806,Accepted,"a=int(input()) +b=[0]*a +c=list(map(int,input().split())) + +for i in range(a): + b[c[i]-1]+=i+1 +print(' '.join(map(str, b)))" +p02646,s089567473,Accepted,"A,V=list(map(int,input().split(' '))) +B,W=list(map(int,input().split(' '))) +T=int(input()) +if A= B+T*W: + print('YES') + else: + print('NO') +if A>B: + if A-T*V<= B-T*W: + print('YES') + else: + print('NO')" +p03854,s107243175,Accepted,"import re +s = input() +match = re.match(r""^(dream|dreamer|erase|eraser)+$"",s) +print(""YES"" if match else ""NO"")" +p02754,s827605703,Accepted,"n, a, b = map(int, input().split()) +print(n // (a + b) * a + min(n % (a + b), a)) +" +p03673,s332000296,Wrong Answer,"n = int(input()) +al = list(map(int, input().split())) + + +res = [0]*n +m = n //2 + +if n % 2 ==0: + for i in range(m): + res[i] = al[-1-i*2] + for j in range(m): + res[m+j]= al[j*2] + + print(res) + +else: + for i in range(m+1): + res[i] = al[-1-i*2] + for j in range(m): + res[m+1+j] = al[1+j*2] + print(res)" +p03804,s626066995,Accepted,"n, m = map(int, input().split()) +a = [input() for _ in range(n)] +b = [input() for _ in range(m)] +flag = 0 +for i in range(n-m+1): + for j in range(n-m+1): + for k in range(m): + if a[j+k][i:i+m]!=b[k]: + break + else: + flag = 1 +print(""Yes"" if flag else ""No"")" +p03107,s435038914,Wrong Answer,"s = input() +print(min(s.count(""1""),s.count(""2""))*2)" +p03146,s468564885,Accepted,"s = int(input()) +d = {s: 1} +i = 1 + +while True: + if s % 2 == 0: + s //= 2 + else: + s = 3 * s + 1 + i += 1 + if s in d.keys(): + print(i) + exit() + else: + d[s] = i +" +p03951,s745375567,Wrong Answer,"N = int(input()) +s = input() +t = input() + +st = s+t +total_len = len(st) +dupl = 0 +for n in range(N+1): + print(st[N-n:N], st[N:N+n]) + if st[N-n:N] == st[N:N+n]: + dupl = len(s[n-n:N]) + +total_len = total_len - dupl + +print(total_len)" +p02675,s388405834,Accepted,"n = list(input()) +k = int(n[-1]) + +if k in (0,1,6,8): + print(""pon"") +elif k == 3: + print(""bon"") +else: + print(""hon"")" +p02791,s522290816,Accepted,"n=int(input()) +p=list(map(int,input().split())) +a=p[0] +cnt=1 +for i in p: + if i max_B: max_B = skill_list[i][0] + +dp = [float('inf') for i in range(H + max_B)] + +dp[0] = 0 +for i in range(H): + for j in range(N): + if dp[i + skill_list[j][0]] > dp[i] + skill_list[j][1]: + dp[i + skill_list[j][0]] = dp[i] + skill_list[j][1] + +print(min(dp[H : H + max_B]))" +p02754,s701908774,Accepted,"N, A, B = map(int, open(0).read().split()) + +ans = N // (A+B) * A +x = N % (A+B) +if x >= A: + ans += A +else: + ans += x + +print(ans)" +p02823,s988101882,Accepted,"import sys + +N, A, B = map(int, input().split(' ')) +if (B - A) % 2 == 0: + print((B - A) // 2) +else: + print(min((A+B-1)//2, (N*2-A-B+1)//2))" +p03331,s596432957,Wrong Answer,"def readInt(): + return list(map(int,input().split())) +n = int(input()) +ans = 0 +while n > 0: + ans += int(n%10) + n = int(n/10) +print(ans)" +p02697,s488883167,Wrong Answer,"n,k=map(int,input().split()) +ans=[[] for _ in range(n//2)] +for i in range(1,k+1): + ans[i-1].append(i) +for i in range(1,k+1): + ans[i-1].append(n-i+1) +for i in range(k): + print(*ans[i])" +p02795,s484316149,Wrong Answer,"a = int(input()) +b = int(input()) +n = int(input()) +t = max(a, b) +print(n + t - 1 // t)" +p02935,s577936348,Accepted,"from collections import deque +N = int(input()) +v = list(map(int, input().split())) + +v = sorted(v) +v = deque(v) + + +for i in range(N - 1): + cal = 0 + cal += v.popleft() + cal += v.popleft() + cal = cal / 2 + v.appendleft(cal) + +print(v.pop()) +" +p03408,s968604342,Accepted,"import collections +s = [input() for i in range(int(input()))] +t = [input() for i in range(int(input()))] +s = list(collections.Counter(s).items()) +ans = [0] +for i in range(len(s)): + ans.append(s[i][1]-t.count(s[i][0])) +ans.sort(reverse = True) +print(ans[0])" +p04043,s004757042,Accepted,"text = list(map(int, input().split())) +text.sort() +if text[0] == 5 and text[1] == 5 and text[2] == 7: + print('YES') +else: + print('NO') + +" +p02916,s143035278,Accepted,"N = int(input()) +A = [int(x) - 1 for x in input().split()] +B = [int(x) for x in input().split()] +C = [int(x) for x in input().split()] + +result = 0 +was = -5 +for a in A: + result += B[a] + if was == a-1: + result += C[a-1] + was = a + +print(result)" +p03319,s550830077,Wrong Answer,"import sys + +N, K = map(int, input().split()) +A = list(map(int, sys.stdin.readline().rsplit())) + +print((N - 1) // (K - 1)) +" +p02987,s930060680,Accepted,"a = input() +if a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[2])==2: + print('Yes') +else: + print('No')" +p03251,s178663328,Accepted,"import sys +from collections import deque + +sys.setrecursionlimit(10 ** 6) + + +def input(): return sys.stdin.readline().rstrip() + +N, M, X, Y = map(int, input().split()) +x = list(map(int, input().split())) +y = list(map(int, input().split())) + +print('No War' if any(max(x) < Z and min(y) >= Z for Z in range(X + 1, Y + 1)) else 'War')" +p03623,s417931464,Accepted,"x,a,b=map(int,input().split()) +y=abs(x-a) +z=abs(b-x) +if y 0 else print(0)" +p02641,s377720716,Wrong Answer,"x, n = map(int, input().split()) +pli = [int(i) for i in input().split()] +ans = 0 +for s in range(1, 100): + if not x in pli: + ans = x + elif not x - s in pli and not x + s in pli: + ans = x - s + break + elif x - s in pli and not x + s in pli: + ans = x + s + break +print(ans)" +p02948,s031488466,Accepted,"import heapq + +N, M = map(int, input().split()) +jobs = {m: [] for m in range(1, M + 1)} +for _ in range(N): + a, b = map(int, input().split()) + if a in jobs: + jobs[a].append(b) + +q = [] +ans = 0 +for m in range(1, M + 1): + for b in jobs[m]: + heapq.heappush(q, -b) + if len(q) > 0: + neg_b = heapq.heappop(q) + ans += -neg_b + +print(ans) +" +p03433,s265641776,Accepted,"n = int(input()) +a = int(input()) +print('No' if n%500>a else 'Yes')" +p02713,s778998817,Wrong Answer,"def gcd(a,b): + if b > a: + c = a + a = b + b = c + while b != 0: + a = b + b = a % b + return a +k = int(input()) +ans = 0 +for ind0 in range(1,k+1): + for ind1 in range(1,k+1): + for ind2 in range(1,k+1): + ans += gcd(gcd(ind0,ind1),ind2) +print(ans)" +p04012,s692840939,Wrong Answer,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + w=list(input()) + w.sort() + if len(w)%2!=0: + print('No') + else: + for i in range(0,len(w)-1,2): + if w[i]!=w[i+1]: + print('No') + break + print('Yes') + +resolve()" +p02946,s042349121,Accepted,"K, X = map(int, input().split()) +print(' '.join([str(i) for i in range(X-K+1,X+K)]))" +p03557,s620345981,Wrong Answer,"from bisect import bisect +N = int(input()) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) + +ans = 0 +for i in B: + max_A = bisect(A, i-1) + min_C = bisect(C, i+1) + # print(""m_A"", max_A, ""m_C"", min_C) + ans += (max_A)* (len(C) - min_C) +print(ans)" +p03637,s414086106,Accepted,"n = int(input()) +a = list(map(int, input().split())) +cnt2 = 0 +cnt4 = 0 +for i in range(n): + if(a[i] % 4 == 0): + cnt4 += 1 + elif(a[i] % 2 == 0): + cnt2 += 1 + +if((cnt4 * 2 + 1) >= n or cnt2 >= (n - (cnt4 * 2 + 1) + 1)): + print(""Yes"") +else: + print(""No"") +" +p02958,s434792330,Wrong Answer,"N=int(input()) +P=list(map(int,input().split())) + +Q=[i for i in range(1,N+1)] + +count=0 +for i in range(N): + if P[i]!=Q[i]: + count+=1 +if count>=3: + print(""No"") +else:print(""Yes"")" +p03105,s373776697,Accepted,"def main(): + a, b, c = map(int, input().split()) + Count = 0 + while True: + b = b-a + if Count == c or b < 0: + break + Count += 1 + print(Count) + + +if __name__ == ""__main__"": + main() +" +p02958,s586685670,Accepted,"n = int(input()) +P = list(map(int, input().split())) +sc = sum(p != (i + 1) for i, p in enumerate(P)) +if sc == 2 or sc == 0: + print(""YES"") +else: + print(""NO"")" +p02861,s425166246,Wrong Answer,"n = int(input()) +xy_li = [list(map(int,input().split())) for _ in range(n)] +from itertools import permutations +import math +def distance(a,b): + return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2) +ans = 0 +cnt = 0 +i_li = [i for i in range(n)] +for x in permutations(i_li,n): + cnt += 1 + print(x) + for i in range(n-1): + ans += distance(xy_li[x[i]],xy_li[x[i+1]]) + +print(ans/cnt)" +p02963,s529058145,Accepted,"s = int(input()) + +div, mod = divmod(s, 10 ** 9) +ans = [0, 0, 10 ** 9, 1] +ans += [(10 ** 9 - mod) * (mod != 0), div + (mod != 0)] +print(*ans) +" +p02594,s222111945,Accepted,"x=int(input()) + +if x<30 : + print(""No"") +else : + print(""Yes"")" +p03262,s928485169,Accepted,"import fractions +n,x=map(int,input().split()) +x_list=list(map(int,input().split())) +x_list.append(x) + +x_list.sort() +x_sa=[] +a=x_list[1]-x_list[0] +for i in range(1,n): + b=x_list[i+1]-x_list[i] + a=fractions.gcd(a,b) +print(a)" +p02775,s538653336,Wrong Answer,"from collections import defaultdict as dd +n = input() +def num_bill(n): + n = str(n) + ans = sum([int(num) for num in n]) + return ans + +buyer = num_bill(n) +buyer_bill = dd(int) +for i, s in enumerate(n): + buyer_bill[i] = int(s) +#print(buyer_bill) +seller = 0 +for i in range(len(n) - 1, -1, -1): + if buyer_bill[i] > 5: + buyer -= buyer_bill[i] - 1 + buyer_bill[i-1] += 1 + seller += 10 - buyer_bill[i] + buyer_bill[i] = 0 + + #print(buyer_bill, buyer, seller) +#print(buyer_bill) +print(buyer + seller)" +p03417,s920698583,Wrong Answer,"N,M = map(int,input().split()) +"""""" +mat = [[0]*M for _ in range(N)] +dx = [-1,0,1,-1,0,1,-1,0,1] +dy = [1,1,1,0,0,0,-1,-1,-1] +for i in range(N): + for j in range(M): + for k in range(9): + if 0 <= i+dy[k] <= (N-1) and 0 <= j+dx[k] <= (M-1): + mat[i+dy[k]][j+dx[k]] += 1 +print(mat) +"""""" +if N == 1 or M == 1: + print(N*M-2) +else: + print(N*M-2*(N+M-2))" +p02556,s304837897,Accepted,"n = int(input()) + +plus,minus = [],[] +for i in range(n): + a,b = map(int,input().split()) + plus.append(a+b) + minus.append(a-b) + +plus.sort() +minus.sort() + +print(max(plus[-1]-plus[0],minus[-1]-minus[0]))" +p02784,s114108664,Accepted,"H, N = map(int, input().split()) +A_list = list(map(int, input().split())) + +sum_A = 0 + +for i in range(len(A_list)): + sum_A += A_list[i] + +if sum_A < H: + print(""No"") +else: + print(""Yes"") + " +p03000,s242749650,Wrong Answer,"y = [int(z) for z in input().split()] +l = [int(z) for z in input().split()] +d = [0]*(y[0]+1) +c = 0 +for i in range(1,y[0]+1): + d[i] = d[i-1]+l[i-1] + if (d[i]<=y[1]): + c+=1 +print(c) +" +p03103,s272878403,Accepted,"n,m=map(int,input().split()) +costs=[] +for i in range(n): + a,b=map(int,input().split()) + costs.append([a,b]) +costs=sorted(costs, key=lambda student: student[0]) +pointer=0 +ans=0 +while m>0: + costs[pointer][1]-=1 + ans+=costs[pointer][0] + m-=1 + if costs[pointer][1]==0: + pointer+=1 +print(ans)" +p02683,s640474810,Wrong Answer,"n,m,x=map(int,input().split()) +a=[list(map(int,input().split()))for i in range(n)] +ans=[] +for bit in range(1>>n): + total=0 + skill=[0]*m + for i in range(n): + if bit & (1>>i): + total+=a[i][0] + for j in range(m): + skill[j]+=a[i][j] + if all([k>=x for k in skill]): + ans.append(total) +print(min(ans) if len(ans)!=0 else -1)" +p03011,s573029875,Wrong Answer,"L=map(int,input().split()) +print(min(sum(L)-v for v in L))" +p03860,s171327721,Wrong Answer,"St = input().split() +s = St[1] +print('A' + s + 'C')" +p02987,s878027307,Wrong Answer,"import sys +sys.setrecursionlimit(10**7) +input = sys.stdin.readline + +def main(): + s = input().strip() + a = s[0] ; b = None + c = 1 ; d = 0 + + for i in range(1, 4): + if s[i] == a: + c += 1 + + elif s[i] != a: + b = s[i] + d += 1 + + elif s[i] == b: + d += 1 + + if c == 2 and d == 2: + print('Yes') + else: + print('No') + +main()" +p03797,s385692944,Wrong Answer,"n, m = map(int, input().split()) + +if n * 2 >= m: + print(n) + exit() +else: + m -= n * 2 + +print(n + (m // 4))" +p02696,s949025977,Wrong Answer,"def main(): + a,b,n = map(int,input().split()) + aa = min(b,n) + ans = 0 + for i in range(aa,n): + + ans = max(ans,a*aa//b - a * (aa//b)) + print(ans) +if __name__=='__main__': + main() +" +p03435,s184287726,Wrong Answer,"import sys +c= [list(map(int, input().split())) for i in range(3)] + +for a1 in range(100): + b1=c[0][0]-a1 + b2=c[0][1]-a1 + b3=c[0][2]-a1 + + a2=c[1][0]-b1 + a3=c[2][0]-b1 + if a2==c[1][1]-b2 and a2==c[1][2]-b3: + if a3==c[2][1]-b2 and a2==c[2][2]-b3: + print('Yes') + sys.exit(0) +print('No')" +p03387,s011055260,Accepted,"def main(): + abc = [int(x) for x in input().split()] + cnt = 0 + while True: + abc.sort() + if abc[0] == abc[1] == abc[2]: + break + if abc[1] == abc[2]: + abc[0] += 2 + else: + abc[0] += 1 + abc[1] += 1 + cnt += 1 + print(cnt) + +if __name__ == '__main__': + main()" +p02935,s329742018,Accepted,"n=int(input()) +V=list(map(int,input().split())) + +V.sort() +avg=V[0] +for i in range(n): + avg = (avg +V[i]) /2 + +print(avg)" +p02832,s792913389,Accepted,"# -*- coding: utf-8 -*- +n = int(input()) +a_list = list(map(int, input().split())) + +search_num = 1 +count = 0 + +for i in range(n): + if a_list[i] == search_num: + search_num = search_num + 1 + count = count + 1 + +if search_num == 1: + print(-1) +else: + print(n-count) +" +p02957,s282793316,Accepted,"a,b=map(int,input().split()) +if (a-b)&1:print(""IMPOSSIBLE"") +else:print(min(a,b)+abs(a-b)//2)" +p03730,s710170034,Accepted,"import sys +a,b,c = map(int,input().split()) +for i in range(1,1001): + if (a*i)%b == c: + print(""YES"") + sys.exit() +print(""NO"")" +p02952,s874916949,Wrong Answer,"n=int(input()) +a = 0 + +for i in range(1,n): + if 0 <= i <= 9 : + a+=1 + if 100 <= i <= 999 : + a+=1 + if 10000 <= i <= 99999 : + a+=1 + +print(a)" +p02714,s261141804,Accepted,"n = int(input()) +s = input() +ans = s.count(""R"")*s.count(""G"")*s.count(""B"") +for i in range(n-2): + for j in range(i+1, (n-1+i)//2+1): + k = 2*j-i + if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]: + ans -= 1 +print(ans)" +p02847,s991735155,Wrong Answer,"s=input();a=s[:2] +print(2 if a==""F""else 3 if a==""T""else 4 if a==""W""else 5 if a==""T""else 6 if s==""M""else 7 if s==""SUN""else 1)" +p03239,s292826499,Wrong Answer,"import sys +import math +import itertools + +n,T=list(map(int,input().split())) +min=9999 +for i in range(n): + c,t=list(map(int,input().split())) + if T>=t: + if min>c: + min=c +if min==9999: + print(""TLE"") +else: + print(c) +" +p03377,s531553413,Accepted,"a, b, x = map(int, input().split()) +if x < a: + print('NO') +elif a+b < x: + print('NO') +else: + print('YES') +" +p04034,s980395299,Accepted,"N, M = map(int,input().split()) +B = [list(map(int,input().split())) for k in range(M)] +H = [1]*N +E = [0]*N +E[0] = 1 +for e in B: + x, y = e[0]-1, e[1]-1 + if E[x] == 1: + if H[x] == 1: + E[x] = 0 + E[y] = 1 + else: + E[y] = 1 + H[x] -= 1 + H[y] += 1 +print(E.count(1)) +" +p03803,s428761496,Accepted,"a,b = map(int,input().split()) +if a==1: + a=14 +if b==1: + b=14 + +if a answer: + answer = temp + +print(answer) + " +p03471,s847745343,Wrong Answer,"n,y= map(int,input().split()) +ans=0 +for i in range(n+1): + for j in range(n-i,n+1): + z=y-i*10000-j*5000 + if 0<=z/10000): + print(N) +print(-1) +" +p02982,s755388596,Wrong Answer,"n,d = map(int,input().split()) +x = [] +for i in range(n): + xi = [int(i) for i in input().split()] + x.append(xi) +count = 0 +ans = 0 +for i in range(n-1): + for l in range(i+1,n): + ans = 0 + for j in range(d): + ans += (x[i][j]-x[l][j])**2 + + ans = ans **(1/2) + print(ans) + if ans == int(ans): + count += 1 +print(count) + " +p03387,s375832838,Accepted,"import sys +import itertools + +# import numpy as np + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +A = [int(x) for x in readline().split()] +s = max(A) * 3 - sum(A) +print(s // 2 if s % 2 == 0 else (s + 3) // 2) +" +p03001,s949681410,Wrong Answer,"W,H,x,y = map(int,input().split()) +S = W*H +s1 = x*H +s2 = y*W +d1 = abs(s1-S/2) +d2 = abs(s2-S/2) +if d1 == d2: + cnt = 1 +else : + cnt = 0 + +if d1<=d2: + print(s1,cnt) +elif d1>d2: + print(s2,cnt) + + +" +p02748,s889922576,Accepted,"import sys +input=sys.stdin.readline +A,B,m=map(int,input().split()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +ans=min(a)+min(b) +for i in range(m): + x,y,c=map(int,input().split()) + ans=min(ans,a[x-1]+b[y-1]-c) +print(ans) +" +p02677,s118695722,Accepted,"import sys +import math + +a, b, h, m = tuple(map(int, sys.stdin.buffer.read().split())) + +mm = m / 60 +hh = (h + mm) / 12 +r = (mm - hh) * math.pi * 2 + +print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(r)))" +p03623,s631428527,Accepted,"x,a,b=map(int,input().split(' ')) +if abs(x-a) < abs(x-b): + print('A') +else: + print('B')" +p03106,s058261389,Accepted,"a,b,c=map(int,input().split()) +lis=list(range(1,min(a,b)+1)) +lis=[x for x in lis if a%x==0 and b%x==0] +print(lis[-c])" +p02882,s819664031,Accepted,"from math import atan2, degrees +A, B, X = map(int, input().split()) +S = X / A + + +if S >= A * B / 2: + h = (2 * (A * B - S)) / A + print(degrees(atan2(h, A))) + +else: + w = (2 * S) / B + print(degrees(atan2(B, w))) +" +p03815,s139167537,Wrong Answer,"x = int(input()) + +a = x // 11 +b = x % 11 + + +if(b > 5 and b != 0): + print(a*2 + 2) +elif(b <= 5 and b != 0): + print(a*2 + 1) +elif(b == 0): + print(a*2) + " +p03086,s627602354,Wrong Answer,"# -*- coding: utf-8 -*- +"""""" +Created on Tue Mar 31 09:40:38 2020 + +@author: black +"""""" + + +S = list(input()) + +len = 0 +ans = 0 +for i in S: + if i == ""A"" or i == ""T"" or i == ""C"" or i == ""G"": + len += 1 + else: + ans = max(len, ans) + len = 0 + +print(ans)" +p03544,s655817869,Wrong Answer,"N=int(input()) +def ryuka(n): + if n==0: + return 2 + elif n==1: + return 1 + else: + return ryuka(n-1)+ryuka(n-2) +ryuka(N) " +p02866,s276821081,Accepted,"#!/usr/bin/env python3 +from collections import Counter + +n, *d = map(int, open(0).read().split()) +c = Counter(d[1:]) +c = [(0, 1)] + sorted(c.items()) +ans = d[0] == 0 +for i in range(1, len(c)): + if i != c[i][0]: + ans = 0 + break + ans *= c[i - 1][1]**c[i][1] + ans %= 998244353 +print(ans)" +p02982,s084846063,Accepted,"import math +n,d=map(int,input().split()) +X=[] +for i in range(n): + X.append(list(map(int,input().split()))) + +ans=0 +for i in range(n-1): + for j in range(i+1,n): + cnt=0 + for k in range(d): + cnt+=(X[i][k]-X[j][k])**2 + cnt=math.sqrt(cnt) + if int(cnt)==cnt: + ans+=1 +print(ans)" +p04043,s994325208,Accepted,"A = sorted(list(map(int,input().split()))) + +if A == [5,5,7]: + print(""YES"") +else: + print(""NO"")" +p03827,s421245822,Wrong Answer,"n = int(input()) +s = input() +ans = [0] +for i in range(n): + if s[i] == 'I': + ans.append(ans[i-1] +1) + else: + ans.append(ans[i-1] -1) +print(max(ans)) + " +p03075,s521823672,Accepted,"for i in range(5): + if i == 0: + a = int(input()) + elif i == 1 or i == 2 or i == 3: + tmp = int(input()) + else: + b = int(input()) +k = int(input()) +if k >= b - a: + print(""Yay!"") +else: + print("":("")" +p02939,s980841685,Accepted,"s = list(input()) +tmp1 = s[0] +tmp2 = '' +count = 0 +for i in range(1, len(s)): + tmp2 += s[i] + if tmp2 != tmp1: + count += 1 + tmp1 = tmp2 + tmp2 = '' +print(count + 1) +" +p03109,s328209752,Wrong Answer,"S = input() +print('Heisei' if S <= '2019/4/30' else 'TBD') +" +p02630,s646861926,Wrong Answer,"N=int(input()) +a_list=list(map(int,input().split())) +Q=int(input()) +B=[list(map(int,input().split())) for i in range(Q)] +a_list=sorted(a_list) +for i in range(Q): + if B[i][0] in a_list: + for j in range(N): + if a_list[j]==B[i][0]: + a_list[j]=B[i][1] + break + print(sum(a_list))" +p03815,s435488990,Wrong Answer,"# -*- coding: utf-8 -*- +"""""" +Created on Wed Sep 30 01:58:33 2020 + +@author: liang +"""""" +import math + +x = int(input()) + +ans = x // 11 *2 + math.ceil(x%11/5) + +print(ans)" +p03071,s414373479,Accepted,"a,b = map(int,input().split()) +ans = [] + +ans.append(a+b) +ans.append(a+(a-1)) +ans.append(b+(b-1)) + +print(max(ans))" +p03285,s913609948,Accepted,"n = int(input()) +if n in [1,2,3,5,6,9,10,13,17]: + print(""No"") +else: + print(""Yes"")" +p03821,s433657196,Accepted,"N = int(input()) +a = [] +b = [] +for _ in range(N): + ab = list(map(int, input().split())) + a.append(ab[0]) + b.append(ab[1]) + +count = 0 +for i in range(N-1, -1, -1): + if (a[i]+count) % b[i] != 0: + count += (b[i] - (a[i]+count) % b[i]) +print(count) +" +p03037,s935102471,Accepted,"# + +import sys +input=sys.stdin.readline + +def main(): + N,M=map(int,input().split()) + lr=[tuple(map(int,input().split())) for i in range(M)] + imos=[0]*(N+2) + cnt=0 + for i in lr: + imos[i[0]]+=1 + imos[i[1]+1]-=1 + for j in range(N+1): + imos[j+1]+=imos[j] + for i in imos: + if i == M: + cnt+=1 + print(cnt) + +if __name__==""__main__"": + main() +" +p02554,s653426444,Accepted,"mod = 10**9+7 +n = int(input()) +print((pow(10,n,mod)-pow(9,n,mod)*2+pow(8,n,mod))%mod)" +p03377,s216889608,Wrong Answer,"import sys +A,B,X = map(int,input().split()) +if not ( 1 <= A <= 100 and 1 <= B <= 100 and 1 <= X <= 200 ): + sys.exit() + +if (B + A) >= X and A <= X: + print('Yes') +else: + print('No')" +p02659,s890450949,Wrong Answer," +def default(): + a=input() + a=a.split() + a[0]=int(a[0]) + a[1]=float(a[1]) + a[1]=int(a[1]*a[0]) + print(a[1]) +if(__name__==""__main__""): + default() +" +p04030,s290715081,Accepted,"s = input() + +ans = [] + +for ss in s: + if ss == '0': + ans.append('0') + elif ss == '1': + ans.append('1') + else: + if len(ans) >= 1: + del ans[-1] + +print("""".join(ans)) +" +p03910,s122291107,Accepted,"n = int(input()) + +for i in range(1,n+1): + if i*(i+1)//2 >=n: + k = i*(i+1)//2 - n + for j in range(1,i+1): + if j == k: + continue + else: + print(j) + exit() + + +" +p03910,s157959847,Wrong Answer,"import sys +read = sys.stdin.read +#readlines = sys.stdin.readlines +from collections import deque +def main(): + + n = int(input()) + ans = deque() + num = 1 + while n: + if n - num not in ans: + ans.append(num) + n -= num + num += 1 + + print(*ans, sep='\n') + +if __name__ == '__main__': + main()" +p03838,s680126374,Accepted,"x,y = map(int,input().split()) + +res = 10**10 +cnt = 0 +for mask in range(1<<2): + _x = x + _y = y + if mask & 1: + _x *= -1 + cnt +=1 + if (mask>>1) & 1: + _y *= -1 + cnt += 1 + if _x <= _y: + cnt += _y-_x + res = min(res,cnt) + cnt = 0 +print(res)" +p03043,s939510322,Accepted,"n,k = map(int,input().split()) +ans = 0 +for i in range(1,n+1): + tmp = i+0 + x = 1/n + while i10**18: + flag=True + ans=ans%10**18 + +if flag and ans!=0: + print(-1) +else: + print(ans) +" +p02725,s526376465,Wrong Answer,"K, N = [int(n) for n in input().split()] +A = [int(n) for n in input().split()] +#print(K,N,A) +min_dis = K+1 + +for i in range(len(A) -1): + dis = A[i+1] - A[i] + if dis < min_dis: + ans = (i+1)+1 + min_dis = dis +print(ans)" +p02582,s258428006,Accepted,"s = input() +if ""RRR"" in s: + r = 3 +elif ""RR"" in s: + r = 2 +elif ""R"" in s: + r= 1 +else: + r = 0 +print(r)" +p02953,s343142703,Wrong Answer,"n = int(input()) +hlis = list(map(int, input().split())) +d = 0 +for i in range(n-1): + d = max(d, hlis[i] - hlis[i+1]) +if d > 2: + print('No') +else: + print('Yes')" +p03627,s933370852,Accepted,"from collections import Counter +N = int(input()) +a = list(map(int,input().split())) +c = Counter(a) +ans = 0 +s = [] +for e in c: + if c[e] >= 2: + s.append(e) + if c[e] >= 4: + ans = max(ans,e*e) +s = sorted(s) +if len(s) < 2: + print(0) +else: + print(max(ans,s[-1]*s[-2])) +" +p02659,s700211306,Wrong Answer,"import math +A, B = map(float, input().split("" "")) +print(math.floor(A*B))" +p03145,s893430094,Wrong Answer,"a,b,c=map(int,input().split()) +print(a*b/2) +" +p02723,s225994000,Accepted,"S = input() +if S[2] == S[3] and S[4] == S[5]: + print(""Yes"") +else: + print(""No"")" +p03779,s503441055,Wrong Answer,"X = int(input()) +cnt = 0 +t = 0 +while cnt < X: + t+=1 + if cnt+t == X: + cnt += t + elif X - (cnt+t) > t: + cnt += t +print(t)" +p03434,s828374870,Accepted,"n=int(input()) +li=list(input().split("" "")) +for g in range(n): + li[g]=int(li[g]) +ali=0 +bob=0 +li.sort() +li.reverse() +for i in range(n): + if i%2==0: + ali+=li[i] + else: + bob+=li[i] +print(abs(ali-bob)) +" +p02948,s654353342,Accepted,"import sys +import heapq +input = sys.stdin.readline +N,M = map(int,input().split()) +AB = [[] for i in range(M+1)] +for i in range(N): + a,b = list(map(int,input().split())) + if a <= M: + AB[a].append(-b) +work = 0 +AB2 = [] +heapq.heapify(AB2) +for i in range(1,M+1): + for j in AB[i]: + heapq.heappush(AB2,j) + if len(AB2) > 0: + b = heapq.heappop(AB2) + work += -b +print(work)" +p02791,s111822805,Accepted,"#!/usr/bin/env python3 +import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +n = int(readline()) +p = list(map(int,input().split())) +ans = 1 # initialization of p[0] +min_i = p[0] +for i in range(1,n): + if p[i] <= min_i: + ans += 1 + min_i = p[i] + else: pass +print(ans)" +p02847,s992776826,Accepted,"D = {""SUN"": 7, ""MON"": 6, ""TUE"": 5, ""WED"": 4, ""THU"": 3, ""FRI"": 2, ""SAT"": 1} +print(D[input()])" +p03419,s216899907,Accepted,"N,M=map(int,input().split()) +if N==M==1: + r=1 +elif N==1 or M==1: + r=N+M-3 +else: + r=N*M-2*(N-1)-2*(M-1) +print(r)" +p02631,s895586085,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +res=[0]*n +for i in range(n): + x=0 + for j in a[:i]+a[i+1:]: + x^=j + res[i]=x +print(res) +" +p02730,s453120146,Accepted,"s = input() +l = len(s) +#print(s[:(l-1)//2]) +#print(s[(l+3)//2-1:]) +def pal(t): + c = 1 + for i in range((len(t)-1)//2): + if t[i] != t[-i-1]: + c = 0 + return c +"""""" +if pal(s) and pal(s[:(l-1)//2]) and pal(s[(l+3)//2-1:]): + print(""Yes"") +else: + print(""No"") + +"""""" +if s[:(l-1)//2] == s[(l+3)//2-1:] and pal(s): + print(""Yes"") +else: + print(""No"") +" +p03448,s160357563,Accepted,"def main(): + + five_hundred = int(input()) + one_hundred = int(input()) + fifty = int(input()) + x = int(input()) + ans = 0 + for i in range(five_hundred + 1): + for j in range(one_hundred + 1): + for k in range(fifty + 1): + if 500 * i + 100 * j + 50 * k == x: + ans += 1 + + print(ans) + +if __name__ == '__main__': + main()" +p03524,s352854022,Wrong Answer,"from collections import Counter + +S = input() +c = Counter(S) + +if len(c) == 3 and max(c.values()) - min(c.values()) <= 1: + print(""YES"") +elif len(c) == 2 and max(c.values()) == min(c.values()): + print(""YES"") +else: + print(""NO"") +" +p02647,s119458463,Accepted,"N, K = map(int, input().split()) +A_list = list(map(int, input().split())) +for _ in range(K): + count_list = [0] * N + for i, v in enumerate(A_list): + count_list[i - v if i - v > 0 else 0] += 1 + if i + v + 1 < N: + count_list[i + v + 1] -= 1 + temp = 0 + flag = True + for i in range(len(A_list)): + temp += count_list[i] + if temp != N: + flag = False + A_list[i] = temp + if flag: + break + +print(*A_list)" +p03017,s044321128,Accepted,"n, a, b, c, d = map(int, input().split()) +a -= 1 +b -= 1 +c -= 1 +d -= 1 +s = input() +if c 幸福度のmax + for a,b,c in ABC: + x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c + + answer = max(x,y,z) + print(answer) +main()" +p03250,s344172452,Accepted,"a, b, c = map(int, input().split()) +m = max(a, b, c) +print(m*10+(a+b+c-m))" +p03696,s660018116,Accepted,"def Z(): return int(input()) +def ZZ(): return [int(_) for _ in input().split()] + +def main(): + N = Z() + S = input() + par = [0] + cc = 0 + for i in S: + if i == '(': cc += 1 + else: cc -= 1 + par.append(cc) + + mp = min(par) + output = S + if mp < 0: output = '(' * abs(mp) + output + if abs(mp) + cc > 0: output = output + ')' * (abs(mp)+cc) + print(output) + + return + +if __name__ == '__main__': + main() +" +p02899,s237446860,Accepted,"N = int(input()) +A = [int(a) for a in input().split()] + +attend = [0] * N +for i in range(N): + attend[A[i]-1] = str(i+1) + +res = ' '.join(attend) + +print(res)" +p02947,s398551955,Wrong Answer,"n = int(input()) +slist = [""""]*n +for i in range(n): + slist[i] =sorted(input()) +sslist=sorted(slist) +count=0 +for i in range(n-1): + if sslist[i]==sslist[i+1]: + count = count +1 +# print(sslist[i]) +print(count)" +p03854,s065201223,Accepted,"import sys + +s=input() + +lens=len(s) + +while lens>0: + lens0=lens + if s[lens-7:lens]==""dreamer"": + lens=lens-7 + elif s[lens-5:lens]==""dream"": + lens=lens-5 + elif s[lens-6:lens]==""eraser"": + lens=lens-6 + elif s[lens-5:lens]==""erase"": + lens=lens-5 + if lens0==lens: + print(""NO"") + sys.exit() + +print(""YES"") + " +p02909,s473444276,Wrong Answer,"weather=[""Sunny"",""cloudy"",""Rainy"",""Sunny""] + +S=input() + +for i in range(3): + if(S==weather[i]): + print(weather[i+1])" +p02693,s734642230,Wrong Answer,"K = int(input()) +A, B = map(int, input().split()) +s = A % B +if s + A > B: + print('NG') +else: + print('OK')" +p02690,s076326519,Wrong Answer,""""""" +aを10^3くらいまででいいよね +"""""" +x = int(input()) +# a>0 b>0のとき +for i in range(10**3): + for j in range(i+1,10**3): + if j ** 5 - i ** 5 == x: + print(i,j) + exit() +# a>0, b<0のとき +for i in range(10**2): + for j in range(10**2): + if i**5 + j**5 == x: + print(i,-j) + exit()" +p02918,s584901298,Accepted,"n,k = map(int,input().split()) +s = 'R' + input() + 'L' + +score = 0 +for i in range(1,n+1): + if s[i] == 'R' and s[i+1] =='R': + score += 1 + elif s[i] =='L' and s[i-1]=='L': + score += 1 +print(min(n-1,score+2*k)) + " +p02555,s065796024,Wrong Answer,"S=int(input()) +list=list(range(S)) +def get_integral_value_combination(list, target): + def a(idx, l, r, t): + if t == sum(l): r.append(l) + elif t < sum(l): return + for u in range(idx, len(list)): + a((u + 1), l + [list[u]], r, t) + return r + return a(0, [], [], target) + +print(len(get_integral_value_combination(list, S)))" +p03679,s347761606,Wrong Answer,"x,a,b = map(int,input().split()) +if a<=b: + print('delicious') +elif b>(a+x): + print('dangerous') +else: + print('safe')" +p03251,s970978570,Wrong Answer,"n,m,x,y=map(int,input().split()) +x=list(map(int,input().split())) +y=list(map(int,input().split())) +x.sort() +y.sort() +if x[n-1] 0: + if i // k == 1: + cnt += 1 + + i %= 100 + k //= 10 + +print(cnt)" +p02642,s914066629,Wrong Answer,"n = int(input()) +a_list = list(map(int, input().split())) +a_list.sort() +binary_list = [1 for i in range(n)] +#print(a_list) + +for i in range(n): + if binary_list[i]==1: + for k in range(i+1, n): + if a_list[k]%a_list[i]==0: + binary_list[k] = 0 + +if a_list[0] in a_list[1:]: + binary_list[0] = 0 + +print(sum(binary_list)) + +" +p03545,s478745368,Accepted,"_ = ""_"" + + +def solve(f): + if _ in f: + a = solve(f.replace(_, '+', 1)) + b = solve(f.replace(_, '-', 1)) + if a is not None: + return a + if b is not None: + return b + else: + if eval(f) is 7: + return f + else: + return None + + +s = _.join(input()) +print(solve(s) + '=7') +" +p03331,s930217103,Accepted,"N = int(input()) +result = [] + +for A in range(1, N): + B = N - A + A = str(A) + B = str(B) + A_sum = sum(list(map(int, A))) + B_sum = sum(list(map(int, B))) + result.append(A_sum + B_sum) + +print(min(result)) +" +p03146,s549677855,Accepted,"s=int(input()) +n=set() +a=s +for i in range(10**7): + if a in n: + break + + if a%2==0: + n.add(a) + a=a//2 + else: + n.add(a) + a=3*a+1 + +print(i+1) +" +p02880,s326192242,Accepted,"N=int(input()) +count=0 +for i in range(1,10): + for m in range(1,10): + if i*m==N: + count+=1 +if count>=1: + print(""Yes"") +else: + print(""No"")" +p02862,s070190961,Wrong Answer,"x, y = map(int, input().split()) + +if (x + y)%3 != 0: + print(0) + exit() + +diff = abs(x - y) +ref = (min(x, y) - diff)//3 +total = ref*2 + diff +mod = 10**9 + 7 +ans = 1 + +for i in range(min(ref, total - ref)): + ans = ans*(total - i)%mod + ie = pow((i + 1), (mod - 2))%mod + ans = ans*ie%mod + +print(ans)" +p02748,s154906197,Accepted,"A,B,M=map(int,input().split()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +ans=min(a)+min(b) +for _ in range(M): + x,y,c=map(int,input().split()) + ans=min(ans,a[x-1]+b[y-1]-c) +print(ans)" +p03605,s407332326,Accepted,"s = input() +if s[0]=='9' or s[1]=='9': print('Yes') +else: print('No')" +p03323,s398892193,Wrong Answer,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import sys +input = sys.stdin.readline().rstrip + +A,B = map(int, input().split()) + +ans = "":("" if A > 9 or B > 9 else ""Yay!"" +print(ans) + + +" +p04033,s602208006,Wrong Answer,"SUM = 0 +N = [int(j) for j in input().split(' ')] +LIST = [j for j in range(N[0],N[1]+1)] + +for i in range(1,len(LIST)): + if SUM == 0: + SUM = LIST[i-1] * LIST[i] + else: + SUM *= LIST[i] +if SUM < 0: + print(""Negative"") +elif SUM > 0: + print(""Positive"") +else: + print(""Zero"") +" +p03565,s966328820,Accepted,"S = input() +T = input() +ans = 'UNRESTORABLE' +for i in range(len(S)-len(T), -1, -1): + for j in range(len(T)): + if S[i+j] != '?' and S[i+j] != T[j]: + break + else: + ans = S[:i].replace('?', 'a')+T+S[i+len(T):].replace('?', 'a') + break +print(ans) +" +p02696,s630942463,Accepted,"import math +a,b,n = map(int,input().split()) +x = min(b-1,n) +print(math.floor(a*x/b) - a * math.floor(x/b))" +p03262,s014487487,Wrong Answer,"n, x = map(int, input().split()) +lis = list(map(int, input().split())) + +ans = 10**9 + 7 + +for i in range(n): + ans = min(ans, abs(x-lis[i])) + +print(ans)" +p02813,s480638496,Accepted,"import itertools + +n = int(input()) +p = tuple(map(int,input().split())) +q = tuple(map(int,input().split())) + +permutations = list(itertools.permutations(range(1,n+1))) +ps = permutations.index(p) +qs = permutations.index(q) + +print(abs(ps-qs))" +p03471,s931870252,Wrong Answer,"N, Y = map(int, input().split()) +ans = False +for i in range(N+1): + for j in range(N+1-i): + k = N-i-j + if 10000*i + 5000*j + 1000*k == Y: + ans = True + print(i, j, k) + break + +if ans == False: + print(-1, -1, -1)" +p03487,s937424198,Wrong Answer,"n = int(input()) +a = sorted(list(map(int, input().split()))) +b = set(a) +import numpy as np +c = np.array(a) +count = 0 +for i in b: + if i > 10**5: + j = sum(c>10**5) + count += j + break + else: + j = a.count(i) + if j < i: + count += j + elif j == i: + pass + else: + k = j - i + count += k +print(count)" +p02546,s818152862,Accepted,"word = input() +if word[len(word)-1] == 's': + word += 'es' +else: + word += 's' +print(word) +" +p02761,s390446213,Accepted,"x,m = map(int, input().split()) +s=[-1]*m +c=[-1]*m +for i in range(m): + s[i], c[i] = map(int, input().split()) +if x ==1: + start = 0 +else: + start = 10**(x-1) + +for j in range(start, 1000): + num = str(j) + for k1, k2 in zip(s, c): + if num[k1-1] != str(k2): + break + else: #すべて一致したとき + print(j) + break +else: + print(-1)" +p02624,s841561141,Wrong Answer,"def num_divisors_table(n): + table = [0] * (n + 1) + + for i in range(1, n + 1): + for j in range(i, n + 1, i): + table[j] += 1 + + return max(table) +N=int(input()) +ans=0 +li=[i for i in range(1,N+1)] +for i in range(1,N+1): + ans+=num_divisors_table(i)*i +print(ans) +" +p03352,s689191919,Accepted,"x=int(input()) +if x==1: + print(1) + exit() + +i=2 +ans=0 +while i*i= G: + X += 1 + G *= 2 + +while G >= B: + X += 1 + B *= 2 + +if X <= K: + print(""Yes"") +else: + print(""No"")" +p03814,s114782283,Accepted,"# import sys;input = lambda : sys.stdin.readline() +s = input() +A, Z = None, None +for i in range(len(s)): + if s[i] == ""A"": + A = i + break +for i in range(len(s) - 1, -1, -1): + if s[i] == ""Z"": + Z = i + break +print(Z - A + 1) +" +p03001,s110160390,Wrong Answer,"W,H,x,y=map(int,input().split()) +size1 = min((x*H), ((W-x)*H)) +size2 = min((W*y), (W*(H-y))) +count = 0 +if size1 == size2: + count += 1 +print(max(size1, size2), count)" +p02630,s677240931,Accepted,"from collections import Counter +a=int(input()) +l=list(map(int,input().split())) +b=int(input()) +s=Counter(l) +initial_sum=sum(l) + +for _ in range(b): + x,y=map(int,input().split()) + k=s[x] + s[x]=0 + s[y]+=k + initial_sum+=(y-x)*k + print(initial_sum) +" +p02687,s030428091,Accepted,"s = input() +if s == 'ABC': + print('ARC') +else: + print('ABC')" +p02571,s115423425,Accepted,"import sys + +s = input() +t = input() +ls = len(s) +lt = len(t) + +ans = lt +for i in range(ls -lt + 1): + tmp = lt + for j in range(lt): + if s[i + j] == t[j]: + tmp -= 1 + ans = min(ans, tmp) + if ans == 0: + print(0) + sys.exit() + +print(ans)" +p02970,s643688962,Accepted,"def mapt(fn, *args): + return list(map(fn, *args)) + + +def Input(): + return mapt(int, input().split("" "")) + + +def main(): + n, d = Input() + d = 2 * d + 1 + return (n+d-1)//(d) + +print(main())" +p02730,s494535007,Accepted,"s = list(input()) +t = s[::-1] +n = len(s) +if s != t: + print ('No') + exit() +if n == 3: + print('Yes') + exit() +d = s[:int((n-1)/2)] +e = d[::-1] +#print(d,e) +r = s[int((n+3)/2-1):] +q = r[::-1] +#print(r,q) +if d != e: + print('No') + exit() +if r != q: + print ('No') + exit() + +print('Yes')" +p02777,s670639226,Wrong Answer,"a,b = map(str, input().split()) +c,d = map(int, input().split()) +e = input() +if a == e: + c -= 1 +else: + d -= 1 +print(a,b)" +p02789,s449250875,Accepted,"n,m = map(int,input().split()) +if n-m == 0: + print(""Yes"") +else: + print(""No"")" +p02854,s531015991,Wrong Answer,"n = int(input()) +a = [int(i) for i in input().split()] +b = [] +sum_a = sum(a) +cum = 0 +for i in a: + cum += i + b.append(sum_a - cum) +print(min(b)) +" +p02958,s245258456,Accepted,"n = int(input()) +p = list(map(int,input().split())) +count = 0 +for i in range(n): + if i+1 != p[i]: + count += 1 + +if count <= 2: + print(""YES"") +else: + print(""NO"")" +p04005,s327270949,Accepted,"L = list(map(int, input().split())) + +ans1 = L[0]*L[1]*(L[2]//2-(L[2]-L[2]//2)) +ans2 = L[0]*L[2]*(L[1]//2-(L[1]-L[1]//2)) +ans3 = L[1]*L[2]*(L[0]//2-(L[0]-L[0]//2)) +print(min(abs(ans1), abs(ans2), abs(ans3))) +" +p02797,s155393360,Wrong Answer,"N,K,S=map(int,input().split()) +A=[1]*N +for i in range(K): + A[i]=S +print(*A)" +p02627,s579674223,Accepted,"import re + +chr = input() + + +if re.match(""[a-z]"", chr): + print(""a"") +else: + print(""A"")" +p02723,s040568757,Wrong Answer,"s = input() + +if s[2] == s[3] and s[4] == s[5]: + print(""yes"") +else: + print(""no"")" +p03282,s038493724,Wrong Answer,"s = input() +k = int(input()) +f = True +for si in s: + if si != ""1"": + print(si) + f = False + break +if f: print(""1"") +" +p03565,s239574304,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import re + + +def main(): + S = input() + T = input() + + S = S.replace(""?"", ""."")[::-1] + T = T[::-1] + + for i in range(len(S) - len(T) + 1): + if re.match(S[i:i + len(T)], T): + s = S[:i].replace(""."", ""a"") + T + S[i + len(T):].replace(""."", ""a"") + print(s[::-1]) + break + else: + print(""UNRESTORABLE"") + + +if __name__ == ""__main__"": + main() +" +p03210,s527691750,Accepted,print('YNEOS'[input()not in'357'::2]) +p03417,s079499976,Accepted,"n, m = map(int, input().split()) + +if n == 2 or m == 2: + ans = 0 +elif n == 1 and m == 1: + ans = 1 +elif n == 1 or m == 1: + ans = max(n, m) - 2 +else: + ans = (n - 2)*(m - 2) + +print(ans)" +p03471,s834701678,Wrong Answer,"a,b = map(int,input().split()) +flag = 0 + +for i in range(a): + for j in range(a): + nokori = b - ((i * 1000) + (j * 5000)) + if nokori == 0 and (i+j) == a: + k = 0 + flag = 1 + break + elif nokori%10000 == 0 and nokori >= 0: + k = int(nokori/10000) + if (i+j+k)==a: + flag = 1 + break + + + if flag == 1: + break +if flag == 1: + print(k,j,i) +else: + print(""-1 -1 -1"")" +p02708,s041053761,Wrong Answer,"N,K=map(int, input().split()) +ko = (N-K+1)*K+1 +print('{:.0f}'.format(ko*(ko+1)/2))" +p03998,s671234905,Accepted,"from collections import deque +s = [0,0,0] + +sa = deque(list(input())) +sb = deque(list(input())) +sc = deque(list(input())) + +now = sa.popleft() + +if now == 'a': + d = sa +if now == 'b': + d = sb +if now == 'c': + d = sc + +while True: + if len(d) == 0: + ans = now + break + now = d.popleft() + if now == 'a': + d = sa + if now == 'b': + d = sb + if now == 'c': + d = sc + +print(ans.upper()) +" +p03220,s507932198,Accepted,"n = int(input()) +t, a = map(int, input().split()) +h = list(map(int, input().split())) + +ans = 0 +temp = 1000000000000 + +for i in range(n): + if temp > abs(a*1000-1000*t+h[i]*6): + temp = abs(a*1000-1000*t+h[i]*6) + ans = i+1 + +print(ans)" +p02790,s550526667,Accepted,"a,b = map(int,input().split()) +if a>=b: + ans = [str(n) for n in [b]*a] + print("""".join(ans)) +else: + ans = [str(n) for n in [a]*b] + print("""".join(ans)) +" +p02702,s288962474,Accepted,"S = input() +mod_bucket = [0] * 2019 +mod_bucket[0] = 1 + +_S = S[::-1] +mod = 0 +p = 1 +for i in range(len(S)): + mod = (p * int(_S[i]) + mod) % 2019 + mod_bucket[mod] += 1 + p = p*10%2019 + +ans = sum([mod*(mod-1)/2 for mod in mod_bucket]) +print(int(ans))" +p03261,s232397683,Accepted,"import sys +input = sys.stdin.readline +N = int(input()) +W = [input() for _ in range(N)] + +before = [W[0]] +for i in range(1,N) : + if W[i] in before : + print(""No"") + exit() + if W[i-1][-2] != W[i][0] : + print(""No"") + exit() + before.append(W[i]) + +print(""Yes"") +" +p03103,s674326818,Wrong Answer,"n, m = [int(i) for i in input().split()] +d = sorted({i[0]: i[1] for i in [[int(j) for j in input().split()] for k in range(n)]}.items(), key = lambda x:x[0]) +sm = 0 +i = 0 +for i in d: + if m > i[1]: + sm += i[0] * i[1] + m -= i[1] + else: + sm += i[0] * m + break +print(sm)" +p02552,s183299659,Accepted,"#!python3 + +import sys +iim = lambda: map(int, sys.stdin.readline().rstrip().split()) + +def resolve(): + s = int(input()) + + print([1, 0][s]) + +if __name__ == ""__main__"": + resolve() +" +p02681,s944792437,Accepted,"S = input() +T = input() +if T[0:len(S)] == S: + print(""Yes"") +else: + print(""No"")" +p02744,s478732750,Wrong Answer,"n = int(input()) +if n == 1: + print('a') +elif n == 2: + print('aa\nab') +elif n == 3: + print('aaa\naab\naba\nabb\nabc') +elif n == 4: + print('aaaa\naaab\naaba\naabb\naabc\nabaa\nabab\nabac\nabba\nabbb\nabbc\nabca\nabcb\nabcc\nabcd')" +p02813,s269782185,Wrong Answer,"import itertools +n = int(input()) +P = list(map(int,input().split())) +Q = list(map(int,input().split())) +tmp = list(itertools.permutations(range(1,n+1))) +tmp = sorted(tmp) +ans = [] +for index,t in enumerate(tmp): + if list(t) == P or list(t) == Q : + ans.append(index) + +if len(ans) ==1: + print(*ans) +else: + print(abs(ans[0]-ans[1]))" +p03817,s888185854,Wrong Answer,"x=int(input()) +a=x//11 +b=x%11 +while (a+1)*11<=x: + a+=1 +if b>6: + print(2*a+2) +else: + print(2*a+1)" +p03679,s687239823,Accepted,"def main(): + x,a,b = map(int,input().split()) + now = b - a + if now <= 0: + print(""delicious"") + elif now <= x: + print(""safe"") + else: + print(""dangerous"") + +if __name__ == '__main__': + main() +" +p02724,s571176025,Wrong Answer,"n=int(input()) +c=n//500 +if c!=0: + n-=(c*500) + k=n//5 + print(c*1000+k*5) +else: + print(c*1000) +" +p03486,s387108413,Accepted,"#!/usr/bin/env python3 + +s = sorted(input()) +t = sorted(input(), reverse=True) + +ans = """" +for x,y in zip(s,t): + if x > y: + ans = ""No"" + break + elif y > x: + ans = ""Yes"" + break + +if ans == """": + if len(s) < len(t): + ans = ""Yes"" + else: + ans = ""No"" + +print(ans) + +" +p03721,s519598948,Wrong Answer,"n, k = map(int,input().split()) +x = [] +for _ in range(n): + a,b = map(int,input().split()) + x += [a]*b +print(x[k-1])" +p03797,s094959211,Accepted,"S, C = map(int, input().split()) + +ans = min(S, C // 2) +S -= ans +C -= ans * 2 +if C >= 4: + ans += C // 4 +print(ans)" +p02843,s501600528,Accepted,"x=int(input()) +a=int(x/100) +r=x-a*100 +if r/5<=a: + print(1) +else: + print(0) +" +p02784,s841149563,Wrong Answer,"num = input() +list = list(map(int,input().split())) +list2 = set(list) +print(""No"") if len(list) == len(list2) else print(""Yes"") +" +p02983,s449712602,Wrong Answer,"l, r = map(int, input().split()) +l_2 = l%2019 +r_2 = r%2019 +ans = 2019 +if r_2 - l_2 > 2017: + print(0) +else: + for i in range(l_2,r_2+1): + for j in range(i+1,r_2+1): + print(i,j) + tmp = i*j%2019 + if tmp < ans: + ans = tmp + print(ans)" +p02771,s222862401,Wrong Answer,"abc = input().split("" "") +a = int(abc[0]) +b = int(abc[1]) +c = int(abc[2]) + +d = 0 +if a==b: + d=d+1 +if b==c: + d=d+1 +if c==a: + d=d+1 +if d==1: + print(""yes"") +else: + print(""no"") +" +p02785,s530946753,Accepted,"n, k = map(int, input().split()) +h = list(map(int, input().split())) + +h.sort(reverse=True) +h = h[k:] + +print(sum(h)) +" +p03042,s243679612,Accepted,"S=input() +x=int(S[:2]) +y=int(S[2:]) + +if 0=K: + print(key) + break +if __name__ == '__main__': + main() +" +p03487,s908228506,Wrong Answer,"n = int(input()) +a = sorted(list(map(int, input().split()))) +b = set(a) +count = 0 +l = len(a) +z = 0 +for i in b: + if i > l: + count = l-z + break + else: + j = a.count(i) + if j < i: + count += j + z += j + else: + count += j-i + z += j +print(count)" +p03698,s297151912,Accepted,"import sys +readline = sys.stdin.buffer.readline + +def main(): + S = input() + L = len(S) + s = set(S) + if L == len(s): + ans = 'yes' + else: + ans = 'no' + print(ans) + +if __name__ == '__main__': + main()" +p03127,s805315660,Accepted,"#!/usr/bin/python3 +# -*- coding:utf-8 -*- + +def gcd(a, b): + if a > b: + a, b = b, a + while b % a: + a, b = b % a, a + return a + +def main(): + n = int(input()) + As = list(map(int, input().split())) + As.sort() + min = 10**9 + 1 + num = As[0] + for A in As[1:]: + num = gcd(num, A) + print(num) + +if __name__=='__main__': + main() + +" +p03545,s384778198,Accepted,"abcd=list(input()) +enzanshi=[['+','-'],['+','-'],['+','-']] +for i in range(2**3): + l=[] + for j in range(3): + if (i>>j)&1: + l.append(enzanshi[j][0]) + else: + l.append(enzanshi[j][1]) + + + keisan="""" + for i,j in zip(abcd,l+['']): + keisan+=i+j + + if eval(keisan)==7: + print(keisan + '=7') + break" +p03251,s074129015,Accepted,"n,m,X,Y=map(int,input().split()) +x=list(map(int,input().split())) +y=list(map(int,input().split())) +if min(Y,min(y))-max(X,max(x))>=1: + print(""No War"") +else: + print(""War"")" +p03106,s996335751,Wrong Answer," +a,b,k = map(int,input().split()) +ans = [] + +if a < b: + for i in range(1,a+1): + if a % i == 0: + ans.append(i) +else: + for j in range(1,b+1): + if b % j == 0: + ans.append(j) + +#print(ans) +print(ans[k-1]) +" +p03077,s514873171,Accepted,"#70 C - Five Transportations +N = int(input()) +lis = [int(input()) for _ in range(5)] +mini = min(lis) +group = (N+mini-1)//mini + +ans = 5 + group - 1 +print(ans)" +p02959,s352232889,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +B.append(0) +B.append(0) +ans = 0 +for i in range(len(A)-1): + a = A[i] + b = B[i] + if a > b: + ans += b + else: + ans += a + if A[i + 1] >= b - a: + ans += b - a + A[i + 1] -= b - a + else: + ans += A[i + 1] + A[i + 1] = 0 +print(ans)" +p02848,s136477552,Accepted,"import sys +input = lambda : sys.stdin.readline().rstrip() +sys.setrecursionlimit(max(1000, 10**9)) +write = lambda x: sys.stdout.write(x+""\n"") + + +n = int(input()) +s = input() +ans = """" +for c in s: + ans += chr((ord(c)+n-ord(""A""))%26 + ord(""A"")) +print(ans)" +p02612,s037243950,Accepted,"N = int(input()) +print((1000 - N%1000) % 1000) +" +p02595,s128175904,Accepted,"#-*- coding: utf-8 -*- +import numpy as np + +N, D = map(int, input().split()) +X=[] +Y=[] +for i in range(N): + x, y = map(int, input().split()) + X.append(x) + Y.append(y) + +x=np.array(X) +y=np.array(Y) +distance_calc=(x**2+y**2)**0.5 +cnt=0 +for i in range(len(distance_calc)): + if distance_calc[i]<=D: + cnt+=1 +print(cnt)" +p03624,s461686118,Accepted,"import sys +input = sys.stdin.readline +s = input() + +chrs = [chr(i) for i in range(97, 97+26)] + +for i in chrs: + if i not in s: + print(i) + exit() +print(""None"")" +p02630,s226662127,Wrong Answer,"import numpy as np +N=int(input()) +A=list(map(int,input().split())) +A=sorted(A) +Q=int(input()) +B=[0]*Q;C=[0]*Q +for i in range(Q): + B[i],C[i]=map(int,input().split()) +#print(A) +D=[0]*10**5;W=[0]*10**5 +for i in range(10**5): + D[i]=A.count(i+1) + W[i]=i+1 + +for i in range(Q): + D[C[i]-1]+=D[B[i]-1] + D[B[i]-1]=0 + print(int(np.average(D, weights=W)*10**5*(10**5+1)//2))" +p03481,s193403991,Accepted,"import sys +sys.setrecursionlimit(10 ** 5 + 10) +def input(): return sys.stdin.readline().strip() + +def resolve(): + + x,y=map(int,input().split()) + cnt=0 + while True: + x*=2 + cnt+=1 + if x>y: + break + print(cnt) + + +resolve()" +p03211,s266366193,Wrong Answer,"S = input() +l = [] + +for i in range(len(S) - 2): + a = S[i] + S[i + 1] + S[i + 2] + l.append(a) +ans = int(l[0]) +for j in l: + ans = min(ans, abs(int(j) - 753)) +print(ans)" +p03524,s758645313,Accepted,"s=input() +a=s.count('a') +b=s.count('b') +c=s.count('c') +print('YES' if abs(a-b)<2 and abs(a-c)<2 and abs(c-b)<2 else 'NO')" +p03035,s201596945,Wrong Answer,"a,b = map(int, input().split()) + +if a<5: + print(0) +elif a>=6 & a<13: + print(int(b/2)) +else: + print(int(b))" +p02754,s685631191,Wrong Answer,"n,a,b = map(int,input().split()) +print((a)*n//(a+b) + min(n%(a+b),a))" +p02777,s462435598,Wrong Answer,"s = input().rstrip() +print('x' * len(s))" +p02664,s834286849,Wrong Answer,"t= list(input()) + +for i in range(1, len(t)): + if i == len(t)-1 and t[i] == '?': + t[i] == 'D' + if t[i-1] == 'P' and t[i] == '?': + t[i] = 'D' + elif t[i] == '?' and t[i-1] == 'D': + t[i] = 'P' + +print(''.join(t)) + " +p03323,s369005104,Wrong Answer,"a, b = map(int, input().split()) +print([':(', 'Yay!'][int((a <= 16) & (b <= 8))]) +" +p02628,s507549682,Wrong Answer,"a = list(map(int, input().split())) +p = list(map(int, input().split())) + +N = a[0] +K = a[1] + +p.sort() + +g = sum(p[0:K-1]) +print(g)" +p02748,s097771315,Accepted,"a, b, m = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +ans = min(A) + min(B) + +for _ in range(m): + x, y, c = map(int, input().split()) + t = A[x - 1] + B[y - 1] - c + if t < ans: + ans = t + +print(ans)" +p02993,s143879742,Accepted,"S = list(input()) +pr = 'X' +ans = 'Good' +for s in S: + if pr == s: + ans = 'Bad' + break + pr = s +print(ans)" +p02780,s558240721,Accepted,"n ,k = map(int ,input().split()) +hai = list(map(lambda x:(int(x)+1)/2 ,input().split())) +hait= hai[:k] +ans = tmp = sum(hait) +for i in range(k,n): + tmp = tmp - hai[i-k] + hai[i] + if ans < tmp: + ans = tmp +print(ans)" +p02717,s945095854,Accepted,"x, y, z = map(int, input().split()) + +a = x +x = y +y = a + +a = x +x = z +z = a + +print(x, y, z)" +p03371,s822848639,Wrong Answer,"a, b, c, x, y = map(int, input().split()) + +ans = float('inf') +for i in range(0, 2 * max(x, y)+1, 2): + total = a * (x - (i // 2)) + b *(y - (i // 2)) + c * i + ans = min(ans, total) +print(ans)" +p02639,s819233127,Accepted,"a = list(map(int,input().split())) +count = 1 + +for i in a: + if i == 0: + print(count) + break + count+=1 +" +p02712,s332397315,Accepted,"N = int(input()) +ans = 0 +for i in range(1,N+1): + if i%3 != 0 and i%5 != 0: + ans += i +print(ans)" +p03427,s234877987,Accepted,"n = int(input()) + +l = len(str(n)) +if n < 10: + ans = n +else: + ans1 = 9 * (l-1) + int(str(n)[0]) - 1 + ans2 = sum([int(x) for x in list(str(n))]) + ans = max(ans1, ans2) +print(ans)" +p02725,s847529217,Accepted,"K,N = map(int,input().split()) +A = list(map(int,input().split())) + +dist_max = 0 +for i in range(N-1): + dist_max = max(dist_max,A[i+1]-A[i]) +dist_max = max(dist_max,K-A[N-1]+A[0]) + +print(K-dist_max) +" +p03962,s324698464,Wrong Answer,"list = (input().split()) + +A=set(list) + +print(A)" +p03455,s172101033,Accepted,"a, b = map(int, input().split()) +if a * b % 2 == 0: + print('Even') +else: + print('Odd')" +p02693,s138201897,Accepted,"k = int(input()) +a, b = [int(i) for i in input().split()] + +i = k +while(i < a): + #print(i) + i += k +#print(i) +if i <= b: + print('OK') +else: + print('NG')" +p03796,s525708697,Accepted,"n = int(input()) +ans = 1 +mod = 10**9+7 +for i in range(1,n+1): + ans *= i + ans %= mod + +print(ans)" +p02785,s989296766,Accepted,"N, K = map(int, input().split()) +H = list(map(int, input().split())) + +if N <= K: + print(0) +else: + H.sort(reverse=True) + del H[:K] + print(sum(H))" +p04005,s515665275,Wrong Answer,"a, b, c = map(int, input().split()) +if a % 2 == 0 or b % 2 == 0 or c % 2 == 0: + print(0) +else: + d = [a, b, c] + d.sort() + print(a * b) +" +p03493,s745087510,Accepted,"print(input().count(""1""))" +p03633,s576634126,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Fri May 29 21:29:28 2020 + +@author: naoki +"""""" +import fractions + +N = int(input()) # 時計の個数 +T = [int(input()) for i in range(N)] # 時計の針が一周する時間 +T.sort() # 小さい順番にソートする +lcm = T[0] + +for i in range(1,N): + lcm = lcm*T[i]// fractions.gcd(lcm,T[i]) +print(lcm) + +" +p03437,s147669132,Wrong Answer,"X, Y = map(int, input().split()) +print(-1 if Y % X == 0 else X) +" +p02879,s917825052,Accepted,"A, B = map(int, input().split()) +print(A*B) if (A<=9) & (B<=9) else print(-1)" +p03041,s780286177,Wrong Answer,"a,b=input().split() +a=int(a) +b=int(b) +c=input() +h,i,j=c[:(a-2)],c[a-2],c[a-1:] +if i==""A"": + i=""a"" +if i==""B"": + i=""b"" +if i==""C"": + i=""c"" +print(h+i+j)" +p03457,s869802340,Accepted,"N = int(input()) +t = [0] * (N + 1) +x = [0] * (N + 1) +y = [0] * (N + 1) +for i in range(N): + t[i + 1], x[i + 1], y[i + 1] = map(int, input().split()) + +for i in range(N): + dt = t[i + 1] - t[i] + dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) + if dt < dist: + print(""No"") + exit(0) + + if dist % 2 != dt % 2: + print(""No"") + exit(0) + +print(""Yes"")" +p02661,s288863530,Wrong Answer,"N=int(input()) + +min_x=[] +max_x=[] +for _ in range(N): + A,B=map(int,input().split()) + min_x.append(A) + max_x.append(B) + +if N%2==0: + center=N//2 + min_tmp=(min_x[center]+min_x[center-1]) + max_tmp=(max_x[center]+max_x[center-1]) + print(max_tmp-min_tmp+1) +else: + center=N//2 + print(max_x[center]-min_x[center]+1)" +p03607,s303059255,Wrong Answer,"n = int(input().strip()) +a = [int(input().strip()) for _ in range(n)] +a.sort() +ans = 0 +for i in range(len(a) - 1): + if a[i + 1] == a[i]: + ans += 1 +print(ans) +" +p04020,s593137836,Accepted,"N=int(input()) +A=[0] +for i in range(1,N+1): + A.append(int(input())) + +ans=0 +i=1 +while i<=N: + # print(i) + # print(A[1:]) + if A[i]>=2: + ans+=A[i]//2 + A[i]%=2 + # print(A[1:]) + if i=1: + ans+=1 + A[i]-=1 + A[i+1]-=1 + # print(A[1:]) + # print(ans) + i+=1 + +print(ans) +" +p02576,s774782173,Wrong Answer,"l = list(map(int,input().split())) +a=l[0] +b=l[1] +c=l[2] +d=b//c +if(b==1): + print(a*c) +else: + x=abs(a-b) + if(x>c): + print(c+c) + else: + print(c+x)" +p02553,s458291697,Wrong Answer,"a,b,c,d = map(int, input().split()) +x = a +y = c +max = x * y +if b <= 0: + print(max) +else: + for x in range(a,b + 1): + for y in range(c,d + 1): + if x * y > max: + max = x * y + print(max)" +p03327,s486584958,Wrong Answer,"N = int(input()) + +if N >= 1: + print('ABC') +elif N <= 999: + print('ABC') +if N >= 1000: + print('ABD') +elif N <= 1998: + print('ABD')" +p02577,s339970193,Wrong Answer,"import sys +li = lambda : [int(x) for x in sys.stdin.readline().strip().split()] +rw = lambda : sys.stdin.readline().strip().split() +ni = lambda : int(sys.stdin.readline().strip()) +nsi = lambda : sys.stdin.readline().strip() + +from collections import defaultdict as df +import math +s=input() +sum=0 +for i in s: + sum+=int(i) + +if(sum%9==0): + print(""YES"") +else: + print(""NO"") +" +p03479,s871080510,Accepted,"# -*- coding: utf-8 -*- +x,y = map(int, input().split()) +cnt = 0 +b = 1 +while x*b<=y: + cnt += 1 + b *= 2 + +print(cnt)" +p02860,s885693111,Accepted,"N = int(input()) +S=input() + +if N%2==0 and all(a==b for a,b in zip(S,S[N//2:])): + print(""Yes"") +else: + print(""No"") + +" +p03835,s644291990,Accepted,"k,s = map(int,input().split()) +ans = 0 +for i in range(k+1): + for j in range(k+1): + ans += (1 if 0 <= s-i-j <= k else 0) +print(ans)" +p02645,s821650990,Wrong Answer,"n = input() +print(n[:2])" +p02615,s349975936,Accepted,"N = int(input()) +A = list(map(int,input().split())) +A.sort(reverse=True) +if N%2==1: + #print(A[0]) + #print(A[1:N//2]) + #print(A[N//2]) + print(A[0] + sum(A[1:N//2])*2 + A[N//2]) +else: + print(A[0] + sum(A[1:N//2])*2)" +p02924,s793605938,Wrong Answer,"import math + +n = int(input()) + +_sum = int(n / 2) * (n + 1) + +print(_sum - n)" +p02862,s157208127,Wrong Answer,"X,Y=map(int,input().split()) +s=(2*X-Y)/3 +t=(2*Y-X)/3 +mod=(10**9)+7 +if s!=int(s) or t!=int(t): + print(0) + exit() +s=int(s) +t=int(t) +up=1 +d=1 +for i in range(s+t,max(s,t),-1):#a!/b!c!(a=b+c)がやりたい + up=(up*i)%mod +for i in range(1,min(s,t)+1): + d=(d*i)%mod +d=pow(d,mod-2,mod) +print((up*d)%mod)" +p03329,s743602761,Accepted,"# 配るDP + +n = int(input()) + + +max_n = 110000 +dp = [n] * max_n + +# 初期化 +dp[0] = 0 + +for i in range(n): + pow6, pow9 = 1, 1 + while i + pow6 <= n: + dp[i + pow6] = min(dp[i + pow6], dp[i] + 1) + pow6 *= 6 + while i + pow9 <= n: + dp[i + pow9] = min(dp[i + pow9], dp[i] + 1) + pow9 *= 9 +print(dp[n]) +" +p02683,s330866203,Accepted,"import sys +def input(): return sys.stdin.readline().strip() +N, M, X = map(int, input().split()) +li = [list(map(int, input().split())) for _ in range(N)] +ans = 10 ** 10 +for i in range(2 ** N): + p = [0] * M + sum = 0 + for j in range(N): + if ((i >> j) & 1): + sum += li[j][0] + for k in range(M): + p[k] += li[j][k + 1] + if all(x >= X for x in p): + ans = min(sum, ans) + +print(ans if ans != 10 ** 10 else -1)" +p02701,s158189339,Accepted,"d={} +for i in range(int(input())): + s=input() + d[s]=d.get(s,0)+1 +print(len(d)) +" +p02754,s721195558,Wrong Answer,"def main(): + N,A,B=map(int,input().split()) + count=(N//(A+B)) + if (A+B)*10**100 <= N: + print(A*10**100) + return 0 + ans=count*A + if A>=N-(A+B)*count: + ans+=(N-(A+B)*count) + print(ans) + else: + print(ans) +main()" +p03457,s800319597,Accepted,"n=int(input()) +txy=[list(map(int,input().split())) for _ in range(n)] +u,v,w=0,0,0 +for t,x,y in txy: + p=t-u + q=abs(v-x)+abs(w-y) + if pmax_: + max_=f(a) + ans=a +print(ans)" +p02784,s958535894,Accepted,"#Common Raccoon vs Monster +H, N = map(int,input().split()) +A = list(map(int,input().split())) + +if sum(A) >= H: + print(""Yes"") +else: + print(""No"")" +p02683,s279584700,Accepted,"n,m,x = map(int,input().split()) +ls = [list(map(int,input().split())) for i in range(n)] +ans = 10**18 +for i in range(2**n): + uds = [0]*m + cost = 0 + for j in range(n): + if i&1<= x: + ans = min(ans,cost) +if ans == 10**18: + print(-1) +else: + print(ans)" +p03767,s380623243,Accepted,"n=int(input());print(sum(sorted(map(int,input().split()))[n::2]))" +p02801,s114920179,Accepted,print(chr(ord(input()) + 1)) +p03386,s773623400,Wrong Answer,"a,b,k = map(int,input().split()) +ans = set() +for i in range(k): + if b>a+i: ans.add(a+i) +for i in range(k-1,-1,-1): + if a X: + tmp = A[i] + A[i+1] - X + ret += tmp + A[i+1] -= min(A[i+1], tmp) + + +print(ret) + +" +p02947,s692301106,Wrong Answer,"n=int(input()) +l=[] +for i in range(n): + s=input() + s=sorted(s) + s="""".join(s) + l.append(s) + +l.sort() +cnt=0 +tmp=0 + +for i in range(1,len(l)): + if l[i]==l[i-1]: + tmp += 1 + else: + cnt += tmp+1*(tmp)//2 + tmp=0 +cnt += tmp+1*(tmp)//2 +print(cnt) + " +p02694,s717956005,Accepted,"X = int(input()) + +count = 0 +num = 100 +while num < X: + num = int(num * 1.01) + count += 1 +print(count) +" +p02694,s275547401,Accepted,"def resolve(): + x = int(input()) + ans = 0 + money = 100 + while money < x: + money *= 1.01 + money = int(money) + ans += 1 + print(ans) +resolve()" +p03041,s258394608,Wrong Answer,"n,k=tuple(map(int,input().split())) +print(n,k) +s=list(input()) +s[k-1]=s[k-1].lower() +print("""".join(s))" +p02792,s786691765,Accepted,"N = int(input()) + +g = [[0] * (10) for _ in range(10)] +for i in range(1, N + 1): + a = int(str(i)[0]) + b = int(str(i)[-1]) + g[a][b] += 1 +ans = 0 +for i in range(1, 10): + for j in range(1, 10): + ans += g[i][j]*g[j][i] + +print(ans)" +p02818,s093964778,Accepted,"a, b, k = map(int, input().split()) + +if k >= a + b: + print(0, 0) + +elif a <= k < a + b: + print(0, a + b - k) + +else: + print(a - k, b)" +p02613,s158605823,Accepted,"import sys +input = sys.stdin.readline + +N = int(input()) +dic = {""AC"": 0, ""WA"": 0, ""TLE"": 0, ""RE"": 0} +for i in range(N): + dic[input().rstrip('\n')] += 1 +for k, v in dic.items(): + print(k, 'x', v) +" +p02995,s117051302,Wrong Answer,"from fractions import gcd +from math import ceil +a,b,c,d = map(int, input().split()) + +nums = b-a+1 +t1 = ceil(b/c - a/c) +t2 = ceil(b/d - a/d) + +lcm = (c*d)//gcd(c,d) +t3 = b//lcm - a//lcm +print(nums-t1-t2+t3)" +p02699,s349517302,Wrong Answer,"a = input().split() +s = int(a[0]) +w = int(a[1]) + +if w <= s: + print('safe') +else: + print('unsafe') +" +p03455,s437772309,Wrong Answer,"a, b = map(int, input().split()) + +if 1 < a and a < 10000 and 1 < b and b < 10000: + if (a * b) % 2 == 1: + print('Odd') + if (a * b) % 2 == 0: + print('Even') +" +p03038,s745516055,Accepted,"from operator import itemgetter +n,m=map(int,input().split()) +A=list(map(int,input().split())) +B=[list(map(int,input().split())) for _ in range(m)] +B.sort(key=itemgetter(1),reverse=True) +C=[] +for b,c in B: + C+=[c]*b + if len(C)>=n:break +print(sum(sorted(A+C)[-n:]))" +p02829,s335199323,Wrong Answer,"A=int(input()) +B=int(input()) +L=[1,2,3] +L.remove(A) +L.remove(B) +print(L) +" +p03206,s820771487,Wrong Answer," +D = int(input()) + +print(""christmas""+"" Eve""*(25-D)) +" +p03448,s187091105,Accepted,"A=int(input()) +B=int(input()) +C=int(input()) +X=int(input()) +count=0 +for a in range(A+1): + for b in range(B+1): + for c in range(C+1): + if ((500*a)+(100*b)+(50*c))==X: + count+=1 +print(count)" +p03494,s750003297,Accepted,"input() +A = list(map(int, input().split())) +count = 0 +while all(a % 2 == 0 for a in A): + A = [a/2 for a in A] + count += 1 +print(count)" +p03838,s317383925,Accepted,"x, y = map(int, input().split()) +if abs(y) > abs(x): + if (x >= 0 and y > 0): + print(abs(y - x)) + elif x * y <= 0: + print(abs(y) - abs(x) + 1) + else: + print(abs(y) - abs(x) + 2) +else: + if x > 0 and y > 0: + print(x - y + 2) + elif x * y < 0 or (y == 0 and x > 0): + print(abs(x) - abs(y) + 1) + else: + print(abs(x - y))" +p02842,s422994353,Accepted," +X = int(input()) + +if X % 1.08 == 0: + print(int(X//1.08)) +else: + if int((int(X//1.08)+1) * 1.08) == X: + print(int(X//1.08+1)) + else: + print("":("")" +p02994,s283673828,Wrong Answer,"import numpy as np +N,L = map(int,input().split()) +L_list=np.array(range(1,N+1))+L-1 +print(sum(L_list)) +if (0 in L_list): + print(sum(L_list)) + exit() +if(N<=abs(L) and L<0): + print(sum(L_list)-L_list[N-1]) + + exit() +else: + print(sum(L_list)-L_list[0]) + exit()" +p02582,s525427899,Wrong Answer,"N=input() +if N==""RRR"": + print(3) +elif N==""SRR"" or N==""RSR"" or N==""RRS"": + print(2) +elif N==""SSR"" or N==""SRS"" or N==""RSS"": + print(1) +else: + print(0)" +p02765,s110969798,Accepted,"n,r = map(int,input().split()) +ans = 0 +if n>10: + ans = r +else: + ans = r+100*(10-n) +print(ans)" +p03723,s354482062,Wrong Answer,"A, B, C = map(int,input().split()) + +if A == B == C == 1: + print(0) + +elif A == B == C: + print(-1) + exit() + +LA = [] +LB = [] +LC = [] +LA.append(A) +LB.append(B) +LC.append(C) +i = 0 +cnt = 0 + +while LA[i] % 2 == 0 and LB[i] % 2 == 0 and LC[i] % 2 == 0: + LA.append((LB[i]+LC[i])/2) + LB.append((LC[i]+LA[i])/2) + LC.append((LA[i]+LB[i])/2) + i += 1 + cnt += 1 + +print(cnt) +" +p03493,s997850549,Accepted,"# ABC 081: A – Placing Marbles +n = input() +print(n.count('1'))" +p03548,s908844284,Accepted,"x,y,z=map(int,input().split()) +print((x-z)//(y+z))" +p02952,s332813274,Accepted,"N = int(input()) +count = 0 +for i in range(1,N+1): + if i<10 or 100<=i<1000 or 10000<=i<100000: + count += 1 + +print(count)" +p02623,s969903496,Wrong Answer,"N,M,K = list(map(int, input().split())) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +A.append(10**9+7) +B.append(10**9+7) +ans = 0 + +while True: + if A[0] > B[0]: + K = K- B[0] + B = B[1:] + ans +=1 + else: + K = K-A[0] + A = A[1:] + ans +=1 + if K <0: + break +print(ans-1)" +p02779,s665039832,Accepted,"n = int(input()) +a = input().split() +s = set() + +dup = False +for i in a: + if i in s: + dup = True + else: + s.add(i) + +if dup: + print(""NO"") +else: + print(""YES"") +" +p02613,s794793511,Wrong Answer,"N=map(int,input().split()) +S=list(map(str,input().split())) + +AC=S.count('AC') +WA=S.count('WA') +TLE=S.count('TLE') +RE=S.count('RE') + +print(""AC × "", end='') +print(AC) +print(""WA × "", end='') +print(WA) +print(""TLE × "", end='') +print(TLE) +print(""RE × "", end='') +print(RE)" +p03017,s463070468,Wrong Answer,"import sys +n, a, b, c, d = map(int, input().split()) +s = input() +for i in range(a+1, c-1): + if s[i-1]==s[i]=='#': + print('No') + sys.exit() +for i in range(b+1, d-1): + if s[i-1]==s[i]=='#': + print('No') + sys.exit() +if c cnt[-1][1] + 1: + print('NO') +else: + print('YES') +" +p03986,s940031923,Accepted,"from itertools import groupby as gb +l=[(a,len(list(b))) for a,b in gb(list(input()))] +ans=0 +now=0 +if l[0][0]==""T"": + ans+=l[0][1] + now+=1 +pres=0 +for (k,x),(k1,y) in zip(l[now::2],l[now+1::2]): + #print(ans,pres) + if x+pres>=y:pres=(x+pres-y) + else: + ans+=y-x-pres + pres=0 +print(ans+pres+(0 if l[-1][0]==""T"" else l[-1][1]))" +p02688,s723844450,Wrong Answer,"n, k = map(int, input().split()) +ss = set() + +for i in range(1, k*2+1): + if i%2==1: + pass + else: + for s_i in map(int, input().split()): + ss.add(s_i) +print(len([s for s in range(1, n+1) if s not in ss])) +" +p02613,s624858228,Accepted,"N = int(input()) +S = [] +for _ in range(N): S.append(input()) + +print('AC x', S.count('AC')) +print('WA x', S.count('WA')) +print('TLE x', S.count('TLE')) +print('RE x', S.count('RE')) +" +p03206,s882542573,Accepted,"D = int(input()) +ans = "" "".join([""Christmas""] + [""Eve""] * (25 - D)) +print(ans) +" +p03637,s011560727,Accepted,"N = int(input()) +A = list(map(int,input().split())) +four = 0 +two = 0 +one = 0 +for e in A: + if e%4 == 0: + four += 1 + elif e %2 == 0: + two += 1 + else: + one += 1 + +if two == 0: + if one <= four + 1: + print('Yes') + else: + print('No') +else: + if one <= four: + print('Yes') + else: + print('No') +" +p03495,s602030185,Accepted,"from collections import Counter +import sys + +N, K = map(int, input().split()) +A = list(input().split()) +ball = [int(A[i]) for i in range(N)] +kinds = len(set(ball)) +Cou = list(Counter(ball).most_common()) +dele = [int(Cou[i][1]) for i in range(len(Cou) - kinds + K, len(Cou))] +print(sum(dele)) +" +p02713,s560290546,Wrong Answer,"import math + +K = int(input()) + +sum = 0 +for a in range(1, K+1) : + for b in range(1 , K+1) : + tmp = math.gcd(a, b) + for c in range(1 , K+1) : + sum = sum + math.gcd(a, tmp) + +print(sum) +" +p02866,s133669639,Wrong Answer,"n = int(input()) +d = list(map(int, input().split())) + +l = [0]*(max(d)+1) +for i in d: + l[i] += 1 + +if l[0] != 1: + print(0) + exit() + +ans = 1 +for i in range(1, len(l)): + ans *= l[i-1]**l[i] + +print(ans%998244353*min(l))" +p03037,s804783420,Accepted,"from itertools import accumulate +N, M = map(int, input().split()) + +# left = 1 +# right = N +# +# for i in range(M): +# a,b = map(int, input().split()) +# left = max(left,a) +# right = min(right, b) +# +# print(max(0,right-left+1)) + +imos = [0] * (N + 2) +for i in range(M): + l, r = map(int, input().split()) + imos[l] += 1 + imos[r + 1] -= 1 + +imos = list(accumulate(imos)) + +ans = 0 +for im in imos: + ans += (im == M) + +print(ans) +" +p03625,s365422929,Accepted,"from collections import Counter as C + +_ = input() +a = C([int(x) for x in input().split()]) + +b = [0] * 2 +for k, v in a.items(): + b.extend([k] * (v // 2)) +else: + b.sort() + print(b[-1] * b[-2])" +p02546,s279899111,Accepted,"s=input() +ss=list(s) +if ss[len(ss)-1] == ""s"": + print(s+""es"") +else: + print(s+""s"")" +p03241,s486413131,Accepted,"n, m = map(int, input().split()) + +divisors = [] +for i in range(1, int(m**0.5)+1): + if m % i == 0: + divisors.append(i) + if i != m // i: + divisors.append(m // i) +divisors.sort() + +print([i for i in divisors if i <= m/n][-1]) +" +p03038,s999875685,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +magic = [list(map(int, input().split())) for _ in range(M)] +magic = sorted(magic, key=lambda x: -x[1]) + +hold = [] +now = 0 +for k, v in magic: + hold.extend([v]*k) + now += k + if now >= N: + break +A.extend(hold) +A.sort(reverse=True) +print(sum(A[:N])) +" +p02761,s050838488,Wrong Answer,"n, m=map(int, input().split()) +a = [-1]*n +ans = 0 +for i in range(m): + s, c = map(int, input().split()) + if a[s-1]!=c and a[s-1]!=-1: + ans = -1 + break + elif n>1 and s==1 and c==0: + ans = -1 + break + else: + a[s-1]=c +if ans == 0: + if a[0]==-1: + a[0]=1 + for i in range(n): + if a[n-1-i] != -1: + ans += a[n-1-i]*10**i +print(ans)" +p03545,s972736852,Wrong Answer,"X = str(input()) + +# 文字列を4つのintに分裂 +# 二分検索でヒットしたらタス、そうでなければ引く、listに履歴を残しておく + +for i in range(2**3): + ans = int(X[0]) + list = [] + for j in range(3): + if (i>>j & 1) == 1: + ans += int(X[j+1]) + list.append(""+"") + else: + ans -= int(X[j+1]) + list.append(""-"") + if ans == 7: + break + +ans = X[0] +for i in range(3): + ans += list[i] + ans += X[i+1] +print(ans)" +p02661,s356181315,Accepted,"def e_count_median(): + N = int(input()) + Min, Max = [], [] + for _ in range(N): + a, b = [int(i) for i in input().split()] + Min.append(a) + Max.append(b) + Min.sort() + Max.sort() + + mid = N // 2 + median_min, median_max = ((Min[mid], Max[mid]) if N % 2 == 1 + else (Min[mid] + Min[mid - 1], Max[mid] + Max[mid - 1])) + return median_max - median_min + 1 + +print(e_count_median())" +p02628,s966599152,Wrong Answer,"A1, A2 = map(int, input().split()) +B = list(map(int,input().split())) + +B.sort() +num = 0 + +for i in range(A2): + num = B[i] + +print(num) + +" +p02576,s344476691,Wrong Answer,"N, X, T = map(int,input().split()) +int((N/X)*T)" +p02690,s028248114,Wrong Answer,"X = int(input()) +x = 1 +while ((x-1)**2)*9 < X: + x += 1 +for i in range(x): + for j in range(-x, i): + if i**5-j**5 == X: + a = [i,j] + print(*a)" +p02747,s085678957,Accepted,"s=input() +n=len(s) +if n%2==1: + print('No') +else: + fail=0 + for i in range(n): + if (s[i]!='h' and i%2==0) or (s[i]!='i' and i%2==1): + fail=1 + if fail==0: + print('Yes') + else: + print('No')" +p02899,s578221704,Wrong Answer,"n=int(input()) +l=list(map(int,input().split())) +s=list(range(n)) +s.sort(key=lambda i: l[i]) +newl="""" +for i in range(n): + newl+=str(s[i]+1) + """" +print(*newl) + +" +p03086,s707297607,Wrong Answer,"s=list(input()) +n=len(s) +ans=[] +for i in range(n-1): + for j in range(i+1,n+1): + part=set(s[i:j]) + flag=True + for p in part: + if p not in list('ATGC'): + flag=False + break + if flag==True: + ans.append(len(s[i:j])) +#print(ans) +if ans: + print(max(ans)) +else: + print(0)" +p02755,s802670406,Accepted,"import math +A,B = map(int,input().split()) + +ans = """" +for i in range(1,1251): + a = math.floor(i * 0.08) + b = math.floor(i * 0.1) + if a == A and b == B: + ans = i + break + +print(ans if ans != """" else -1)" +p02696,s556335099,Wrong Answer,"a, b, n = map(int, input().split()) +ans = 0 +for i in range(n, max(0, n-b), -1): + ans = max(ans, int(a * i / b) - (a * int(i / b))) +print(ans)" +p02647,s627951355,Wrong Answer,"def add_1(n): + return n + 1 + +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) + +for n_chg in range(k): + n_light = [0] * n + for i in range(n): + print(n_light) + print('i: {}, a[i]:{}\n'.format(i,a[i])) + for j in range(max(i-a[i],0), min(i+a[i],n-1) + 1): + n_light[j] += 1 + # n_light[max(i-a[i],0):min(i+a[i],n-1)] += 1 + a = n_light + print('-------------\n') + +print(a) +" +p03698,s970431942,Accepted,"s=list(input()) +li=[] +non=False +for c in s: + if c in li: + non=True + break + li.append(c) + +if non: + print(""no"") + +else: + print(""yes"")" +p02755,s743856739,Accepted,"from math import floor +A, B = map(int, input().split()) + +def check(x): + if floor(x*0.08) == A and floor(x*0.1) == B: + return True + return False + +x = 1 +while(x < 1251): + if check(x): + break + x += 1 + +if x == 1251: + print(-1) +else: + print(x)" +p02793,s747576343,Wrong Answer,"import numpy as np +from fractions import gcd +from functools import reduce + +def lcm_base(x, y): + return (x * y) // gcd(x, y) + +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +input() +nums = np.array(list(map(int, input().split())), dtype=np.int64) + +total = 0 +for num in lcm_list(nums) / nums: + total += int(num) % (10**9 + 7) + total %= (10**9 + 7) +print(total)" +p03759,s450666600,Accepted,"a,b,c = map(int,input().split()) +if 2*b == a + c: + print(""YES"") +else: + print(""NO"")" +p03329,s216317044,Accepted,"# thought greedy was better i am noob +# classical problem no explanation needed +def main(): + n = int(input()) + dp = [0 for i in range(n+4)] + dp[0]=0 + for i in range(1, n+2): + p = 1 + dp[i]=1000000000000000 + while i>=p: + dp[i]=min(dp[i] , dp[i-p]+1) + p =p*9 + p=1 + while i>=p: + dp[i]=min(dp[i] , dp[i-p]+1) + p = p*6 + print(dp[n]) +if __name__==""__main__"": + main()" +p02768,s955576045,Accepted,"def comb_mod(n, k, p): + """""" + nCk mod p + """""" + numerator = 1 + denominator = 1 + for i in range(k): + numerator *= n - i + numerator %= p + denominator *= i + 1 + denominator %= p + return numerator * pow(denominator, p-2, p) % p + +mod = 10**9 + 7 +n, a, b = map(int, input().split()) +result = pow(2, n, mod) - 1 + +for i in (a, b): + result -= comb_mod(n, i, mod) +result %= mod + +print(result)" +p02717,s540829649,Wrong Answer,"array = list(map(int, input().split())) +tmp = array[0] +array[0] = abs(array[0] - array[1]) +while (tmp >= array[0]): + tmp = array[0] + array[0] = abs(array[0] - array[1]) +print(tmp) +" +p03679,s219913432,Accepted,"X, A, B = map(int, input().split()) + +if B <= A: + print(""delicious"") +elif B <= (X + A): + print(""safe"") +elif B >= (X + A + 1): + print(""dangerous"") +" +p02627,s110748094,Accepted,"a=input() + +if a==a.upper(): + print(""A"") +else: + print(""a"")" +p02677,s313691866,Accepted,"import math +A,B,H,M = map(int,input().split()) + +edge = max(30*H+0.5*M,6*M) - min(30*H+0.5*M,6*M) +C = math.cos(math.radians(edge)) +ans = math.sqrt(pow(A,2) + pow(B,2) - 2 * A * B * C) +print(ans)" +p03150,s312690808,Accepted,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(10 ** 7) + +s = input().strip() + +target = 'keyence' + +if target in s: + print('YES') + sys.exit(0) + +for start in range(len(s)): + for end in range(start + 1, len(s) + 1): + copy_s = list(s) + copy_s[start:end] = '' + if ''.join(copy_s) == target: + print('YES') + sys.exit(0) +print('NO') +" +p03555,s771899358,Wrong Answer," + +import numpy as np + +s=[input() for k in range(2)] +for i in range(3): + if(s[0][i]!=s[1][2-i]): + print(""No"") + exit(0) +print(""Yes"")" +p03862,s031540819,Accepted,"N, x = map(int, input().split()) +arr = list(map(int, input().split())) +ans = 0 +for i in range(N-1): + if arr[i] + arr[i+1] >= x: + tmp = arr[i] + arr[i+1] - x + if arr[i+1] >= tmp: + arr[i+1] -= tmp + else: + arr[i+1] = 0 + ans += tmp +print(ans)" +p03821,s263838419,Accepted,"n=int(input()) +A=[] +B=[] +for i in range(n): + x,y=map(int,input().split()) + A.append(x) + B.append(y) +A.reverse() +B.reverse() +ans=0 + +for i in range(n): + if (A[i]+ans)%B[i]!=0: + ans+=B[i]-(A[i]+ans)%B[i] +print(ans)" +p03095,s788123764,Accepted,"n = int(input()) +s = input() +ans = 1 +for x in set(s): + ans *= s.count(x)+1 +print((ans-1)%(10**9+7))" +p02817,s738128804,Wrong Answer,"# A - Strings + +S, T = map(str, input().split()) +print(S + T) +" +p03438,s844979850,Accepted,"(n,),a,b=[[*map(int, i.split())]for i in open(0)] +print(""YNeos""[sum(j - i if i > j else (j-i)//2 for i, j in zip(a,b))<0::2]) +" +p02842,s270450622,Accepted,"n = int(input()) + +if n/1.08==n//1.08: + print(n//1.08) +elif int(-(-n//1.08) * 1.08) == n: + print(int(-(-n//1.08))) +else: + print(':(')" +p03455,s482560287,Wrong Answer,"a,b = map(int,input().split()) +if (a*b % 2 == 0): + print(""Even"") +else: + print(""0dd"")" +p02923,s895846600,Accepted,"N = int(input()) +*H, = map(int, input().split()) + +max = 0 +temp = 0 + +for h_index in range(0, len(H)-1, 1): + if H[h_index]>=H[h_index+1]: + temp = temp + 1 + continue + if max < temp: + max = temp + temp = 0 +if max < temp: + max = temp + +print(max)" +p04030,s786256726,Wrong Answer,"from sys import exit +s = input() + +ans="""" +for i in range(len(s)): + if s[i] == ""0"": + ans = ""0"" + ans + elif s[i] == ""1"": + ans += ""1"" + else: + if len(ans) != 0 : + ans = ans[:-1] + +print(ans)" +p04030,s767017255,Wrong Answer,"s=list(input()) +res=[] +for i in s: + if i==""b"": + res=res[:-1] + else: + res.append(i) +res="""".join(res) +print(res)" +p02678,s621940623,Wrong Answer,"def main(): + + n, m = map(int, input().split()) + + import numpy as np + import scipy.sparse as sp + ab = [list(map(int, input().split())) for _ in [0]*m] + g = [[] for _ in [0]*n] + [g[a-1].append(b-1) for a, b in ab] + [g[b-1].append(a-1) for a, b in ab] + + data = [1 for a, b in ab] + row = [a-1 for a, b in ab] + col = [b-1 for a, b in ab] + matrix = sp.csr_matrix((data, (row, col)), shape=(n, n), dtype=np.int32) + d = sp.csgraph.dijkstra(matrix, indices=0) + + +main() +" +p02699,s604489728,Accepted,"n_sheep ,n_wolves = input().split() +n_sheep , n_wolves = int(n_sheep),int(n_wolves) + +if n_sheep > n_wolves: + print('safe') +else: + print('unsafe') +" +p03720,s978106230,Accepted,"n, m = map(int, input().split()) +connections = [input().split() for _ in range(m)] + +for i in range(1, n+1): + print(sum(c.count(str(i)) for c in connections)) +" +p02792,s110110631,Wrong Answer,"n = int(input()) +i = 1 +j = 1 +ans = 0 +while i <= n: + a = list(str(i)) + while j <= i: + b = list(str(j)) + if a[0] == b[-1] and a[-1] == b[0]: + ans += 1 + j += 1 + i += 1 +print((ans-8)**2 + 8)" +p03012,s607565901,Accepted,"n = int(input()) +W = list(map(int, input().split())) +ans = 1e5 +for i in range(n - 1): + ans = min(ans, abs(sum(W[:i + 1]) - sum(W[i + 1:]))) +print(ans)" +p04034,s397833338,Accepted,"N, M = list(map(int, input().split())) +boxes = [1] * N +boxes_status = [False] * N +boxes_status[0] = True + +for i in range(M): + x, y = list(map(int, input().split())) + x -= 1 + y -= 1 + if boxes_status[x]: + if boxes[x] == 1: + boxes_status[x] = False + boxes_status[y] = True + boxes[x] -= 1 + boxes[y] += 1 + +print(boxes_status.count(True))" +p03827,s169428084,Wrong Answer,"N=int(input()) +S=input() +x=0 +for i in S: + if i==""I"": + x+=1 + elif i==""D"": + x-=1 +print(x)" +p02577,s782416811,Wrong Answer,"n=int(input()) +print('Yneos'[(n%9!=0)::2])" +p02661,s217585305,Wrong Answer,"N = int(input()) +import numpy as np +A = [0]*N +B = [0]*N +for i in range(N): + A[i], B[i] = map(int,input().split()) +na = np.median(A) +nb = np.median(B) +if N%2 == 1: + ans = int(nb - na + 1) + print(ans) + exit() +else: + ans = 2*int(nb - na) + 1 + print(ans) + exit() +" +p03951,s593366176,Accepted,"n = int(input()) +a, b = [input() for i in range(2)] +for i in range(n+1): + if a[i:] == b[:n-i]: + print(i + n) + break" +p04011,s130392871,Accepted,"n,k,x,y = map(int, open(0)) +print(n*x - (x-y)*max(n-k, 0))" +p03219,s822199858,Wrong Answer,"X, Y = map(int, input().split()) +print((X+Y)/2)" +p03494,s418684354,Accepted,"n = input() +A = list(map(int, input().split())) +ans = 0 +while not any (a%2 for a in A): + ans+=1 + A = [a/2 for a in A] +print(ans)" +p04044,s564788652,Accepted,"n,l = map(int,input().split()) +print(''.join(sorted([input() for i in range(n)])))" +p03416,s441728096,Accepted,"import sys +input = sys.stdin.readline +A, B = [int(x) for x in input().split()] +import numpy as np +a = np.arange(A, B + 1) +a = np.array(a, np.object) +ans = 0 +for i in a: + i = str(i) + if i[0] == i[4] and i[1] == i[3]: + ans += 1 +print(ans)" +p02678,s551514342,Accepted,"from collections import deque +n,m = map(int, input().split()) + + +graph = [[] for _ in range(n+1)] +for i in range (m): + a, b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +#print(graph) + +dist = [-1]*2 + [0 for i in range (n-1)] + +d = deque([1]) +#print(d) + +while d: + v = d.popleft() + for i in graph[v]: + if dist[i] == 0: + dist[i] = v + d.append(i) + +print(""Yes"") +ans = dist[2:] +print(*ans, sep=""\n"")" +p02708,s720428810,Wrong Answer,"mod=100000007 +n,k=list(map(int,input().split("" ""))) +sum=0 +for i in range(k,n+2): + sum=sum+i*(n-i+1)+1 +print(sum%mod) + " +p02555,s410133512,Accepted,"from scipy import special + +S = int(input()) +top = S // 3 +if top == 0: + print(0) + exit() + +ans = 1 +mod = 10 ** 9 + 7 +for i in range(2, top + 1): + t = S - 3 * i + i -= 1 + ans += special.comb(t+i, i, True) +print(ans % (mod)) +" +p03611,s091732309,Accepted,"n, *a = map(int, open(0).read().split()) +cnt = [0] * 100000 +for x in a: cnt[x] += 1 +ans = 0 +for i in range(99998): + ans = max(ans, cnt[i]+cnt[i+1]+cnt[i+2]) +print(ans)" +p02786,s645777095,Wrong Answer,"h = int(input()) +tem = 1 +while h/2 > 1: + tem+=1 + h = h/2 +result = 1 +print(""tem""+str(tem)) +for i in range(1,tem+1): + result += 2**i +print(result)" +p02881,s502869302,Accepted,"n = int(input()) + +ans = 10**13 +for i in range(1, int(n**0.5//1)+1): + if n%i == 0: + ans = min(ans, i+n//i-2) +print(ans)" +p02963,s011482429,Accepted,"s = int(input()) +x1, y1 = 0, 0 +x2, y2 = 10**9, 1 +x3 = -s % (10**9) +y3 = (s+x3) // (10**9) +print(x1,y1,x2,y2,x3,y3)" +p02719,s076898463,Accepted,"N,K=map(int,input().split()) + +a = int(N % K) +b = int(K - a) + +print(min(a,b))" +p03251,s852584468,Accepted,"N, M, X, Y = map(int, input().split()) +x = list(map(int, input().split())) +y = list(map(int, input().split())) + +xmax = max(x) +ymin = min(y) +if (xmax= n: + print(""YES"") +else: + print(""NO"")" +p02615,s169569834,Accepted,"n = int(input()) +A = list(map(int, input().split())) +A.sort(reverse=True) + +cnt = n-1 +i = 0 +ans = 0 +while cnt: + if i == 0: + cnt -= 1 + ans += A[i] + i += 1 + else: + if cnt < 2: + ans += A[i]*cnt + cnt = 0 + else: + ans += A[i]*2 + cnt -= 2 + i += 1 +print(ans) +" +p02676,s303471834,Wrong Answer,"K = int(input()) +N = list(input()) +#print(K,N) +ans = [] +if len(N) > K: + for i in range(len(N)-K): + #print(i,len(N)) + N.pop(-1) +print("""".join(N))" +p03556,s024906000,Wrong Answer,print(int(int(input())**0.5)) +p03338,s588386569,Wrong Answer,"n = int(input()) +s = input() + +mxcnt = 0 +for i in range(n): + xy = set(s[:i]) & set(s[i:]) + print(xy) + mxcnt = max(mxcnt, len(xy)) +print(mxcnt) +" +p03804,s914736330,Accepted,"n,m = map(int,input().split()) +a = [list(input()) for _ in range(n)] +b = [list(input()) for _ in range(m)] +r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1)) +print(""Yes"" if r == True else ""No"")" +p02618,s201422098,Wrong Answer,"D=int(input()) +c = list(map(int,input().split())) +s = [list(map(int,input().split())) for _ in range(D)] +last_day = [0]*26 +score = 0 + +def calc_sum(day,t,sum): + sum += s[day-1][t-1] + for j in range(len(c)): + if(j!=day-1): + sum -= c[j]*(day-last_day[j]) + return sum + +for i in range(D): + t = 1 + max = 0 + for j in range(26): + if(max < calc_sum(i+1,j,score)): + max = calc_sum(i+1,j,score) + t = j + last_day[t-1]=i + score = max + print(t)" +p02922,s051594864,Accepted,"kuchi,total=map(int,input().split()) + +tap=0 +while tap*kuchi-(tap-1) B: + print(A - int(abs(A - B) / 2)) + else: + print(B - int(abs(A - B) / 2)) + else: + print('IMPOSSIBLE') + + +main()" +p03721,s314967809,Accepted,"n, k = map(int, input().split()) +AB = [] +for i in range(n): + a, b = map(int, input().split()) + AB.append((a, b)) +AB.sort() +cnt = 0 +for a, b in AB: + cnt += b + if cnt >= k: + print(a) + break +" +p03720,s490561550,Wrong Answer,"N,M = map(int,input().split()) +res = {} +for _ in range(M): + a,b = map(int,input().split()) + if a in res.keys(): + res[a] += 1 + else: + res[a] = 1 + if b in res.keys(): + res[b] += 1 + else: + res[b] = 1 +for key in sorted(res.keys()): + print(res[key]) +" +p03038,s441450131,Wrong Answer,"from heapq import heappush,heappop + +N,M = list(map(int,input().split())) +A = list(map(int,input().split())) +change = [list(map(int,input().split())) for _ in range(M)] + +def tempchange(l,change): + for i in range(M): + B,C = change[i][0],change[i][1] + for j in range(B): + a = heappop(l) + dif = C - a + if dif > 0: + heappush(l,C) + else: + heappush(l,a) + return sum(l) + +#A.sort(reverse = True) +change.sort(key = lambda x:x[1],reverse =True) +print(tempchange(A,change))" +p02742,s735395539,Wrong Answer,"h, w = map(int, input().split()) + +if (h*w) % 2 == 0: + print(int(h*w/2)) +else: + print(int(h*w//2+1))" +p03705,s081681512,Accepted,"# map(int, input().split()) +N, A, B = map(int, input().split()) +mn = A * (N - 1) + B +mx = B * (N - 1) + A +ans = mx - mn + 1 +if ans < 0: + print(0) +else: + print(ans)" +p03309,s244802810,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +b = [0]*n +for i in range(n): + sa = a[i] - (i+1) + b[i] = sa +b.sort() +idx = int(n/2) + +p = b[idx] +ans = 0 +for i in range(n): + ans += abs(i+1+p-a[i]) +print(ans) + + +" +p02836,s025164553,Accepted,"s=input() +s_re=s[::-1] +ans=0 +for i in range(len(s)): + if s[i]!=s_re[i]: + ans+=1 +print(ans//2)" +p02759,s721302115,Accepted,"N = int(input()) +div, mod = divmod(N, 2) + +if mod > 0: + div = div + 1 + +print(div) +" +p03705,s908293417,Accepted,"# よくよくサンプル1をみたら1ずつインクリメントするので +n, a, b = map(int, input().split()) +mins = b + a * (n - 1) +maxs = a + b * (n - 1) +print(max(0, maxs - mins + 1)) +" +p02995,s739755928,Accepted,"import math +a,b,c,d = map(int,input().split()) + +#cで割り切れる数+dで割り切れる数-gcd(c,d)で割り切れる数を求めればよい +ans=(b//c+b//d-b//(c*d//math.gcd(c,d)))-((a-1)//c+(a-1)//d-(a-1)//(c*d//math.gcd(c,d))) + +print(b-a+1-ans) +" +p02982,s460961936,Wrong Answer,"import math +n,d=map(int,input().split()) +l=[] +ans=0 +cnt=0 +for i in range(n): + l.append(list(map(int,input().split()))) + +for i in range (n-1): + for k in range(n-i-1): + for j in range(d): + ans+=((l[i][j])-(l[i+1+k][j]))**2 + if float.is_integer(math.sqrt(ans))==True: + cnt+=1 +print(cnt) +" +p02759,s949003050,Accepted,"N = int(input()) + +q = N //2 +r = N % 2 +print(q + r) +" +p03544,s821563864,Accepted,"N = int(input()) + +L = [2, 1] + +if N == 1: + print(L[1]) + exit() +else: + for i in range(2, N+1): + L.append(L[i-1] + L[i-2]) + print(L[N])" +p03556,s101954059,Accepted," +n = int(input()) +result = int(n ** 0.5) +print(result **2)" +p03854,s823291725,Wrong Answer,"s=""dreamerer"" + +s=s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') + +if len(s)==0:print(""YES"") +else:print(""NO"") +" +p03284,s665406436,Accepted,"def resolve(): + n, k = map(int, input().split()) + print(0 if n == 1 or n % k == 0 else 1) + + +if __name__ == '__main__': + resolve() +" +p02775,s218740302,Wrong Answer,"n = int(input()) +l = len(str(n)) +ans = 0 +nl = [int(str(n)[i]) for i in range(l)] + +for i in range(l-1): + if nl[l-1-i] == 10: + nl[l-2-i] += 1 + elif 10 > nl[l-1-i] > 5: + ans += 10-nl[l-1-i] + nl[l-2-i] += 1 + else: + ans += nl[l-1-i] +if nl[0]==10: + ans+=1 +elif 10>nl[0]>5: + ans+=11-nl[0] +else: + ans += nl[0] +print(ans)" +p03760,s576541516,Wrong Answer,"o = list(input()) +e = list(input()) + [""""] + +print(e) +for x, y in zip(o, e): + print(x + y, end="""")" +p02641,s493185633,Accepted,"X,N=map(int,input().split()) +alist = list(map(int, input().split())) +for a in range(X+1): + for b in [-1,+1]: + c = X + a * b + if alist.count(c) == 0: + print(c) + exit(0)" +p02879,s594330968,Wrong Answer,"n,m=map(int,input().split()) +if n>9 and m>9: + print(-1) +else: + print(n*m)" +p03543,s134285046,Accepted,"a = input() +li = [] +for s in a: + li.append(s) + +count = 0 +for i in range(1,4): + if li[i] == li[i-1]: + count += 1 + if count == 2: + break + else: + count = 0 + +if count >= 2: + print(""Yes"") +else: + print(""No"") +" +p02958,s741074551,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=sorted(A) +count=0 +for i in range(N): + if A[i]!=B[i]: + count+=1 +if count<=2: + print(""YES"") +else: + print(""NO"")" +p03943,s729097699,Accepted,"a,b,c = map(int,input().split()) +if max(a,b,c) * 2 == a + b + c: + print(""Yes"") +else: + print(""No"")" +p02948,s622743417,Wrong Answer,"N,M = map(int,input().split()) +A = [] +for _ in range(N): + Ai,Bi = map(int,input().split()) + A.append([Ai,Bi]) +A.sort(key=lambda x: x[0],reverse=True) +A.sort(key=lambda x: x[1],reverse=True) + +sum_pay = 0 +checked = [1]*N +j=0 +for i in range(N): + while A[j][0] > M-i or checked[j] == 0: + j += 1 + if j == N: + break + if j == N: + break + + sum_pay += A[j][1] + checked[j] = 0 + +print(sum_pay)" +p02744,s359174337,Wrong Answer,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(1000000) +from collections import deque, Counter +def getN(): + return int(input()) +def getList(): + return list(map(int, input().split())) +import math + +def res(n, cur, ln, k): + if ln == n: + print(cur) + return + res(n, cur + chr(ord(""a"") + k), ln+1, k) + res(n, cur + chr(ord(""a"") + k+1), ln + 1, k+1) + + +def main(): + n = getN() + res(n, ""a"", 1, 0) +if __name__ == ""__main__"": + main()" +p02555,s749163963,Accepted,"s=int(input()) +mod=10**9+7 +ans=0 +fac=[1] +for i in range(s*3): + fac.append(fac[-1]*(i+1)%mod) +def c(x,y): + r=fac[y]*fac[x-y]%mod + return fac[x]*pow(r,mod-2,mod)%mod +for i in range(1,s//3+1): + n=s-3*i + ans+=c(n+i-1,i-1) + ans%=mod +print(ans)" +p04045,s495512140,Accepted,"n,k=map(int,input().split()) +t=list(map(int,input().split())) +while True: + tab=0 + for i in t: + if str(i) in list(str(n)): + tab+=1 + if tab==0: + print(n) + break + else: + n+=1" +p02608,s693495361,Accepted,"n = int(input()) + +a = [0] * 10010 + +# x,y,z +for x in range(1, 101): + for y in range(1, 101): + for z in range(1, 101): + if x*x + y*y + z*z + x*y + y*z + z*x > n: + continue + a[x*x + y*y + z*z + x*y + y*z + z*x] += 1 + + +for i in range(1, n+1): + print(a[i]) +" +p03673,s122015598,Accepted,"from collections import deque + +n=int(input()) +a=[0]+list(map(int, input().split())) + +b=deque() + +for i in range(1, n+1): + if n%2==i%2: + b.appendleft(a[i]) + else: + b.append(a[i]) + +ans=[] + +for elem in b: + ans.append(elem) + +print(*ans)" +p02862,s368289837,Wrong Answer,"x,y=map(int,input().split()) +if (2*x-y)%3!=0 or (x-2*y)%3!=0: + print(0) + exit() +a=(2*x-y)//3 +b=(2*y-x)//3 +mod=10**9+7 +def comb(x,y): + s=1 + t=1 + for i in range(1,y+1): + s=s*(x-i+1)%mod + t=t*(i)%mod + return (s*pow(t,mod-2,mod))%mod +print(comb(a+b,min(a,b)))" +p03695,s534629013,Accepted,"import math + +N = int(input()) +A = [math.floor(a/400) if a < 3200 else 3200 for a in list(map(int, input().split()))] + +set_A = set([a for a in A if a != 3200]) +print(*[max(1, len(set_A)), len(set_A) + A.count(3200)], sep="" "")" +p02677,s866639993,Wrong Answer,"import math +a,b,h,m=map(int,input().split()) +time= 60*h + m +H=time*0.5 +M=(time*6) % 360 +angle=(abs(H-M))%180 +ans=math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))) +print(ans)" +p03821,s921499977,Wrong Answer,"n = int(input()) +ab = [list(map(int, input().split())) for i in range(n)] +ab = ab[::-1] + +z = 0 +cnt = 0 +for a, b in ab: + a += z + if a <= b: + z += abs(b-a) + else: + if a % b != 0: + z += b - (a % b) +print(z) +" +p02923,s976557915,Wrong Answer,"N = int(input()) +N_List = list(map(int,input().split())) +maxct = 0 +ct = 0 +for i in range(N-1): + if N_List[i] >= N_List[i+1]: + ct += 1 + if (i == N - 2) & (ct > maxct): + maxct = ct + else: + if maxct < ct: + maxct = ct + ct = 0 + +print(maxct) +" +p03657,s740132538,Accepted,"a,b=map(int,input().split()) +print('Possible' if a%3==0 or b%3==0 or (a+b)%3==0 else 'Impossible')" +p02684,s829379912,Wrong Answer,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +now = 1 +for i in range(min(k,int(2*n-1))): + now = a[now-1] +print(now)" +p03657,s217996940,Wrong Answer,"a,b = map(int,input().split()) +if (a+b) % 3 == 0: + print('Possible') +else: + print('Impossible')" +p03625,s801753872,Accepted,"from collections import Counter +N = int(input()) +A = [int(x) for x in input().split()] +pair = [] +c = Counter(A) +for x,cnt in c.items(): + pair += [x]*(cnt//2) + +pair.sort() + +answer = 0 +if len(pair)>= 2: + answer = pair[-1] * pair[-2] + +print(answer) +" +p02843,s874811964,Accepted,"x=int(input()) +if x>=2000: + print(1) +else: + a=x//100 + b=x-100*a + if a*5>=b: + print(1) + else: + print(0) +" +p02879,s811527964,Wrong Answer,"S = list(input()) +if len(S) > 3: + print(int(S[0]) * int(S[-1])) +else: + print(-1) +" +p02842,s476080182,Wrong Answer,"import math +N=int(input()) +x=math.floor(N/1.08) +X=math.floor((N+1)/1.08) +if x < X: + print(x) +else: + print("":("")" +p02628,s634262977,Accepted,"n,k = map(int,input().split()) +l = list(map(int,input().split())) +l.sort() + +ans = 0 +for i in range(k): + ans += l[i] + +print(ans)" +p03449,s947368397,Accepted,"n = int(input()) +A = [list(map(int,input().split())) for _ in range(2)] + +ans = 0 +for i in range(n): + cnt = 0 + for j in range(n): + if j <= i: + cnt += A[0][j] + if j >= i: + cnt += A[1][j] + ans = max(ans,cnt) +print(ans) +" +p03524,s121213534,Wrong Answer,"def mycounter(d,i): + if i in d: + d[i]+=1 + else: + d[i]=1 + return d +s=input() +d=dict() +for i in s: + d=mycounter(d,i) +l=-(-len(s)//3) +for i in d.values(): + if l= V: + print('NO') +elif abs(A - B) <= (V - W) * T: + print('YES') +else: + print('NO')" +p02918,s641444280,Accepted,"n, k = map(int, input().split()) +s = input() + +happy = n +for i in range(n - 1): + if s[i] + s[i + 1] == ""RL"": + happy -= 2 +if s[0] == ""L"": + happy -= 1 +if s[-1] == ""R"": + happy -= 1 + +answer = happy + 2 * k +print(min(answer, n - 1)) +" +p03293,s863147958,Accepted,"s = input() +t = input() +ans = ""No"" +for i in range(len(t)): + if s == t: + ans = ""Yes"" + break + else: + tmp = t[0] + t = t[1:] + t[0] + +print(ans)" +p02724,s331514386,Accepted,"x=int(input()) +c=x//500 +d=x%500 +e=d//5 +print(1000*c+e*5)" +p03206,s121650331,Wrong Answer,"d=int(input()) +print(""Chrismas""if d==25 else ""Chrismas Eve""if d==24 else""Chrismas Eve Eve"" if d==23 else""Chrismas EveEveEve"")" +p03821,s370422107,Wrong Answer,"n = int(input()) +a = [] +b = [] + +for i in range(n): + a_temp,b_temp = map(int,input().split()) + a.append(a_temp) + b.append(b_temp) + + +ans = 0 +for i in range(n): + ans += (-(a[i] + ans)) % b[i] +print(ans)" +p03239,s021170085,Accepted,"def resolve(): + n,T=map(int,input().split()) + ans=10000 + for i in range(n): + c,t=map(int,input().split()) + if t<=T: + ans=min(ans,c) + if ans==10000: + print('TLE') + else: + print(ans) + +if __name__ == '__main__': + resolve()" +p02819,s393130469,Wrong Answer,"x = int(input()) + +def is_prime(q): + q = abs(q) + if q == 2: return True + if q < 2 or q&1 == 0: return False + return pow(2, q-1, q) == 1 + +while True: + if is_prime(x): + print(x) + exit() + x+= 1" +p03380,s361759194,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a_i = max(a) +a.sort(key=lambda x: abs(a_i/2-x)) + +if a[0] == a_i: + print(a_i, a[1]) +else: + print(a_i, a[0]) +" +p03592,s846128961,Wrong Answer,"N,M,K=map(int,input().split()) +ret = 'No' +for m in range(M+1): + a=K-m*N + b=M-2*m + if 0= a else a - 1 +print(ans) +" +p02933,s249093060,Accepted,"a = int(input()) +s = str(input()) +if a >= 3200: + print(s) +else: + print(""red"")" +p02603,s871245720,Accepted,"N = int(input()) +A = [int(x) for x in input().split()] +A.append(0) +f = [0] * N +for i in range(N): + if A[i] < A[i+1]: + f[i] = 1 + elif A[i] > A[i+1]: + f[i] = 2 +cnt = 1000 +stock = 0 +prev = 0 +for i in range(N): + if stock == 0 and prev != 1 and f[i] == 1: + stock = cnt // A[i] + cnt %= A[i] + elif prev != 2 and f[i] == 2: + cnt += stock * A[i] + stock = 0 + prev = f[i] +print(cnt) +" +p02647,s588635606,Wrong Answer,"# -*- coding: utf-8 -*- +import math +N, K = map(int, input().split()) +A = input().split() +AK = [[0 for j in range(N)] for i in range(2)] +for l in range(N): + AK[0][l] = int(AK[0][l]) + int(A[l]) +p = int(math.log10(K+1)) +for m in range(1,p,1): + for o in range(N): + for x in range(N): + if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)): + AK[1][x] = AK[1][x] +1 + AK[0] = AK[1] + AK[1] = [0] * N +print(*AK[0])" +p02678,s072686765,Accepted,"import sys +from collections import deque +input = sys.stdin.readline +n,m=map(int,input().split()) +l=[[] for i in range(n)] +for i in range(m): + a,b=map(int,input().split()) + l[a-1].append(b-1) + l[b-1].append(a-1) +ans=[-1]*n +ans[0]=0 +print('Yes') +d=deque([0]) +while d: + now=d.pop() + for x in l[now]: + if ans[x]<0: + ans[x]=now + d.appendleft(x) +for i in range(1,n): + print(ans[i]+1)" +p02780,s472716420,Accepted,"from collections import deque +import copy +N,K = map(int, input().split()) +p = list([(i+1)* i/2/i for i in map(int, input().split())]) +que = deque([0]* K) +sumM = 0 +sumq = 0 +E = 0.0 + +for i in range(N): + sumq -= que.popleft() + sumq += p[i] + que.append(p[i]) + if E < sumq: + E = sumq +print(E)" +p03254,s345208948,Accepted,"#!/usr/bin/env python3 + + +def main(): + N, x, *A = map(int, open(0).read().split()) + A.sort() + for i in range(N): + x -= A[i] + if x == 0: + print(i + 1) + break + elif x < 0: + print(i) + break + else: + # ちょうどN個もらわないと喜べない悲しい子どもたち + print(N - 1) + + +main() +" +p02578,s009454512,Accepted,"n = int(input()) +a = list(map(int, input().split())) +fumi_sum = 0 +for i in range(1,n): + if a[i] < a[i-1]: + fumi_sum += a[i-1] - a[i] + a[i] += a[i-1] - a[i] +print(fumi_sum)" +p03951,s401479831,Wrong Answer,"n = int(input()) +s = input() +t = input() +if s == t: print(n) +else: + idx = False + for i in reversed(range(n)): + if s[i] == t[0]: + idx = i + for j in range(0, n - idx): + if s[idx + j] == t[j]: continue + else: + idx = False + break + if idx == False: print(len(s + t)) + else: print(len(s[:idx] + t))" +p03860,s416629764,Wrong Answer,"x=""AtCoder ""+input().capitalize()+"" Contest"" +print(x) + +print(""A""+x[8]+""C"")" +p03000,s232775270,Accepted,"n, x = map(int, input().split()) +l = list(map(int, input().split())) +d = 0 +c = 1 +for i in range(1, n + 1): + d += l[i - 1] + if d <= x: + c += 1 + else: + break +print(c)" +p03038,s095746245,Accepted,"n,m = map(int,input().split()) +a = list(map(int,input().split())) +a.sort() +q = [] +for i in range(m): + b,c = map(int,input().split()) + q.append([c,b]) +q.sort(reverse=True) +j = 0 +for i in range(m): + while j < len(a) and q[i][1]>0: + if a[j]=bb): + print(""YES"") +else : + print(""NO"") +" +p02576,s600868963,Accepted,"n, x, t = input().split() +N = int(n) +X = int(x) +T = int(t) +if N % X == 0: + c = N / X +else: + c = int(N / X) + 1 +C = int(c) +print(C*T) +" +p03150,s540155645,Wrong Answer,"s = str(input()) +j = 0 +flag = 0 +if ""key"" in s: + if ""ence"" in s: + print(""YES"") + exit() +print(""NO"")" +p02602,s836684652,Wrong Answer,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +for i in range(1,n - k): + score = 1 + p_score = 1 + for j in range(i,i+k): + score *= a[j] + p_score *= a[j-1] + if score > p_score: + print(""Yes"") + else: + print(""No"") + +" +p02835,s069391284,Accepted,"A1, A2, A3 = map(int, input().split()) + +t = A1 + A2 + A3 + +if t >= 22: + print(""bust"") +else: + print(""win"")" +p03419,s675393761,Wrong Answer,"N,M=map(int,input().split()) +print(1 if N==1 and M==1 else M-2 if N==1 and M!=1 else (N-2)*(M-2))" +p03434,s971312258,Accepted,"N=int(input()) +a=list(map(int, input().split())) +a.sort() +a=a[::-1] +A=sum([a[i] for i in range(0, N, 2)]) +B=sum([a[i] for i in range(1, N, 2)]) +print(A-B)" +p02771,s266009132,Accepted,"a,b,c=map(int,input().split()) +print(""No"" if a==b==c else ""Yes"" if a==b or b==c or c==a else ""No"") +" +p03767,s453119588,Accepted,"import sys +input = sys.stdin.readline + +# A - AtCoder Group Contest +n = int(input()) +a = list(map(int, input().split())) +a.sort(reverse = True) +ans = 0 + +for i in range(1, n * 2, 2): + ans += a[i] + +print(ans)" +p03617,s749985938,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + q,h,s,d=map(int, input().split()) + n=int(input()) + s=min(4*q,2*h,s) + if 2*s<=d: + print(n*s) + else: + a,b=divmod(n,2) + print(a*d+b*s) +resolve()" +p03106,s262525813,Accepted,"A, B, K = map(int,input().split()) +l = [x for x in range(1,A+1) if A%x == 0 and B%x == 0] +print(l[-K])" +p03241,s098480914,Accepted,"n,m=list(map(int,input().split())) + +i=1 +ans=0 + +while i*i<=m: + if m%i==0: + if n<=m/i: + ans=max(ans,i) + if n<=i: + ans=max(ans,m//i) + + i+=1 + +print(ans) +" +p03457,s041452730,Accepted,"import sys +N = int(input()) +turn = 0 +x, y = 0, 0 +for i in range(N): + a = list(map(int, input().split())) + if a[0]%2 == 0 and (a[1]+a[2])%2 == 1: + print(""No"") + sys.exit() + if a[0]%2 == 1 and (a[1]+a[2])%2 == 0: + print(""No"") + sys.exit() + if (a[0] - turn) < abs(x - a[1]) + abs(y - a[2]): + print(""No"") + sys.exit() +print('Yes')" +p02640,s454495366,Wrong Answer,"#!/usr/local/bin/python3 +# coding: utf-8 + +ha = input() +kita = ha.split("" "") +x = int(kita[0]) +y = int(kita[1]) +ifAshi = False + +for i in range(x): + if((y - 2*i)%4 == 0): + if((x-i) == ((y - 2*i)/4)): + ifAshi = True + +if(ifAshi): + print(""Yes"") +else: + print(""No"")" +p02600,s376256678,Wrong Answer,"X = int(input()) + +lst = [ [400, 599, 8], [600, 799, 7], [800, 999, 6], [1000, 1199, 5], [1200, 1399, 4], [1400, 1599, 3], [1600, 1799, 2], [1800, 1999, 1] ] + +def Kyu(X): + + for i in lst: + if i[0] <= X <= i[1]: + result = i[2] + break + + print(result)" +p02647,s747589240,Wrong Answer,"import math + +N, K = map(int, input().split("" "")) +A = list(map(int, input().split("" ""))) + +for i in range(min(math.ceil(math.log(N)), K)): + B = [0] * N + for n, A_n in enumerate(A): + B_min = max(0, n-A_n) + b_max = min(N-1, n+A_n) + B[B_min] += 1 + if b_max+1 < N: + B[b_max+1] -= 1 + + sum = 0 + for n in range(len(A)): + sum += B[n] + A[n] = sum + +print("" "".join(list(map(str, A))))" +p03693,s540621455,Wrong Answer,"r,g,b = map(int,input().split()) +1 <= r <= 9 +1 <= g <= 9 +1 <= b <= 9 +number1 = str(r+g+b) +number2 = int(number1) +if number2%4 == 0: + print(""YES"") +else: + print(""NO"")" +p02897,s918708771,Accepted,"n = int(input()) +cnt = 0 +for i in range(n+1): + if i%2 ==1: + cnt += 1 +print(cnt/n)" +p03971,s503535181,Wrong Answer,"datalist=list(map(int,input().split())) +N,A,B=datalist[0],datalist[1],datalist[2] +strings=str(input()) +na,nb=0,0 +for i in range(len(strings)): + if strings[i]==""a"": + if na + nb < A+B: + print(""YES"") + na += 1 + else: + print(""NO"") + elif strings[i]==""b"": + if na + nb < A+B: + if nb < B: + print(""YES"") + nb += 1 + else: + print(""NO"") + else: + print(""NO"") + else: + print(""NO"")" +p03435,s755895664,Wrong Answer,"masu = [list(map(int,input().split())) for _ in range(3)] +import numpy as np +masu = np.array(masu) +a = [] +b = [] +for i in masu: + a.append(min(list(i))) +for i in masu.T: + b.append(min(list(i))) +flag = True +c = 0 +p = masu[0][0] +for i in range(3): + for j in range(3): + if masu[i][j] != a[i] + b[j]: + flag = False + if masu[i][j] == p: + c += 1 +if flag or c==9: + print('Yes') +else:print('No') + " +p02711,s652956582,Wrong Answer,"n=int(input()) +data=[10**i for i in range(1,3+1)] +for i in data: + if n%i==7: + print(""Yes"") + exit() +print(""No"")" +p03639,s642167525,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +num_odd = 0 +num_mul4 = 0 +for a in A: + if a % 2 == 1: + num_odd += 1 + elif a % 4 == 0: + num_mul4 += 1 +if N <= 3: + if num_odd == 0: + print('Yes') + elif num_mul4 >= 1: + print('Yes') + else: + print('No') + exit() + +if num_odd <= num_mul4: + print('Yes') +else: + print('No') +" +p03680,s839052949,Accepted,"def readinput(): + n=int(input()) + a=[0] + for _ in range(n): + a.append(int(input())) + return n,a + +def main(n,a): + button=[0]*(n+1) + button[1]=1 + i=1 + count=0 + while(True): + i=a[i] + count+=1 + if i==2: + return count + if button[i]>0: + return -1 + button[i]+=1 + +if __name__=='__main__': + n,a=readinput() + ans=main(n,a) + print(ans) +" +p02917,s332677358,Wrong Answer,"from sys import stdin,stdout + + +if __name__==""__main__"": + + n=int(stdin.readline()) + b=[int(x) for x in stdin.readline().split()] + b.append(1000000) + + s=b[0] + + for i in range(n-1): + if b[i]>b[i+1]: + s+=b[i+1] + else: + s+=b[i] + stdout.write(str(s)+""\0"") + +" +p02753,s926054477,Wrong Answer,"S = input() +if S[0] == S[1] and S[1] == S[2]: + print('Yes') +else: + print('No')" +p02951,s060487397,Accepted,"a, b, c = map(int, input().split()) +ans = max(c-(a-b), 0) +print(ans)" +p03720,s756287105,Accepted,"n,m=[int(x) for x in input().split()] +r=[input() for _ in range(m)] + +r=' '.join(r).split() +for i in range(1,n+1): + print(r.count(str(i)))" +p03799,s381099328,Accepted,"N,M=map(int,input().split()) +ans=0 +ans+= min(N, M//2) +M-=ans*2 +ans+=M//4 +print(ans)" +p03633,s014574921,Accepted,"from math import gcd +from functools import reduce + + +def lcm(a, b): + return (a * b) // gcd(a, b) + + +def main(): + n = int(input()) + t = [int(input()) for _ in range(n)] + print(reduce(lcm, t)) + + +if __name__ == '__main__': + main() +" +p03286,s118752038,Accepted,"n = int(input()) +ans = '' +p = -2 +while n!=0: + n,r = divmod(n,p) + if r < 0: + r -= p + n += 1 + ans = str(r) + ans +if ans == '': ans = '0' +print(ans) +" +p03612,s716325452,Accepted,"n = int(input()) +lis = [0]+list(map(int, input().split())) +[0] + +total = 0 + +for i in range(1, n+1): + if i == lis[i]: + t = lis[i] + lis[i] = lis[i+1] + lis[i+1] = t + total += 1 + +print(total)" +p02547,s490965210,Accepted,"N = int(input()) +l = [] +for _ in range(N): + a, b = map(int, input().split()) + l.append((a, b)) + +cnt = 0 +for t in l: + if t[0] == t[1]: + cnt += 1 + if cnt >= 3: + break + else: + cnt = 0 +if cnt >= 3: + print('Yes') +else: + print('No') +" +p03944,s860226038,Accepted,"w,h,n = map(int, input().split()) +x_left = 0 +x_right = w +y_up = h +y_down = 0 +for _ in range(n): + x,y,a = map(int, input().split()) + if a==1 and x_left <= x: + x_left = x + elif a==2 and x_right >= x: + x_right = x + elif a==3 and y_down <= y: + y_down = y + elif a==4 and y_up >= y: + y_up = y + +if x_right <= x_left or y_up <= y_down: + print(0) +else: + print((x_right - x_left)*(y_up - y_down))" +p03069,s175001402,Accepted,"n = int(input()) +s = list(input()) +b = [0] * n +w = [0] * n +x,y = 0,0 +ans = 0 +for i in range(n): + if s[i] == '#': + x += 1 + else: + y += 1 + b[i] = x + w[i] = y + +ans = float('inf') +for i in range(n): + ans = min(ans, b[i] + w[n-1] - w[i]) +print(min(ans, b[n-1], w[n-1]))" +p03494,s342429049,Wrong Answer,"N = int(input()) +S = list(map(int,input().split())) + +cnt = 0 +while True: + check = sum(S) + if check % 2 == 0 and check > 0: + S = [n//2 for n in S] + cnt += 1 + else: + break + +print(cnt)" +p03627,s619483787,Accepted,"from collections import Counter + +N = int(input()) +A = list(map(int, input().split())) + +cntA = Counter(A) +B = [] +for a, c in cntA.items(): + if c // 2 == 0: + continue + for _ in range(c // 2): + B.append(a) + +B.sort(reverse=True) +ans = B[0] * B[1] if len(B) >= 2 else 0 + +print(ans)" +p02719,s484288685,Accepted,"N,K = map(int, input().split()) +xo=N%K +xn=abs(xo-K) +while True: + if xo>xn: + xo=xn + xn=abs(xn-K) + else: + break +print(xo)" +p03815,s101563905,Wrong Answer,"# C - X: Yet Another Die Game +def main(): + x = int(input()) + + if x <= 11: + print(2) + else: + print(x//11*2+1) + + +if __name__ == '__main__': + main()" +p03696,s964418590,Wrong Answer,"n = int(input()) +S = input() + +d = [0] * n +nl = 0 +nr = 0 +for i in range(n): + if S[i] == '(': nl += 1 + if S[i] == ')': nr += 1 + d[i] = nl - nr + +x = min(d) +# print(d) +# print(x) + +print('('*(-x) + S + ')'*(d[-1]-x))" +p03438,s377261406,Accepted,"import math + +N = int(input()) + +As = list(map(int, input().split())) +Bs = list(map(int, input().split())) + +if sum(As) > sum(Bs): + print('No') + exit() + +dif = sum(Bs) - sum(As) +A = 0 +for i in range(N): + if Bs[i] > As[i]: + A += math.ceil((Bs[i]-As[i])/2) + +if A > dif: + print('No') +else: + print('Yes')" +p04011,s048998052,Wrong Answer,"N = int(input()) +K = int(input()) +X = int(input()) +Y = int(input()) + +if N > K: + print(K*X + Y*(N-K)) +else: + print(K*X)" +p03106,s575629223,Accepted,"def LI(): return list(map(int,input().split())) +A,B,K = LI() +ans = [] +for i in range(1,min(A,B)+1): + if A%i==B%i==0: + ans.append(i) +print(ans[-K]) +" +p03639,s845793969,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +x,y=0,0 +for i in a: + if i%4==0: + x+=1 + if i%2==1: + y+=1 + +z=n-y-x + +if z==0: + print('Yes' if y<=x+1 else 'No') +else: + print('Yes' if y<=x else 'No')" +p03817,s671876466,Accepted,"x = int(input()) +ans = (x // 11) * 2 +if x % 11: + if x % 11 > 6: + ans += 2 + else: + ans += 1 +print(ans) +" +p03126,s858513973,Wrong Answer,"N, M = map(int, input().split()) +list=[] +s=[] +if N == 1: + a, *b=map(int, input().split()) + print(a) +else: + for i in range(N): + list.append(input().split()) + s = set(s) & set(list[1:]) + list=[] + print(len(s)) " +p02882,s536770497,Accepted,"import math +a,b,x =map(int,input().split()) + +if x <(a*a*b)/2: + hen=(x*2)/(a*b) + print(math.degrees(math.atan(b/hen))) + + +else: + taiseki=a*a*b-x + hen=(taiseki*2)/(a*a) + print(math.degrees(math.atan(hen/a))) + +" +p03243,s402058956,Accepted,"n=int(input()) +if n<112: + print(111) +elif n<223: + print(222) +elif n<334: + print(333) +elif n<445: + print(444) +elif n<556: + print(555) +elif n<667: + print(666) +elif n<778: + print(777) +elif n<889: + print(888) +else: + print(999) +" +p02917,s525743271,Accepted,"n = int(input()) +b = [int(i) for i in input().split()] + +a = [b[0]] +for i in range(1, n-1): + a.append(min(b[i-1], b[i])) +a.append(b[-1]) + +print(sum(a)) +" +p03475,s981985477,Accepted,"import math +n=int(input()) +c=[0]*(n-1) +s=[0]*(n-1) +f=[0]*(n-1) +for i in range(n-1): + c[i],s[i],f[i] = map(int,input().split()) + +for i in range(n): + ans=0 + for j in range(i,n-1): + ans = max(s[j], math.ceil(ans/f[j])*f[j]) + c[j] + print(ans)" +p03695,s923996520,Accepted,"N = int(input()) +a = [int(c) for c in input().split()] +c = [0]*8 +over = 0 +for i in range(N): + if a[i]>=3200: + over+=1 + else: + c[a[i]//400]+=1 + +mi = 8-c.count(0) +ma = mi+over +if mi == 0: + mi+=1 +print(mi,ma) +" +p03221,s153309174,Accepted,"N, M = map(int, input().split()) +PY = [list(map(int, input().split())) + [i] for i in range(M)] + +sortPY = sorted(PY, key=lambda x: x[1]) +prefec = [0]*(N+1) +res = [] +for p, y, i in sortPY: + prefec[p] += 1 + strp = str(p) + ID = '0'*(6-len(strp)) + strp + '0'*(6-len(str(prefec[p]))) + str(prefec[p]) + res.append([ID, i]) + +sortres = sorted(res, key=lambda x: x[1]) +for i in range(M): + print(sortres[i][0]) +" +p03838,s251101380,Wrong Answer,"st, gl = map(int, input().split()) +ans = 0 + +if gl == st: + print(0) + exit() +elif gl == -st: + print(1) + exit() + +if st >= 0: + if gl > st: + ans = gl - st + elif gl < -st: + ans = - st - gl + 1 + else: + ans = gl + st + 1 + +if st < 0: + if gl > -st: + ans = gl + st + 1 + elif gl < st: + ans = st - gl + 2 + else: + ans = gl - st + +print(ans)" +p02796,s464513532,Wrong Answer,"N = int(input()) +List = dict() +for i in range(N): + X,L = map(int,input().split()) + List.update({X:L}) +keys= sorted(List,reverse=True) +if len(List)<=1: + print(len(List)) +elif len(List)<3: + if keys[0]-List[keys[0]]<=keys[1] or keys[1]+List[keys[1]]<=keys[0]: + del List[keys[i]] + print(len(List)) +else: + for i in range(1, len(keys)-1): + if keys[i]-List[keys[i]]<=keys[i+1] or keys[i]+List[keys[i]]>=keys[i-1]: + del List[keys[i]] + print(len(List)) + +" +p02684,s840186136,Accepted,"N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +visited = {'1': 0} +route = [1] +next_id = 0 +count = 0 +while count < K: + count += 1 + if A[next_id] in visited.keys(): + route = route[visited[A[next_id]]:] + K -= count + break + visited[A[next_id]] = count + route.append(A[next_id]) + next_id = A[next_id] - 1 +print(route[K % len(route)]) +" +p03779,s351598202,Accepted,"x = int(input()) +c = 0 +t = 0 +while 1: + t += 1 + c += t + if c >= x: + print(t) + exit()" +p04011,s571649757,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +print(n*x) if n max_count: + max_count = count + else: + if count > max_count: + max_count = count + count = 0 +print(max_count) +" +p02582,s628836857,Accepted,"D = input() +ans = 0 +ans_list = [] +if D.count(""R"") >= 1: + for i in range(3): + if D[i] == 'R': + ans += 1 + ans_list.append(ans) + elif D[i] == 'S': + ss = 0 + ans_list.append(ss) + if i > 0: + ans = 0 + print(max(ans_list)) +elif D.count(""R"") < 1: + print(0) +" +p03827,s440765440,Accepted,"# n, m, l = map(int, input().split()) + +# list_n = list(map(int, input().split())) + +# n = input() +# list = [input() for i in range(N) + +# list = [[i for i in range(N)] for _ in range(M)] + +import sys +input = sys.stdin.readline + +N = int(input()) +S = input() + +ans = 0 +x = 0 +for i in range(len(S)): + if S[i] == ""I"": + x += 1 + else: + x -= 1 + ans = max(ans, x) + +print(ans) +" +p03943,s840634509,Accepted,"a,b,c=sorted(list(map(int,input().split()))) +if a+b==c:print(""Yes"") +else:print(""No"")" +p03962,s601030089,Wrong Answer,"s = str(input()) + +g_count = 0 +p_count = 0 +point = 0 +for i in range(len(s)): + # 必ずグーを出す状態 + if g_count == p_count: + g_count += 1 + if s[i] == 'g': + pass + else: + point -= 1 + # パーも出せる状態 + elif s[i] == 'g': + p_count += 1 + point += 1 + elif s[i] == 'p': + p_count += 1 + +ans = point +print(ans)" +p02988,s531493894,Wrong Answer,"import copy +n = int(input()) +s = list(map(int, input().split())) + +count = 0 + +for i in range(n - 2): + t = copy.copy(s[i:i + 2]) + if(s[i + 1] == sorted(t)[1]): + count += 1 + +print(count) +" +p02947,s465259875,Accepted,"def main(): + n = int(input()) + d = {} + ans = 0 + + for _ in range(n): + ss = ''.join(sorted(input())) + d[ss] = d.get(ss, 0) + 1 + + for k, v in d.items(): + if v != 1: + ans += (v*(v-1)) // 2 + + print(ans) + + +if __name__ == '__main__': + main()" +p03407,s799949022,Wrong Answer,"A, B, C = map(int, input().split()) + +if A + B <= C: + print('Yes') +else: + print('No')" +p02836,s304051985,Accepted,"s = input() + +n = len(s) +count = 0 + +for i in range(n//2): + if not s[i] == s[-1-i]: + count += 1 +print(count) +" +p02717,s336915208,Accepted,"x, y, z = map(int, input().split()) +print(z, x, y) +" +p02553,s111332500,Accepted,"a,b,c,d = map(int,input().split()) +print(max(a*c,a*d,b*c,b*d))" +p02713,s829124913,Accepted,"import math +k = int(input()) + +ans = 0 +for a in range(1, k+1): + for b in range(1, k+1): + m = math.gcd(a, b) + for c in range(1, k+1): + ans += math.gcd(m, c) + +print(ans) +" +p03059,s755377221,Accepted,"a,b,c=map(int,input().split()) +print((c//a)*b)" +p02641,s548262939,Accepted,"x, n = map(int, input().split()) +p = list(map(int,input().split())) +p.sort() +s = x +d = 1 +while s in p: + s = s - d + d = int((abs(d)+1)*d/abs(d)*(-1)) +print(s)" +p02778,s274683501,Accepted,"s = input() +x=""x"" +print(x*len(s)) +" +p03475,s223326011,Wrong Answer,"N = int(input()) + +A = [] +for i in range(N-1): + c, s, f = map(int, input().split()) + A.append([c, s, f]) + +for i in range(N-1): + ans = 0 + T = 0 + for j in range(i, N-1): + if T <= A[j][1]: + T += A[j][0] + A[j][1] - T + else: + T += (T-A[j][1])%A[j][2] + A[j][0] + print(T) + +print(0)" +p04033,s471982613,Accepted,"a, b = map(int, input().split()) + +if a <= 0 and 0 <= b: + print(""Zero"") +elif 0 < a: + print(""Positive"") +elif a < 0 and 0 <= b: + print(""Zero"") +else: + if abs(a - b) % 2 == 1: + print(""Positive"") + else: + print(""Negative"") + + " +p03011,s293194450,Accepted,"p,q,r=map(int,input().split());print(min(p+q,q+r,r+p))" +p03852,s641108836,Accepted,"# -*- coding: utf-8 -*- +c = input() +if c=='a' or c=='i' or c=='u' or c=='e' or c=='o': + print('vowel') +else: + print('consonant')" +p02848,s368675412,Wrong Answer,"N = int(input()) +S = input() + +front = S[0:N] +back = S[N:] +print(back+front)" +p02627,s342004281,Wrong Answer,"alpha = str(input()) + +if alpha > ""A"" and alpha < ""Z"": + print(""A"") +else: + print(""a"")" +p03137,s752359190,Accepted,"N,M = map(int,input().split()) +X = list(map(int,input().split())) +X.sort() +if M <= N : + ans = 0 +else: + Y = [] + for i in range(M-1): + Y.append(X[i+1] - X[i]) + Y.sort(reverse=True) + ans = X[-1] - X[0] + Y = Y[:N-1] + for i in Y: + ans -= i +print(ans)" +p02676,s525397430,Accepted,"K = int(input()) + +S = input() + +if len(S) <= K: + print(S) +else: + print(S[:K] + ""..."")" +p03611,s553421203,Wrong Answer,"n = int(input()) +num = list(map(int,input().split())) +lis = [0]*(max(num)+2) +for i in num: + lis[i-1] +=1 + lis[i] +=1 + lis[i+1] +=1 +print(lis) +print(max(lis)) +" +p02838,s869284416,Wrong Answer,"import numpy as np + +mod = 10 ** 9 + 7 + +N = int(input()) +A = np.array(list(map(int, input().split()))) + + +tmp = 0 +for n in range(len(bin(max(A)))-2): # 最大桁数は、最も大きい数値の2進数の桁数 + num_1 = np.count_nonzero((A >> n)&1) # 1の数をカウント + print((A >> n)&1) + num_0 = N - num_1 # 0の数をカウント + mul = num_1 * num_0 # 0 XOR 1の回数 + tmp += ((2 ** n)*mul) % mod + +print(tmp%mod)" +p03163,s747787676,Wrong Answer,"n,w=map(int,input().split()) +mer=[list(map(int,input().split())) for i in range(n)] +dp=[[0]*w for i in range(n+1)] +for i in range(1,n+1): + for j in range(1,w+1): + if j>=mer[i-1][0]: + dp[i][j-1]=mer[i-1][1]+dp[i-1][j-mer[i-1][0]-1] + dp[i][j-1]=max(dp[i][j-1],dp[i-1][j-1]) +print(dp[-1][-1])" +p02583,s093565313,Accepted,"import itertools + + +num_sticks = int(input()) + +sticks = list(map(int, input().split())) + +stick_combinations = list(itertools.combinations(sticks, 3)) + +counter = 0 + +for a, b, c in stick_combinations: + if a == b or b == c or c == a: + continue + + if abs(b - c) < a < (b + c): + counter += 1 + +print(counter) +" +p02987,s293308196,Accepted,"a = list(input()) +a.sort() +if a[0] == a[1] and a[2] == a[3] and a[1] != a[2]: + print('Yes') +else: + print('No')" +p03282,s123794250,Accepted,"s=input() +k=int(input()) +n=min(len(s),k) +ans=1 +for i in range(n): + if s[i]!=""1"": + ans=str(s[i]) + break +print(ans)" +p02615,s116832972,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +A.sort(reverse = True) + +ans = sum(A[:N // 2]) * 2 - A[0] + +print(ans) +if N % 2 == 1: + ans += A[N // 2] + +print(ans)" +p03469,s767230596,Wrong Answer,"N = list(input()) + +N[3] = ""8"" + +print(N) +date = ''.join(N) +print(date)" +p03011,s910462014,Accepted,"INT = lambda: int(input()) +INTM = lambda: map(int,input().split()) +STRM = lambda: map(str,input().split()) +STR = lambda: str(input()) +LIST = lambda: list(map(int,input().split())) +LISTS = lambda: list(map(str,input().split())) +def do(): + p,q,r=INTM() + print(min(p+q,q+r,r+p)) +if __name__ == '__main__': + do()" +p02838,s044798112,Wrong Answer,"import numpy as np +n = int(input()) +a = np.array(list(map(int, input().split())), dtype=""int64"") +p = 7 + 10**9 + +ans = 0 + +for i in range(n-1): + ans += np.sum(a[i+1:] ^ a[i]) % p + +print(ans % p)" +p03137,s321260399,Wrong Answer,"n, m = map(int, input().split()) +x = sorted(set(map(int, input().split()))) +t = [] +for i, j in zip(x, x[1:]): + t += [i - j] +t = sorted(t, reverse=True) +print(sum(t[n-1:])) +" +p02970,s595354623,Accepted,"import math +N, D = map(int, input().split()) +print(math.ceil(N/(2*D+1)))" +p02982,s130756456,Accepted,"from math import sqrt + +N, D = map(int, input().split()) + +X = [tuple(map(int, input().split())) for _ in range(N)] + +ans = 0 +for i in range(N - 1): + for j in range(i + 1, N): + tmp = 0 + for k in range(D): + tmp += (X[i][k] - X[j][k]) ** 2 + if tmp == int(sqrt(tmp)) ** 2: + ans += 1 + +print (ans)" +p02582,s016508832,Accepted,"S = input() + +ans = 0 +tmp = 0 +for i in S: + if i == 'R': + tmp += 1 + else: + ans = max(tmp,ans) + tmp = 0 + +ans = max(tmp,ans) + +print(ans)" +p03042,s403753553,Wrong Answer,"s = input() +a = int(s[:2]) +b = int(s[2:]) +if a<=12 and b<=12: + print('AMBIGUOUS') +elif a<=99 and 0 price: + ans = price + +print(ans)" +p03407,s590789201,Accepted,"a,b,c = map(int,input().split()) +if a+b>=c: + print('Yes') +else: + print('No')" +p02785,s814073533,Accepted,"a = input() +l = a.split() +n = int(l[0]) +k = int(l[1]) +b = input() +ll = b.split() +for i in range(0,n): + ll[i] = int(ll[i]) +if n k: + ans = step[k] +else: + cnt = (k - lp_start) % syuki + ans = step[lp_start:][cnt] + 1 + +print(ans)" +p03434,s350544001,Wrong Answer,"n = int(input()) +array = list(map(int, input().split())) + +bob = [] +alice = [] +for i in range(1, n+1): + if i % 2 == 1: + max_value = max(array) + array.remove(max_value) + alice.append(max_value) + else: + min_value = min(array) + array.remove(min_value) + bob.append(min_value) + +print(sum(alice)-sum(bob)) +" +p02554,s323650202,Accepted,"MOD = 10**9+7 + +n = int(input()) +print((pow(10, max(n, 0), MOD) - pow(9, max(n, 0), MOD) - + pow(9, max(n, 0), MOD) + pow(8, max(n, 0), MOD)) % MOD) +" +p03721,s591126585,Accepted,"n,k = map(int, input().split()) +d = {} +for _ in range(n): + a,b = map(int, input().split()) + if a not in d: d[a] = b + else: d[a] += b + +t = 0 +for i in sorted(d.items(), key=lambda x:x[0]): + t += i[1] + if t >= k: + print(i[0]) + exit()" +p02835,s501879549,Wrong Answer,"a=list(map(int,input().split())) +print(a[0]+a[1]+a[2])" +p02624,s769408196,Accepted,"n = int(input()) +ans = 0 + +for i in range(1, n + 1): + k = n // i + ans += i * k * (k + 1) // 2 + +print(ans)" +p02982,s690881939,Accepted,"n, d = map(int, input().split()) +T = [list(map(int, input().split())) for _ in range(n)] + +ans = 0 + +for i in range(n - 1): + for j in range(i + 1, n): + tmp = 0 + + for k in range(d): + tmp = tmp + (T[i][k] - T[j][k]) ** 2 + + tmp = tmp ** 0.5 + + if tmp == int(tmp): + ans = ans + 1 + +print(ans)" +p03804,s011634454,Wrong Answer,"n,m=map(int,input().split()) +a=[input() for i in range(n)] +b=[input() for i in range(m)] + +#二次元配列の部分配列を抽出する手法 +#[l[i:m+i] for l in a[i:m+i]] +for i in range(n-m): + for j in range(n-m): + if [l[i:m+i] for l in a[i:m+i]]==b: + print('Yes') + exit() + +print('No')" +p03417,s785438825,Accepted,"n, m = sorted(map(int, input().split())) +print(1 if n==m==1 else m-2 if n==1 else (n-2)*(m-2))" +p03252,s877875669,Wrong Answer," +def main(): + S = list(input()) + T = list(input()) + d = {} + for k in set(T): + d[k] = set() + for s, t in zip(S, T): + if s != t: + d[t].add(s) + if all([len(v) == 1 for v in d.values()]): + print('Yes') + else: + print('No') + +if __name__ == '__main__': + main() +" +p02663,s354773975,Accepted,"h1,m1,h2,m2,k = map(int,input().split()) +t1=60*h1+m1 +t2=60*h2+m2 +print(t2-t1-k)" +p03062,s935545472,Accepted,"n=int(input()) +a=list(map(int,input().split())) +s=sum(map(abs,a)) +m=min(list(map(abs,a))) +z=[] +for i in range(n): + if a[i]<0: + z.append(a[i]) + +if len(z)%2: + print(s-2*m) +else: + print(s)" +p03665,s975254645,Accepted,"n, p = map(int, input().split()) +a = list(map(int, input().split())) +mod = {0:0, 1:0} +for i in a: + mod[i % 2] += 1 +ans = 0 +for i in range(p, mod[1] + 1, 2): + temp = 1 + for j in range(i): + temp *= mod[1] - j + temp //= j + 1 + ans += temp +for i in range(mod[0]): + ans *= 2 +print(ans)" +p03012,s849603419,Wrong Answer,"ans = [] +n = int(input()) +w = list(map(int, input().split())) + +for t in range(1, n): + s1 = [] + s2 = [] + for i in w: + if t >= i: + s1.append(i) + elif t < i: + s2.append(i) + + ans.append(abs(sum(s1) - sum(s2))) +print(min(ans)) +" +p03962,s003255505,Accepted,"# -*- coding: utf-8 -*- +import sys +sys.setrecursionlimit(10**9) +INF=10**18 +MOD=10**9+7 +input=lambda: sys.stdin.readline().rstrip() +YesNo=lambda b: bool([print('Yes')] if b else print('No')) +YESNO=lambda b: bool([print('YES')] if b else print('NO')) +int1=lambda x:int(x)-1 + +def main(): + print(len(set(list(map(int,input().split()))))) + +if __name__ == '__main__': + main() +" +p02700,s093883883,Accepted,"a, b, c, d = map(int, input().split()) +if (c + b - 1) // b <= (a + d - 1) // d: + print('Yes') +else: + print('No')" +p03103,s815828942,Accepted,"n, m = map(int, input().split()) +ab = [tuple(map(int, input().split())) for _ in range(n)] +ab = sorted(ab, key=lambda x: x[0]) +ans = 0 +for a, b in ab: + if m - b > 0: + ans += a*b + m -= b + elif m == b: + ans += a*b + m -= b + break + else: + ans += a*m + break +print(ans)" +p03698,s023173805,Accepted,"import sys + +s = input() + +used_dict = {} + +for l in s: + if l in used_dict: + print('no') + sys.exit() + else: + used_dict[l] = True + +print('yes')" +p03556,s200695259,Wrong Answer,"for i in range(int(input()), 1, -1): + if i**(1/2) % 1 == 0: + print(i) + break +" +p03017,s182605836,Wrong Answer,"n,a,b,c,d = map(int,input().split()) +s = input() +if c= 3 and m >= 3: + print((n-2)*(m-2)) +if (n >= 3 and m == 2) or (n == 2 and m >= 3) or (n == 2 and m == 2): + print(0) +if (n == 1) or (m == 1): + print(max(n, m) - 2)" +p03317,s846338805,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) + +if (N-1) % (K-1) == 0: + print((N-1)//(K-1)) +else: + print(1 + (N-1)//(K-1))" +p03455,s695553199,Accepted,"s = input().split() +t = [int(p) for p in s] +#print(t) + +ans = 'Odd' +for i in range(2): + if t[i] % 2 == 0: + ans = 'Even' +print(ans)" +p02785,s621976100,Accepted,"N,K=map(int,input().split()) +H=sorted(map(int,input().split()))[::-1] +print(sum(H[K:]))" +p02996,s066890694,Wrong Answer,"n = int(input()) +a = [0] * n +b = [0] * n +for i in range(n): + a[i], b[i] = map(int, input().split()) + +am = 0 +bm = 0 +for i in range(n): + am += a[i] + bm = max(bm, b[i]) + if a[i] > b[i]: + print(""No"") + exit() + +if am <= bm: + print(""Yes"") +else: + print(""No"")" +p02760,s353562566,Wrong Answer,"def common_member(a, b): + a_set = set(a) + b_set = set(b) + if (a_set & b_set): + return a_set & b_set + else: + return ""a"" + +L = list(map(int,input().split())) +L1 = list(map(int,input().split())) +L2 = list(map(int,input().split())) +LL = L + L1 + L2 +N = int(input()) +M = [] +for i in range(N): + ML = input() + M.append(int(ML)) + +res = len(common_member(M,LL)) +if(res == 1): + print(""No"") +elif (res >= (N/2)): + print(""Yes"") +" +p03944,s695013063,Accepted,"w, h, n = map(int, input().split()) +lis = [] +for i in range(n): + lis.append(list(map(int, input().split()))) +x=0 +y=0 + +for i in lis: + if i[2] == 1: + if x < i[0]: + x=i[0] + elif i[2] == 2: + if i[0] < w: + w=i[0] + elif i[2] == 3: + if y < i[1]: + y=i[1] + else: + if i[1] < h: + h=i[1] +x_a = w-x +y_a= h-y +if x_a < 0 or y_a < 0: + print(0) + exit() +print(x_a*y_a)" +p03419,s119873799,Accepted,"def main(): + n, m = map(int, input().split()) + x, y = min(n, m), max(n, m) + if x == 1 and y == 1: + ans = 1 + elif x == 1: + ans = y - 2 + else: + ans = (x - 2) * (y - 2) + print(ans) + +if __name__ == '__main__': + main() +" +p02596,s301515140,Accepted,"k = int(input()) +now = 7%k +if now == 0: + print(1) + exit() +ans = 1 +for i in range(k+1): + ans += 1 + now *= 10 + now += 7 + now %= k + if now == 0: + break +if now == 0: + print(ans) +else: + print(-1) +" +p03438,s879710515,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +A = 0 +B = 0 +for i in range(n): + A += max(0, (b[i] - a[i]) // 2) + B += max(0, a[i] - b[i]) +if sum(b) >= sum(a): + if A >= B: + print(""Yes"") + exit() +print(""No"")" +p03944,s339660353,Accepted,"w, h, n = map(int, input().split()) +xa = 0 +xb = w +ya = 0 +yb = h +for _ in range(n): + x, y, a = map(int, input().split()) + if a == 1: + xa = max(x, xa) + if a == 2: + xb = min(x, xb) + if a == 3: + ya = max(y, ya) + if a == 4: + yb = min(y, yb) + +print(max(max(xb - xa, 0) * max(yb - ya, 0), 0))" +p02731,s493002767,Accepted,"from decimal import Decimal +from sys import stdin + + +def main(): + input = lambda: stdin.readline()[:-1] + L = input() + + l = Decimal(L) / Decimal('3') + ans = Decimal(l) ** Decimal('3') + print(ans) + + +main() +" +p03835,s653802651,Wrong Answer,"n, s = map(int, input().split()) +cnt=0 +for i in range(n+1): + for j in range(n+1): + S = s-i-j + if S<=n: + cnt+=1 +print(cnt)" +p03557,s385386348,Accepted,"import bisect +from collections import defaultdict +N = int(input()) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) + +ans = 0 +bb = [] +for b in B: + idx = bisect.bisect_right(C, b) + bb += [[b, len(C)-idx]] + +for i in range(len(bb)-1, 0, -1): + bb[i-1][1] += bb[i][1] + +for a in A: + idx = bisect.bisect_right(B, a) + if idx > len(B)-1: + continue + ans += bb[idx][1] +print(ans)" +p03761,s417790263,Accepted,"import sys +def input(): return sys.stdin.readline().strip() +def mapint(): return map(int, input().split()) +sys.setrecursionlimit(10**9) + +N = int(input()) +lis = list(input()) +lis.sort() +for i in range(N-1): + string = list(input()) + nx = [] + for l in lis: + if l in string: + nx.append(l) + string.remove(l) + lis = nx +lis.sort() +print(''.join(lis))" +p03472,s488844000,Accepted,"N, H = map(int, input().split()) +A = [0]*N +B = [0]*N +for i in range(N): + A[i], B[i] = map(int, input().split()) +a = max(A) +B.sort() +ans = 0 +while len(B) > 0 and B[-1] >= a and H > 0: + H -= B.pop() + ans += 1 + if H <= 0: + print(ans) + exit() +print(ans+(-(-H//a)))" +p02570,s755277693,Accepted,"D , T , S = map(int,input().split()) +if(D/S <= T): + print(""Yes"") +else: + print(""No"")" +p03852,s764381535,Accepted,"c=input() + +if ((c==""a"")or(c==""e"")or(c==""i"")or(c==""o"")or(c==""u"")): + print(""vowel"") +else: + print(""consonant"")" +p03067,s542145902,Wrong Answer,"a,b,c = map(int,input().split()) +print (""Yes"") if a <= c <= b else print (""No"") +" +p03693,s669735795,Wrong Answer,"a, b, c = input().split() +num = int(str(a + b + c)) +if type(num/4) == 'int': + print('YES') +else: + print('NO')" +p02786,s448306908,Accepted,"H = int(input()) +count = 0 +i = 0 +while True: + if H == 1: + count += 2**i + break + else: + H = H//2 + count += 2**i + i += 1 + continue +print(count)" +p02996,s563467880,Wrong Answer,"from operator import itemgetter +N = int(input()) +AB = [] +for _ in range(N): + A, B = map(int, input().split()) + AB.append([B-A, A, B]) +AB.sort(key=itemgetter(0)) +cnt = 0 +for _, a, b in AB: + cnt += a + if cnt > b: + print(""No"") + exit() +print(""Yes"")" +p03719,s777251774,Wrong Answer,"a,b,c = map(int, input().split()) +print(['No', 'Yes'][a 9: + print(':(') +else: + print('Yay!')" +p03486,s290472762,Accepted," +s = sorted(input()) +t = sorted(input(),reverse=True) + +if s < t: + print('Yes') +else: + print('No') + +" +p02657,s415511885,Wrong Answer,"A=eval(input().replace('.','').replace(' ','*')) +print(int(A/100))" +p03633,s952532854,Wrong Answer,"import math +import sys +n = int(input()) +t = [int(input()) for _ in range(n)] +if n == 1: + print(t[0]) + sys.exit() +elif n == 2: + print((t[0]*t[1])//(math.gcd(t[0],t[1]))) + sys.exit() +t.sort() +ans = (t[0]*t[1])//math.gcd(t[0],t[1]) +for i in range(2,n-3): + #print((ans*t[i])//math.gcd(ans,t[i])) + ans =((t[i]*ans)//math.gcd(t[i],ans)) +print((ans*t[-1])//math.gcd(ans,t[-1])) +" +p02613,s633855983,Accepted,"N = int(input()) +ac, re, wa, tle = 0,0,0,0 +for i in range(N): + line = input() + if line == ""AC"": + ac += 1 + elif line == ""TLE"": + tle += 1 + elif line == ""WA"": + wa += 1 + elif line == ""RE"": + re += 1 +print(""AC x "" + str(ac)) +print(""WA x "" + str(wa)) +print(""TLE x "" + str(tle)) +print(""RE x "" + str(re))" +p03555,s279106997,Accepted,"a = input() +b = input() + +if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]: + print(""YES"") +else: + print(""NO"")" +p03136,s608125603,Accepted,"N = int(input()) +L = input().split() +max = 0 +count = 0 + +for i in range(N): + count += int(L[i]) + if max < int(L[i]): + max = int(L[i]) + +if count > 2*max: + print(""Yes"") +else: + print(""No"")" +p02819,s143130605,Accepted,"x = int(input()) +for i in range(x,100004): + if all([i%p!=0 for p in range(2,i)]): + print(i) + break" +p02600,s608538671,Accepted,"X = int(input()) +print(10-X//200)" +p02775,s295727340,Wrong Answer,"def main(): + N = [int(x) for x in input()] + dp0 = 0 + dp1 = 1 + for n in N: + # そのまま払う + a = min(dp0 + n, dp1 + 10 - n) + # 1多めに払う + b = min(dp0 + n + 1, dp1 + 10 - (n+1)) + dp0, dp1 = a, b + print(n, dp0, dp1) + print(dp0) + + +if __name__ == '__main__': + main()" +p02888,s943536832,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +res = 0 +for i in range(n-2): + b = a[i:i+3] + b.sort(reverse=True) + if b[0] < b[1] + b[2]: + res += 1 +print(res) +" +p03785,s276509628,Accepted,"N, C, K = map(int, input().split()) +T = [0]*N +cnt = 1 +bus = 1 +for i in range(N): + T[i] = int(input()) +T.sort() +tmp = T[0]+K +for i in range(1, N): + if(cnt == 0): + bus += 1 + cnt = 1 + tmp = T[i]+K + continue + + if(T[i] <= tmp and cnt < C): + cnt += 1 + if(cnt == C): + cnt = 0 + else: + cnt = 1 + bus += 1 + tmp = T[i]+K +print(bus)" +p02909,s581162182,Wrong Answer,"s=input() + +if s == 'Sunny': + print('Cloudy') +elif s == 'Cloudy': + print('Rainy') +else: + print('Rainy')" +p03107,s695147323,Accepted,"s = input() +a = [0,0] +res = 0 +for i in range(len(s)): + if s[i] == '0': + a[0] += 1 + elif s[i] == '1': + a[1] += 1 + if a[0] >= 1 and a[1] >= 1: + res += 2 + a[0] -= 1 + a[1] -= 1 +print(res)" +p02713,s886688466,Accepted,"from math import gcd +K=int(input()) +s=0 +for i in range(1,K+1): + for j in range(1,K+1): + for k in range(1,K+1): + s+=gcd(gcd(i,j),k) +print(s) " +p02963,s333942623,Wrong Answer,"S = int(input()) +v = 10**9 +print(v, -1, 0, 0, S%v, S//v)" +p03030,s180666314,Wrong Answer,"N = int(input()) +S = [None]*N +P = [None]*N + +for i in range(N): + S[i], P[i] = input().split() + +I = [j+1 for j in range(N)] + +x = [(s, p, i) for s, p, i in zip(S, P, I)] + +x.sort(key=lambda x:x[1], reverse=True) +x.sort(key=lambda x:x[0], reverse=False) + +for s, p, i in x: + print(i)" +p03105,s814411134,Accepted,"a,b,c=map(int,input().split()) +m=b//a +print(min(m,c))" +p02699,s991918060,Accepted,"S,W = map(int,input().split()) + +if S<=W: + print(""unsafe"") +else: + print(""safe"")" +p03360,s644802993,Accepted,"a=[0,0,0] +a[0],a[1],a[2]=map(int,input().split()) +k=int(input()) +a=sorted(a) +a[2]=a[2]*(2**k) +print(sum(a))" +p02779,s879988137,Wrong Answer,"import sys +input = sys.stdin.readline + +n = int(input()) +*a, = map(int, input().split()) + +if len(set(a)) == n: + print('Yes') +else: + print('No')" +p02600,s725099814,Accepted,"import sys + +sys.setrecursionlimit(10 ** 6) +int1 = lambda x: int(x) - 1 +p2D = lambda x: print(*x, sep=""\n"") +def II(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LI(): return list(map(int, sys.stdin.readline().split())) +def LLI(rows_number): return [LI() for _ in range(rows_number)] +def SI(): return sys.stdin.readline()[:-1] + +x=II() +print(10-x//200) +" +p02597,s006342256,Accepted,"N = int(input()) +c = input() + +num_r = 0 +for i in range(N) : + if c[i] == 'R' : + num_r += 1 + +ans = 0 +for i in range(num_r, N) : + if c[i] == 'R' : + ans += 1 + +print(ans)" +p03106,s707616621,Accepted,"a,b,k = map(int, input().split()) +ans = 0 +for i in range(100): + if a%(100-i)==0 and b%(100-i)==0: + k -= 1 + if k==0: + ans = 100-i + print(ans) + break" +p03796,s590776424,Wrong Answer,"import math +from functools import reduce +import itertools + +def solve(): + n = int(input()) + p = 1 + for i in range(1,n+1): + p *= i + print(p) + return 0 + +if __name__ == ""__main__"": + solve() +" +p02753,s060677039,Accepted,"import sys + +sys.setrecursionlimit(10 ** 7) +rl = sys.stdin.readline + + +def solve(): + s = set(list(input())) + if len(s) == 1: + print('No') + else: + print('Yes') + + +if __name__ == '__main__': + solve() +" +p03041,s097054076,Wrong Answer,"N,K = map (int, input ().split ()) +a = input () +a = a.replace(a[K-1], '') +print (a)" +p02797,s316081403,Accepted,"N, K, S = map(int,input().split()) + +n = [278]*N +for i in range(K): + n[i] = S +for i in range(N): + print(n[i],end=' ')" +p02682,s108448137,Wrong Answer,"card = list(map(int, input().split())) +count = card[3] - card[0] - (card[1]) +answer = card[0] + +if count <= 0: + print(answer) +else: + count -= card[2] + answer -= count * -1 + print(answer)" +p02571,s346939022,Accepted,"s=input() +t=input() + +count_max = 0 +for i in range(0, len(s)-len(t)+1): + count_tmp = 0 + for j in range(len(t)): + if s[i+j]==t[j]: + count_tmp += 1 + if count_max < count_tmp: + count_max = count_tmp + +print(len(t)-count_max)" +p02570,s900750438,Wrong Answer,"d, t, s = map(int, input().split()) +if d//s > t: + print(""No"") +else: + print(""Yes"")" +p03861,s417180234,Wrong Answer,"import re +import sys +import math +import itertools +import bisect +from copy import copy +from collections import deque,Counter +from decimal import Decimal +import functools +def v(): return input() +def k(): return int(input()) +def S(): return input().split() +def I(): return map(int,input().split()) +def X(): return list(input()) +def L(): return list(input().split()) +def l(): return list(map(int,input().split())) +def lcm(a,b): return a*b//math.gcd(a,b) +sys.setrecursionlimit(10 ** 9) +mod = 10**9+7 +cnt = 0 +ans = 0 +inf = float(""inf"") + +a,b,x = I() +ca = a//x +cb = b//x +ans += cb-ca +if b % x == 0: + ans += 1 +print(ans) +" +p02866,s003999840,Accepted,"N = int(input()) +D = list(map(int, input().split())) + +mod = 998244353 + +from collections import Counter, deque + +def solve(N,D): + if D[0]!=0: + return 0 + c = Counter(D) + if c[0]>1: + return 0 + ans = 1 + m = max(D) + for i in range(1,m): + # if c[i]==0: + # ans = 0 + # continue + ans *= pow(c[i],c[i+1],mod) + ans %= mod + return ans + +print(solve(N,D))" +p02725,s028193761,Accepted,"k,n=map(int,input().split()) +a=list(map(int,input().split())) +ans=0 +for i in range(n-1): + ans=max(a[i+1]-a[i],ans) +ans=max(ans,k-a[-1]+a[0]) +print(k-ans)" +p02771,s158478255,Accepted,"def main(): + a,b,c = map(int, input().split()) + if a == b != c or a != b == c or a == c != b: + print('Yes') + else: + print('No') + + +if __name__ == ""__main__"": + main() +" +p03997,s333208026,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) + +face = (a+b)*h//2 +print(face)" +p02909,s299792109,Accepted,"x = input() + +a,b,c ='Sunny', 'Cloudy', 'Rainy' + +if x ==a: + print(b) +elif x == b: + print(c) +else: + print(a)" +p02699,s938936698,Accepted,"a = input().split("" "") +s = int(a[0]) +w = int(a[1]) + +if w >= s: + print(""unsafe"") +else: + print(""safe"") +" +p02983,s296636467,Accepted,"l, r = map(int, input().split()) +if r - l >= 2019: + print(0) +else: + l %= 2019 + r %= 2019 + if r < l: + print(0) + else: + ans = 2019 + for i in range(l, r): + for j in range(i + 1, r + 1): + ans = min(ans, i * j % 2019) + print(ans) +" +p03264,s534586263,Wrong Answer,"K=int(input()) +if K%2==0: + print(K*K//4) +else: + print(K*(K//2+1)//2)" +p02842,s298236437,Wrong Answer,"import math +N = int(input()) + +ans =0 + +for i in range(N): + if math.floor(i*1.08) == N: + print(i) + ans += 1 + +if ans == 0: + print(':(') + +" +p02879,s956791481,Accepted," +A, B = map(int, input().split()) +if A > 9 or B > 9: + print(-1) +else: + print(A * B)" +p03059,s491648651,Accepted,"a, b, t = map(int, input().split()) +time = t // a +print(time * b)" +p03838,s663920920,Wrong Answer,"x, y = map(int, input().split()) +a = abs(abs(x) - abs(y)) +if x > -1 and y > -1: + print(a) +elif x < 0 and y < 0: + print(a + 2) +else: + print(a + 1) +" +p03345,s833096179,Accepted,"A, B, C, K = map(int, input().split()) +if K % 2 == 0: + print(A-B) +else: + print(B-A)" +p02918,s637828647,Accepted,"N,K=map(int,input().split()) +S=input() +S='.'+S +S=S+'.' +P=0 +for i in range(N): + if S[i+1]=='L': + if S[i]=='L': + P+=1 + else: + if S[i+2]=='R': + P+=1 +print(min(N-1,P+K*2))" +p02583,s130828540,Accepted,"import sys +import itertools + +if __name__ == '__main__': + N = int(sys.stdin.readline()) + L = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split())) + + num = 0 + for items in itertools.combinations(L, 3): + a, b, c = items + if a == b or b == c or c == a: + continue + if a+b > c and b+c > a and c+a > b: + num += 1 + print(num)" +p02712,s458566577,Accepted,"n = int(input()) + +total = [] + + +for i in range(1, n + 1): + if i % 15 == 0: + ""FizzBuzz"" + elif i % 5 == 0: + ""Buzz"" + elif i % 3 == 0: + ""Fizz"" + else: + total.append(i) # リストに加える +print(sum(total))" +p03264,s837136494,Accepted,"import math +k = int(input()) + +if k % 2 == 0: + gusu, kisu = k / 2, k / 2 +else: + gusu, kisu = math.floor(k / 2), math.ceil(k / 2) + +print(int(gusu*kisu))" +p02546,s375543165,Wrong Answer,"s=input() +if s[-1]=='s': + print(s[:-1]+'es') +else: + print(s+'s')" +p03012,s918664702,Accepted,"n = int(input()) +W = list(map(int, input().split())) +sumW = sum(W) + +ans = 10 ** 9 +p = 0 +for w in W: + p += w + ans = min(ans, abs(sumW - 2 * p)) + +print(ans)" +p03814,s929113033,Wrong Answer,"s = input() +a = s.index('A') +print(s[a:].index('Z')+1)" +p03773,s500994648,Wrong Answer,"a,b=(int(x) for x in input().split()) +c = a + b +d = c - 24 + +if int(d) > 0: + print( d ) +else: + print( c )" +p02933,s593375723,Wrong Answer,"n = int(input()) +s = input() +if n >= 3200: + print(""red"") +else: + print(s)" +p02705,s509314553,Wrong Answer,"s = int(input()) +import math +print(s*s*math.pi)" +p03061,s594172009,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +X = [0]*N +Y = [0]*N + +import fractions + +X[0]=A[0] +for i in range(1,N): + X[i] = fractions.gcd(X[i-1], A[i]) + +Y[N-1]=A[N-1] +for i in range(1,N): + Y[N-1-i] = fractions.gcd(Y[N-i], A[N-1-i]) + +cand = [] +cand.append(X[N-2]) +cand.append(X[N-1])#=Y[0] +cand.append(Y[1]) +for i in range(1,N-1): + cand.append(fractions.gcd(X[i-1],Y[i+1])) + +print(max(cand)) +" +p03994,s993180463,Accepted,"s = list(str(input())) +k = int(input()) +for i in range(len(s)): + if s[i] != ""a"": + num = 26-(ord(s[i])-ord(""a"")) + if k >= num: + k -= num + s[i] = ""a"" +s[-1] = chr(ord(""a"")+((ord(s[i])-ord(""a"")+k)%26)) +print("""".join(s))" +p02697,s725533933,Accepted,"N, M = map(int, input().split()) +a, b = 1, N +S = set() +for _ in range(M): + print(a, b) + S.add(b - a) + S.add(a + N - b) + a += 1 + b -= 1 + if b - a in S or a + N - b in S or b - a << 1 == N: + b -= 1" +p03427,s763346610,Accepted,"N=input() +if(N[1:len(N)].count(""9"")!=len(N)-1): + print(int(N[0])-1+9*(len(N)-1)) +else: + print(int(N[0])+9*(len(N)-1)) + +" +p02659,s140733715,Accepted,"import math +from decimal import Decimal + +A, B = map(Decimal, input().split()) +ANS = 0 + +ANS = math.floor(A * B) +print(ANS)" +p03127,s944795447,Wrong Answer,"N = int(input()) +A = list(map(int , input().split())) +max_ = max(A) +A = list(set(A)) +A_ = [] +for i in A: + A_.append(i-(int(max_-(i*int(max_/i))))) +A_ = list(set(A_)) +A_ = sorted(A_) +print(A_[0])" +p03434,s494200270,Accepted,"N=int(input()) +A= list(map(int,input().split())) +list.sort(A,reverse=True) +a=0 +b=0 +for i in range(N): + if(i%2==0): + a+=A[i] + else: + b+=A[i] +print(a-b)" +p02791,s190340984,Accepted,"n=int(input()) +ct=0 +p=list(map(int,input().split())) +mn=p[0] +for i in range(1,n): + if mn>=p[i]: + ct+=1 + mn=p[i] +print(ct+1)" +p02959,s717572554,Wrong Answer,"N, A, B = int(input()), list(map(int, input().split())), list(map(int, input().split())) +result = 0 +for i in range(N): + a, a_next, b = A[i], A[i+1], B[i] + if a >= b: result += b + elif a + a_next < b: + result += a + a_next + a_next = 0 + else: + a_next -= b - a + result += b +print(result)" +p03673,s699675826,Wrong Answer,"from collections import deque +N = int(input()) +A = list(map(int,input().split())) +d = deque() +for i in range(N): + if i%2==0: + d.append(A[i]) + else: + d.appendleft(A[i]) +print(*d)" +p03838,s282694024,Wrong Answer,"x, y = map(int, input().split()) + +if x > 0 and y > 0: + if x < y: + print(y-x) + else: + print(x-y+2) +elif x < 0 and y < 0: + if x < y: + print(y-x) + else: + print(x - y + 2) +else: + print(abs(abs(y) - abs(x)) + 1) +" +p03107,s008709381,Accepted,"# -*- coding: utf-8 -*- +S = input() +red, blue = S.count('0'), S.count('1') +ret = 2 * min(red, blue) +print(ret) + + +" +p02786,s822772668,Accepted,"import sys +import math +def input(): return sys.stdin.readline().rstrip() +def main(): + h=int(input()) + print(2**(int(math.log2(h))+1)-1) + +if __name__=='__main__': + main()" +p03860,s535201154,Accepted,"arr = input().split(' ') +a = list(arr[0]) +b = list(arr[1]) +c = list(arr[2]) +print(a[0],b[0],c[0],sep = '') +" +p03069,s274204273,Accepted,"n=int(input()) +s=input() +w_cnt=s.count(""."") + +ans=[w_cnt] +b=0 +w=w_cnt + +for i in range(n): + if s[i]==""#"": + b+=1 + else: + w-=1 + ans.append(b+w) + +print(min(ans))" +p03162,s383614875,Wrong Answer,"x=int(input()) +count=0 +k=-1 +hap=list(map(int,input().split())) +count=max(hap) +k=hap.index(count) +for i in range(1,x): + hap=list(map(int,input().split())) + m=-1 + for j in range(len(hap)): + if j!=k: + if hap[j]>m: + m=hap[j] + ano=j + count+=m + k=ano +print(count) + + +" +p02606,s104399106,Wrong Answer,"L,R,d = map(int,input().split()) + +r = R//4 +l = (L-1)//4 + +print(r-l)" +p02675,s087620944,Accepted,"a = int(input()[-1]) + +if a in [2, 4, 5, 7, 9]: + print(""hon"") +elif a in [0, 1, 6, 8]: + print(""pon"") +else: + print(""bon"") +" +p03035,s859698510,Accepted,"a, b = map(int, input().split()) + +if a <= 5: + print(0) +elif a <= 12: + print(b // 2) +else: + print(b)" +p02953,s849589449,Accepted,"N = int(input()) +H = [int(x) for x in input().split()] + +MAX = 0 +Flag = True +for T in range(0,N): + if H[T]>MAX: + MAX = H[T] + if MAX-H[T]>=2: + Flag = False + break +if Flag: + print('Yes') +else: + print('No')" +p03435,s263843491,Accepted,"import numpy as np + +c = [] +for i in range(3): + c.append(list(map(int, input().split()))) + +ans = [] + +c = np.array(c) +ch = np.diff(c) + +if np.all(ch[0]==ch[1]) & np.all(ch[1]==ch[2]): + ans.append(True) +else: + ans.append(False) + +cw = np.diff(c.T) + +if np.all(cw[0]==cw[1]) & np.all(cw[1]==cw[2]): + ans.append(True) +else: + ans.append(False) + +ans = ""Yes"" if all(ans) else ""No"" +print(ans)" +p03448,s301452268,Accepted,"five = int(input()) + 1 +hand = int(input()) + 1 +fives = int(input()) + 1 +ans = int(input()) +tmp = 0 + +for i in range(five): + for j in range(hand): + for k in range(fives): + ask = 500 * i + 100 * j + 50 * k + if ans == ask: + tmp = tmp + 1 + +print(tmp)" +p02700,s500842925,Accepted,"a, b, c, d = input().split() +a = int(a) +b = int(b) +c = int(c) +d = int(d) +while True: + c = c - b + if c <= 0: + print(""Yes"") + break + a = a - d + if a<=0: + print(""No"") + break" +p02881,s492615187,Accepted,"def main(): + n = int(input()) + + count = n + 1 + + for i in range(1,int(n**0.5)+1): + if n % i == 0 and n // i + i < count: + count = n // i + i + + print(count-2) + +if __name__ == '__main__': + main()" +p03785,s068137688,Accepted,"def main(): + n, c, k = map(int, input().split()) + t = [int(input()) for _ in range(n)] + t.sort() + ans = 0 + passengers = 0 + first = t[0] + for tn in t: + if tn > first + k or passengers == c: + ans += 1 + passengers = 0 + first = tn + passengers += 1 + + print(ans + 1) + + +if __name__ == '__main__': + main() +" +p02665,s400535850,Accepted,"N=int(input()) +A=list(map(int,input().split())) +tot=sum(A) +cur=1 +total=0 +for d in range(N+1): + if tot>=cur: + total+=cur + cur-=A[d] + tot-=A[d] + if cur<0: + total=-1 + break + cur=min(cur*2,tot) +print(total) " +p02597,s273262724,Accepted,"n = int(input()) +c = input() +l, r = 0, n-1 +ans = 0 +while l < r: + if c[l] == ""W"" and c[r] == ""R"": + ans += 1 + l, r = l+1, r-1 + else: + if c[l] == ""R"": + l += 1 + if c[r] == ""W"": + r -= 1 +print(ans)" +p02842,s870124138,Accepted,"import math +n = int(input()) +a = math.floor(n/1.08) +if a*1.08 >= n: + print(a) +elif (a+1)*1.08 >= n and (a+1)*1.08 < n+1: + print(a+1) +else: + print(':(')" +p02918,s143647895,Accepted,"n,k=map(int,input().split()) +a=list(input()) +count=0 +for i in range(n): + if a[i]==""L"" and i-1>=0 and a[i-1]==""L"": + count+=1 + elif a[i]==""R"" and i+1<=n-1 and a[i+1]==""R"": + count+=1 +print(min(n-1,count+k*2))" +p03274,s934193707,Accepted,"import sys +input = sys.stdin.readline + +def fullsearch(x, k): + for l, r in zip(x, x[k-1:]): + distance = abs(r - l) + yield distance + abs(r) + yield distance + abs(l) + +def main(): + _, K = map(int, input().split()) + X = list(map(int, input().split())) + + + + print(min(fullsearch(X, K))) + +main()" +p03282,s667663743,Accepted,"S = input() +K = int(input()) + +ans = 1 +for i in range(K): + if (S[i] != '1'): + ans = S[i] + break + +print(ans) +" +p03328,s788321051,Accepted,"a,b=map(int,input().split()) +print((b-a)*(b-a-1)//2-a)" +p02783,s709754238,Wrong Answer,"base = input().split() +h = int(base[0]) +a = int(base[1]) +print((h//a)+1)" +p02552,s758272299,Wrong Answer,"# 整数の入力 +N = int(input()) + +print((10 ** (N-2) * N * (N-1) - (N * (N-1))) % (10**9 + 7))" +p03077,s822883892,Accepted,"N=int(input()) +A=[int(input()) for i in range(5)] +X=min(A) +ans=(N+X-1)//X +4 +print(ans)" +p02747,s010787752,Accepted,"S=input() + +for i in range(len(S)): + if i%2==0 and S[i]!=""h"": + print(""No"") + exit() + elif i%2==1 and S[i]!=""i"": + print(""No"") + exit() + +if len(S)%2==0: + print(""Yes"") +else: + print(""No"")" +p02658,s159044387,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +ch = 0 +for i in a: + if(i == 0): + print(0) + ch1 = 1 + break + +if(not ch): + ans = 1 + ch2 = 0 + for i in a: + ans*=i + if(ans > int(1e18)): + print(-1) + ch2 = 1 + break + if(not ch2): + print(ans) + +" +p02777,s635750155,Wrong Answer,"d = dict(zip(input().split(), map(int, input().split()))) +d[input()] -= 1 +print(*d.values()) +" +p02657,s402399445,Accepted,"A,B = map(int,input().split()) +print(A*B)" +p03852,s810044627,Accepted,"c = input() + +if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o': + print('vowel') +else: + print('consonant')" +p02838,s286315815,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +for i in range(n): + a[i] = list(format(a[i],'0b').zfill(65)) +g = [0 for i in range(65)] +for i in range(65): + for j in range(n): + if a[j][i] == '1': + g[i] += 1 +ans = 0 +for i in range(len(g)): + ans += g[i]*(n-g[i])*(2**(64-i)) + ans = ans%1024 +print(int(ans))" +p03037,s403074733,Wrong Answer,"n,m = map(int,input().split()) +gate = [1,n] +for i in range(m): + l,r = map(int,input().split()) + gate[0] = max(gate[0],l) + gate[1] = min(gate[1],r) +print(gate[1]-gate[0]+1)" +p02690,s198557466,Accepted,"X=int(input()) +for A in range(120): + for B in range(120): + if A**5-B**5==X: + print(A,B) + exit() + if A**5+B**5==X: + print(A,B*(-1)) + exit() + + + + + + + + + + + + + + + + + + + + + + + +" +p03103,s628195042,Accepted,"n,m=map(int,input().split()) +ab=[list(map(int,input().split())) for i in range(n)] + +ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1])) + +num = 0 +amount_of_money = 0 +for i in range(n): + buy = min(ab_sorted[i][1], m-num) + num += buy + amount_of_money += ab_sorted[i][0] * buy + + if num >= m: + print(amount_of_money) + exit(0) +" +p02989,s127555425,Accepted,"n = int(input()) +d = sorted(list(map(int, input().split()))) + +t = n//2 +print(d[t]-d[t-1])" +p03161,s503078920,Accepted,"n, k = map(int, input().split()) +h = list(map(int, input().split())) +dp = [float('Inf')] * (10 ** 5 + 1) +dp[0] = 0 +for i in range(n): + for j in range(1, k + 1): + if i + j < n: + dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) +print(dp[n - 1]) +" +p02596,s323483959,Accepted,"k = int(input()) + +s = 7 +for i in range(1, k+1): # rangeの上限がk + if s % k == 0: + print(i) + break + s = (s * 10 + 7) % k # %kが難しい +else: # for文にもelseが使える + print(-1)" +p03944,s615083395,Accepted,"w,h,N=map(int,input().split()) +X,Y,W,H=0,0,w,h +for i in range(N): + x,y,a=map(int,input().split()) + if a==1:X=max(x,X) + elif a==2:W=min(W,x) + elif a==3:Y=max(y,Y) + else:H=min(y,H) + if X>=w or Y>=h or W<=0 or H<=0 or X>=W or Y>=H: + print(0) + exit() +print((W-X)*(H-Y))" +p03797,s896139132,Accepted,"n, m = map(int, input().split()) +ans = 0 +if m >= 2*n: + ans += n + (m-2*n)//4 +else: + ans += m//2 +print(ans)" +p02743,s422466249,Accepted,"from decimal import * +import math + +getcontext().prec = 50 + +a, b, c = map(int, input().split()) +a = Decimal(a) +b = Decimal(b) +c = Decimal(c) + +a = Decimal.sqrt(a) +b = Decimal.sqrt(b) +c = Decimal.sqrt(c) + +if a + b < c: + print(""Yes"") +else: + print(""No"")" +p02596,s040263855,Accepted,"K = int(input()) +X = 7 +p = 0 +for i in range(1, K+2): + p = (p + X)%K + if(p == 0): + print(i) + exit() + X = (X*10)%K +print(-1)" +p03042,s281770079,Accepted,"s = input() +a = 0 +b = 0 + +if s[2] == '0': b = int(s[3]) +else: b = int(s[2:]) +if s[0] == '0': a = int(s[1]) +else: a = int(s[:2]) + +if (b>=1 and b<=12) and (a>=1 and a<=12): print(""AMBIGUOUS"") +elif b>=1 and b<=12: print(""YYMM"") +elif a>=1 and a<=12: print(""MMYY"") +else: print(""NA"") " +p03861,s437369148,Accepted,"a,b,x = (int(T) for T in input().split()) +print((b//x)-(a//x)+(a%x==0))" +p03243,s446061875,Accepted,"n = int(input()) + +for num in range(n, 1000): + if num % 111 == 0: + print(num) + break" +p03136,s654203250,Accepted,"n = int(input()) +l = list(map(int,input().split())) + +longest =max(l) + +index = l.index(longest) + +total = 0 +for i in range(n): + if i!=index: + total+=l[i] + +if longestx: + break + +print(len(d)-1)" +p03611,s830015074,Accepted,"from collections import Counter as C + +n = int(input()) +a= list(input().split()) +al = list([int(i) for i in a]) +aset = set([int(i) for i in a]) + +cnt=0 +ca = C(al) +#print(C(al)[0]) +for i in aset: + #print(i) + #print(al.count(i-1),al.count(i),al.count(i+1)) + if cnt < ca[i-1] + ca[i] + ca[i+1]: + cnt = ca[i-1] + ca[i] + ca[i+1] + +print(cnt)" +p03861,s722630778,Wrong Answer,"a,b,x=map(int,input().split()) +d=b-a +ans=d//x +if a%x==0 or b%x==0: + ans+=1 +if a==b: + ans=0 +print(ans)" +p02972,s923417817,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +hako=[0]*n +for i in range(n): + # print(n-i-1, sum(hako[n-i-1:n:n-i])) + if (sum(hako[n-i-1:n:n-i])%2)!=a[n-i-1]: + hako[n-i-1]+=1 +# print(hako) + +ans=[] +for i in range(n): + if hako[i]==1: + ans.append(str(i+1)) + +print(len(ans)) +if len(ans)!=0: + print(' '.join(ans)) +" +p03329,s809173671,Accepted,"n = int(input()) + +dp = [10**6 for _ in range(10**6)] +dp[0] = 0 + +for i in range(1,n+1): + j6 = 1 + while 0 <= i-j6: + dp[i] = min(dp[i-j6]+1,dp[i]) + j6 *= 6 + j9 = 1 + while 0 <= i-j9: + dp[i] = min(dp[i-j9]+1,dp[i]) + j9 *= 9 +print(dp[n])" +p02683,s619949862,Wrong Answer,"N,M,X = map(int, input().split()) +A = [list(map(int, input().split("" ""))) for i in range(N)] + +MOD = 10**9+7 +a = [0]*M +value = MOD +ans = MOD + +for i in range(2**N): + if min(a) >= X : + ans = min(ans,value) + a = [0]*M + value = 0 + + for j in range(M+1): + if(i >> j) & 1: + for k in range(M): + a[k] += A[j][k+1] + value += A[j][0] + +print(-1 if ans == MOD else ans) +" +p03274,s610542653,Wrong Answer,"N,K = map(int,input().split()) +candle = list(map(int,input().split())) + +min_value = 10*6 + +for i in range(N-K+1): + left = abs(candle[i])+abs(candle[i]-candle[i+K-1]) + right = abs(candle[i+K-1])+abs(candle[i]-candle[i+K-1]) + if min_value > min(left,right): + min_value = min(left,right) + + +print(min_value) +" +p02675,s303729395,Accepted,"N = int(input()) +if (N%10 == 2) or (N%10 == 4) or (N%10 == 5) or (N%10 == 7) or (N%10 == 9): + print(""hon"") +elif (N%10 == 0) or (N%10 == 1) or (N%10 == 6) or (N%10 == 8): + print(""pon"") +else: + print(""bon"")" +p02778,s699819577,Accepted,"#!/usr/bin/env python3 +import re +s = input() +print(re.sub(r'[a-z]','x',s))" +p03611,s679927965,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +a_n = [] + +for i in range(n): + a_n.append(a[i]) + a_n.append(a[i]-1) + a_n.append(a[i]+1) + + +counter=Counter(a_n) + +print(a_n.count(counter.most_common()[0][0])) + + + + + + + +" +p02701,s791699042,Accepted,"N = int(input()) + +S = [] +cnt = 0 +for n in range(N): + temp = input() + S.append(temp) + +S = set(S) +print(len(S))" +p02814,s536887885,Wrong Answer,"import fractions +N, M = map(int, input().split()) +AA = list(map(int, input().split())) +A = list(map(lambda x:x//2, AA)) + +ans = A[0] +for i in range(1, N): + ans = ans * A[i] // fractions.gcd(ans, A[i]) + +ans = (M//ans - 1)//2 + 1 if ans > 0 else 0 +print(ans)" +p02922,s693769912,Accepted,"import sys +from collections import defaultdict +readline = sys.stdin.buffer.readline +#sys.setrecursionlimit(10**8) + + +def geta(fn=lambda s: s.decode()): + return map(fn, readline().split()) + + +def gete(fn=lambda s: s.decode()): + return fn(readline().rstrip()) + + +def main(): + a, b = geta(int) + + if b == 1: + print(0) + exit() + + n = 1 + while a * n - n + 1 < b: + n += 1 + + print(n) + + +if __name__ == ""__main__"": + main()" +p02996,s763303259,Accepted,"from operator import itemgetter +N = int(input()) +ls = sorted(sorted([list(map(int,input().split())) for _ in range(N)]),key=itemgetter(1)) + + + +flag = 1 +t = 0 +for i in range(N): + t += ls[i][0] + if ls[i][1] < t: + flag = 0 + print(""No"") + break + +if flag == 1: + print(""Yes"")" +p03556,s177047745,Accepted,"N=int(input()) +print(int(N**0.5)**2) +" +p03910,s069798232,Accepted,"N=int(input()) + +i=1 +Sum=0 +while Sum=0: + N-=Top + ans.append(Top) + Top-=1 + +for j in ans: + print(j)" +p03548,s888604503,Accepted,"x,y,z=[int(x) for x in input().split()] +x-=z +print(x//(y+z))" +p03696,s204294827,Accepted,"n = int(input()) +N = input() +L = 0 +R = 0 +num = 0 +for c in N: + if c == '(': + num += 1 + else: + if num: + num -= 1 + else: + L += 1 +R = num + +print('('*L+N+')'*R)" +p03799,s321085397,Accepted,"n,m = map(int,input().split()) +cnt = 0 +if m // 2 >= n: + cnt += n + m -= n*2 +else: + cnt += m//2 + n -= m//2 + m -= m + +#print(n,m) +cnt += m//4 + +print(cnt) +" +p02939,s895595878,Accepted,"S = input() +lis = [S[0]] +i = 1 +while ib: + print('safe') +else: + print('unsafe') + " +p03836,s285918743,Wrong Answer,"walklist=[] +a,b,c,d=map(int,input().split()) +x_diff=c-a +y_diff=d-b +walklist.append(""U""*y_diff) +walklist.append(""R""*x_diff) +walklist.append(""D""*y_diff) +walklist.append(""L""*(x_diff+1)) +walklist.append(""U""*(y_diff+1)) +walklist.append(""R""*(x_diff+2)) +walklist.append(""D""*(y_diff+2)) +walklist.append(""L""*(x_diff+1)) +walklist.append(""U"") +print("""".join(walklist)) +" +p02717,s716835088,Accepted,"a,b,c=map(int,input().split()) +print(c,a,b)" +p03827,s294918202,Wrong Answer,"N = int(input()) +S = input() + +ans = 0 +x = 0 +for s in S: + v = 1 if s == 'I' else 0 + x += v + ans = max(ans, x) +print(ans) +" +p02916,s886668849,Wrong Answer," +n = int(input()) + +a = list(map(int,input().split())) +b = list(map(int,input().split())) +c = list(map(int,input().split())) +sum = 0 + +for i in range(len(a)): + sum += b[a[i] - 1] + print(""i:{0} sum{1}"".format(i, sum)) + if(i != len(a) - 1 and a[i] + 1 == a[i + 1]): + sum += c[a[i] - 1] + #print(""i:{0} sum{1}"".format(i, sum))# + +print(sum)" +p03407,s468923695,Accepted,"a, b, c = map(int, input().split()) +if a+b < c: + print(""No"") +else: + print(""Yes"")" +p04043,s834675936,Accepted,"num = list(map(int, input().split())) + +ans = sorted(num) +if(ans[0]==5 and ans[1]==5 and ans[2] == 7): + print(""YES"") +else: + print(""NO"")" +p02596,s537820126,Accepted,"k=int(input()) +ans=1 +judge=0 +s=7%k +while ans<=k: + if s==0: + judge=1 + break + else: + s=s*10+7 + s%=k + ans+=1 +if judge==1: + print(ans) +else: + print(-1) +" +p02555,s573279395,Accepted,"import numpy as np +from functools import reduce + + +mod = 10**9+7 +def cmb(R,B): + numerator = reduce(lambda x,y: x * y % mod, [R+B-k for k in range(B)]) + denominator = reduce(lambda x, y: x * y % mod, [B-k for k in range(B)]) + return numerator * pow(denominator, mod - 2, mod) % mod + + +S = int(input()) +p = S // 3 +A = 0 + +for b in range(p): + + r = S-3*(b+1) + + if b == 0: + A+=1 + else: + A+=cmb(r,b) + +print(A%mod) + + + +" +p03250,s608575958,Accepted,"abc=list(map(int,input().split())) +abc.sort(reverse=True) +print(abc[0]*10+abc[1]+abc[2]) +" +p03487,s791314115,Accepted,"import collections + +n = int(input()) +a = list(map(int,input().split())) +c = collections.Counter(a) + +cnt = 0 +for k,v in c.items(): + cnt += min(v-k,v) if v-k >=0 else v +print(cnt) +" +p02688,s749296799,Wrong Answer,"n, k = map(int, input().split()) + +okashi = set(list(range(1, n))) + +for i in range(k): + d = int(input()) + A = set(map(int, input().split())) + okashi = okashi - A +print(len(okashi))" +p02613,s510576945,Accepted,"N = int(input()) +status = [] +for i in range(N): + S = str(input()) + status.append(S) + +print('AC x %d'% status.count(""AC"")) +print('WA x %d'% status.count('WA')) +print('TLE x %d'% status.count('TLE')) +print('RE x %d'% status.count('RE'))" +p02598,s032526303,Wrong Answer,"def main(): + import sys + def input(): return sys.stdin.readline().rstrip() + n , k = map(int, input().split()) + a = list(map(int, input().split())) + from heapq import heappop, heappush, heapreplace + a = [-x for x in a] + a.sort() + for i in range(k): + x = a[0] + if abs(x) < 1: + break + heapreplace(a, x//3) + heappush(a, x-x//3) + ans = abs(a[0]) + print(ans) + + + +if __name__ == '__main__': + main()" +p03324,s244888782,Wrong Answer,"d,n = map(int,input().split()) +if d == 0: + print(n) +else: + print(n * 100**d )" +p03698,s801562561,Wrong Answer,"S = input() + +if len(set(S)) == len(S) : + print('Yes') +else: + print('No') +" +p02684,s398397499,Accepted,"n,k = map(int, input().split()) +a = list(map(int, input().split())) +a.insert(0,0) +now = 1 +seen = [0]*(n+1) +seen[1] = 1 +for i in range(1,n+1): + now = a[now] + if seen[now] != 0: + break + else: + seen[now] = i+1 +if k <= max(seen): + print(a[seen.index(k)]) +elif (k - max(seen)) % (max(seen)-seen[now]+1) == 0: + print(a[seen.index(max(seen))]) +else: + print(a[seen.index(max(seen) - (max(seen)-seen[now]+1) + (k - max(seen)) % (max(seen)-seen[now]+1))])" +p02554,s664833577,Accepted,"n = int(input()) +mod = 10**9 + 7 +ans = (pow(10, n, mod) - ((2 * pow(9, n, mod)) % mod - pow(8, n, mod) + mod) % mod + mod) % mod +print(ans) +" +p02879,s194421725,Wrong Answer,"a,b = map(int,input().split()) +if a*b > 81: + print(-1) +else: + print(a*b)" +p03637,s439528937,Wrong Answer,"N = int(input()) +a = list(map(int, input().split())) + +four = 0 +not_four = 0 + +for i in range(N): + if a[i] % 4 == 0: + four += 1 + + else: + not_four += 1 + +while four > 0 and not_four > 0: + four -= 1 + not_four -= 2 + +if four == 0 and not_four <= 0: + print(""Yes"") +else: + print(""No"") +" +p03471,s725792635,Accepted,"N,Y = [int(i) for i in input().split()] +for i in range(N+1): + for j in range(N-i, -1, -1): + money = i*10000 + j*5000 + (N - i - j)*1000 + if money == Y: + print(i,j,N-i-j) + exit() + elif money < Y: + break +print(-1,-1,-1)" +p02847,s204125860,Accepted,"s = input() +arr = [""SUN"",""MON"",""TUE"",""WED"",""THU"",""FRI"",""SAT""] +for i in range(7): + if s==arr[i]: + print(7-i)" +p03408,s139978399,Wrong Answer,"n=int(input()) +s=[] +for i in range(n): + s.append(input()) +m=int(input()) +t=[] +for i in range(m): + t.append(input()) +from collections import Counter +s=Counter(s) +t=Counter(t) +ans=-1000000 +for i in s: + ans=max(ans,s[i]-t.get(i,0)) +print(ans) + + " +p02645,s675982605,Accepted,"s=input() +print(s[:3])" +p03071,s222097668,Wrong Answer,"A,B = map(int,input().split()) +res = 0 +if A >= B: + res += A + A-= 1 + if A >= B: + res += A + else: + res += B + print(res) +else: + res += B + B-= 1 + if A >= B: + res += A + else: + res += B + print(res)" +p03803,s074255016,Wrong Answer,"# aアリス   bボブ +a, b = map(int, input().split()) +if a < b: + print(""Bob"") +elif b < a: + print(""Alice"") +elif a == b: + print(""Draw"") +" +p03219,s255289022,Wrong Answer,"x, y = map(int, input().split()) +print(x+y/2) +" +p03219,s109411693,Wrong Answer,"x,y=map(int,input().split()) +print(x+y/2)" +p02814,s818650291,Accepted,"from functools import reduce +import fractions +n, m = map(int, input().split()) +a = [int(x)//2 for x in input().split()] + +y = a[0] + +for i in range(1,n): + y = y*a[i] // fractions.gcd(y,a[i]) + if y > m: + print(0) + exit() + +for i in range(n): + if (y // a[i]) % 2 == 0: + print(0) + exit() + +x = m//y + +if x % 2 == 0: + print(x//2) +else: + print((x+1)//2) +" +p03162,s813634368,Wrong Answer,"N = int(input()) +Q = [] +for _ in range(N): + Q.append(list(map(int, input().split()))) + +dp = [(0, 0) for _ in range(N)] +for i,v in enumerate(Q[0]): + if v>dp[0][1]: + dp[0] = (i, v) + +for i in range(1, N): + for j, v in enumerate(Q[i]): + if j!=dp[i-1][0] and dp[i][1]1: + print(-1) + exit() + else: + print(ans) +else: + ans = max(1, a[1]) + for i in range(2, n+1): + ans = ans*10+max(0, a[i]) +print(ans) +" +p03962,s544877331,Accepted,"l=list(map(int,input().split())) +l=set(l) +print(len(l)) +" +p03693,s895556033,Accepted," +r,g,b = map(int,input().split()) +a = r *100+g*10+b +if a % 4 == 0: + print('YES') +else: + print('NO')" +p03657,s858647829,Accepted,"a, b = map(int, input().split()) + +if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0: + print('Possible') +else: + print('Impossible') " +p03150,s407384604,Wrong Answer,"from sys import exit +import math +ii = lambda : int(input()) +mi = lambda : map(int,input().split()) +li = lambda : list(map(int,input().split())) + +s=input() + +key = ""keyence"" + +for i in range(len(s)): + j = i + len(s) -7 + if s[:i] + s[j:] == key: + print(""Yes"") + exit() +print(""No"")" +p02760,s235360310,Wrong Answer,"# ABC157 B +import numpy as np +a = [list(input()) for i in range(3)] +a = np.ravel(a) +n = int(input()) +b = [input() for i in range(n)] +ans = 'No' +for i in b: + for j in range(3): + if i in a[j*3:j*3+2] or i in a[j:j+6:3]: + ans = 'Yes' + if i in a[0:8:4] or i in a[2:6:2]: + ans = 'Yes' +print(ans)" +p03951,s507692770,Accepted,"N = int(input()) +s = input() +t = input() +i = 0 +while True: + if s[i:] == t[:(N - i)]: + break + i += 1 +print(N + i) +" +p03012,s247059288,Accepted,"n = int(input()) +w = list(map(int, input().split())) +s = [0]*(n+1) +for i in range(n): + s[i+1] = s[i] + w[i] +ans = 1000000 +for i in range(n+1): + ab = abs(s[i] - (s[n]-s[i])) + if ans >= ab: + ans = ab + +print(ans)" +p03379,s580971226,Accepted,"n = int(input()) +x = list(map(int,input().split())) +a = sorted(x) +m1,m2 = a[n//2-1],a[n//2] +for i in x: + if i>=m2:print(m1) + else:print(m2)" +p02690,s388515316,Wrong Answer,"def get_answer(): + x = int(input()) + + is_get = False + for a in range(1000000000): + if is_get: + break + for b in range(-1*a, a, 1): + if x == a**5 - b**5: + is_get = True + break + + print(f""{a-1} {b}"")" +p03672,s519397546,Wrong Answer,"s = input() +n = len(s) +s = s[:-2] +for _ in range(n): + n = len(s) + m = int(n/2) + if s[:m] == s[m:]: + print(s) + break + else: + s = s[:-2]" +p03254,s956369362,Accepted,"N, x = map(int, input().split()) +array = list(map(int, input().split())) +a = sorted(array, reverse=False) +#print(a) +answer = 0 +for i in range(N): + x -= a[i] + if x < 0: + break + answer += 1 + if i == N-1 and x != 0: + answer -= 1 + break + if x < a[i]: + break +print(answer) +" +p02880,s737652862,Wrong Answer,"N=int(input()) + +for i in range(1,10): + for j in range(1,10): + if i+j==N: + print(""Yes"") + exit() + +print(""No"")" +p03352,s381926341,Wrong Answer,"import sys +import math + +input = sys.stdin.readline +MOD = 1000000007 + +X = int(input()) + +sa = 100000 +res = 0 + +if X == 1: + print(1) +else: + for i in range(2,X): + a = int(math.log(X,i)) + if (sa > (X - (i**a))) & ( a != 1): + sa = X - (i**a) + res = i**a + + print(res) +" +p02646,s113298787,Accepted,"A,V = map(int, input().split()) +B,W = map(int, input().split()) +T = int(input()) + +if A == B or V-W > 0 and abs(A-B) <= T*(V-W): + print('YES') +else: + print('NO') + +" +p03075,s127761504,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) +if e - a > k: + print(""Yay!"") +else: + print("":("") +" +p02714,s166939463,Wrong Answer,"N=int(input()) +S=input() +r,g,b = S.count('R'),S.count('G'),S.count('B') +total = r*g*b + +count = 0 +for d in range(1,N//2): + for i in range(N-2*d): + if S[i]!=S[i+d] and S[i+d]!=S[i+2*d] and S[i+2*d] != S[i]: + count+=1 + +print(total-count) + " +p02682,s610257449,Accepted,"s = input().split() +numOfA = int(s[0]) +numOfB = int(s[1]) +numOfC = int(s[2]) +pickNum = int(s[3]) +maxOutcome = 0 + +if pickNum < numOfA: + maxOutcome = pickNum +elif pickNum >= numOfA and pickNum <= (numOfA + numOfB): + maxOutcome = numOfA +elif pickNum >numOfA +numOfB: + maxOutcome = numOfA - (pickNum - numOfA - numOfB) + +print(maxOutcome)" +p03282,s651857520,Wrong Answer,"s = str(input()) +k = int(input()) +for i in range(len(s)): + if s[i] != ""1"": + print(s[i]) + break +else: + print(1)" +p02789,s469178850,Accepted,"n, m = map(int, input().split()) + +if n == m: + print(""Yes"") +else: + print(""No"") + + +" +p02720,s245374983,Accepted,"from collections import deque + +k = int(input()) + +a = deque([9,8,7,6,5,4,3,2,1]) +current_num = 0 + +for i in range(k): + current_num = a.pop() + current_str = str(current_num) + current_last = int(current_str[-1]) + + up = """" + mid = current_str + str(current_last) + down = """" + + if current_last >= 0 and current_last <= 8: + up = current_str + str(current_last + 1) + + if current_last >= 1 and current_last <= 9: + down = current_str + str(current_last - 1) + + if len(down) != 0: + a.appendleft(down) + + a.appendleft(mid) + + if len(up) != 0: + a.appendleft(up) + +print(current_num)" +p03012,s507430337,Wrong Answer,"N = int(input()) +l = list(map(int, input().split())) + +new_l = sorted(l) +ans = 99999 + +for i in range(N): + f = sum(new_l[:i]) + s = sum(new_l[i:]) + if abs(f-s)<=ans: + ans = abs(f-s) + +print(ans)" +p03548,s961166000,Accepted,"X, Y, Z = map(int, input().split()) + +print((X - Z) // (Y + Z)) +" +p03730,s504532373,Accepted,"# https://atcoder.jp/contests/abc060/tasks/abc060_b +a, b, c = map(int, input().split()) + +t = a +s = 0 +while True: + s = (t % b) % b + t += a + if s == c: + print('YES') + break + elif s == 0: + print('NO') + break +" +p02690,s681130687,Accepted,"def solve(): + x = int(input()) + + for a in range(-118, 120): + for b in range(-119, 119): + if a**5 - b**5 == x: + return a, b + + + + + +print(*solve()) +" +p03293,s010525072,Accepted,"S = input() +T = input() + +count = ""No"" +for i in range(len(S)): + S = S[-1] + S[:-1] + if S == T: + count = ""Yes"" + +print(count)" +p03862,s910899291,Accepted,"n,x,*a = map(int,open(0).read().split()) +b = [0]*n +b[0] = min(x,a[0]) +for i in range(n-1): + b[i+1] = max(min(x-b[i],a[i+1]),0) + b[i] = min(b[i],x-b[i+1]) +ans = 0 +for i,j in zip(a,b): + ans += i-j +print(ans)" +p02946,s829067265,Accepted,"K,X=map(int,input().split()) + +def create_num(K,X): + ans = [X-(K-1) + i for i in range(K*2-1)] + return ans + +if K == 1: + print(X) +else: + ans = create_num(K,X) + L=[str(a) for a in ans] + L="" "".join(L) + print(L) + +" +p03387,s857937862,Wrong Answer,"A = list(map(int,input().split())) +A.sort() +ret = 0 +ret += A[2]-A[1] +A[1] += ret +A[0] += ret +ret += (A[1]-A[0]-1+2)//2 +print(ret)" +p02767,s687870018,Accepted,"n = int(input()) +X = list(map(int, input().split())) + +ans = 10 ** 10 +for i in range(1, 101): + hp = 0 + for x in X: + hp += (x - i) ** 2 + ans = min(ans , hp) +print(ans)" +p03286,s309969618,Accepted,"N=int(input()) + +b=-2 +temp=N +ans="""" +while True: + if temp%b!=0: + ans=""1""+ans + temp=temp-(b//(-2)) + else: + ans=""0""+ans + b=b*(-2) + if temp==0:break + +print(ans) +" +p02694,s765690606,Accepted,"X = int(input()) +t = 100 +i = 1 + +while True: + t = int(t*1.01) + if t >= X: + print(i) + break + i += 1" +p03821,s998113492,Wrong Answer,"N = int(input()) +AB = [0] * N +for n in range(N): + AB[-1-n] = [int(x) for x in input().strip().split()] +ans = 0 +cnt = 0 +for (a, b) in AB: + if b == 1: + continue + t = b - ((a + cnt) % b) + cnt += t + ans += t +print(ans)" +p03814,s242262096,Wrong Answer,"s=input() + +for i in range(len(s)): + if s[i]=='A': + a=i +for i in reversed(range(len(s))): + if s[i]=='Z': + x=i +print(x-a+1) +" +p03331,s695626551,Accepted,"n=int(input()) +ans=float('inf') + +def digitSum(n): + # 数値を文字列に変換 + s = str(n) + # 1文字ずつ数値化し配列にする。 + array = list(map(int, s)) + # 合計値を返す + return sum(array) + +for i in range(1,n): + a=i + b=n-i + ans=min(ans,digitSum(a)+digitSum(b)) + +print(ans)" +p02688,s432579277,Wrong Answer,"def resolve(): + N, K = map(int, input().split()) + A = [] + for i in range(K): + d = int(input()) + a = map(int, input().split()) + A.append(a) + print(N - len(set(A))) +resolve()" +p04020,s233902622,Wrong Answer,"import math +N=int(input()) +ans=0 +A=[] +for i in range(N): + a=int(input()) + + ans+=a//2 + a%=2 + + if i!=0: + if A[i-1]==1 and a==1: + ans+=1 + a-=1 + A.append(a) +print(ans) + + " +p02633,s001403360,Accepted,"import math +n=int(input()) +print(int(360/math.gcd(n,360)))" +p03545,s129503365,Wrong Answer,"x = str(input()) +l = [x[0], x[1], x[2], x[3]] +m = [int(s) for s in l] +N = 2 ** 3 +for i in range(N): + n = [m[0], 0, 0, 0] + o = [] # +か-かを記憶 + for j in range(3): + if (i >> j) & 1: + n[-j-1] = -m[-j-1] + o.append('-') + else: + n[-j-1] = m[-j-1] + o.append('+') + if sum(n) == 7: + print(str(m[0]) + o[0] + str(m[1]) + o[1] + str(m[2]) + o[2] + str(m[3]) + '=7') + exit()" +p03986,s653151125,Wrong Answer,"x=list(input()) +t=x.count(""T"") +s=x.count(""S"") +num=0 +num2=0 +if x[0]==""T"": + num=1 + for i in range(1,len(x)): + if x[i]==""S"": + break + else: + num+=1 +if x[-1]==""S"": + num2=1 + for i in range(len(x)-1): + if x[-2-i]==""T"": + break + else: + num2+=1 +t-=num +s-=num2 +print((s+t)-(min(s,t)*2)+num+num2) +" +p02621,s131324899,Wrong Answer," + +a = int(input(""\n"")) + +if a >= 10: + print(""Number too big"") + +elif a <= 0: + print(""Number too small"") + +else: + print(a + (a**2) + (a**3))" +p03469,s871112166,Wrong Answer,"import datetime + +S = input() +S = datetime.datetime.strptime(S, '%Y/%m/%d') + + + +a = int(S.year) + +if a != 2018: + S = S.replace(2018) + +print(S)" +p03339,s552786584,Accepted,"n = int(input()) +s = list(input()) +cnt = 0 +ans_list = [0] +e_cnt = 0 + +for i in range(1,n): + if s[i-1] == ""E"" and s[i] == ""E"": + cnt -= 1 + e_cnt += 1 + if s[i-1] == ""E"" and s[i] == ""W"": + cnt -= 0 + if s[i-1] == ""W"" and s[i] == ""E"": + cnt += 0 + e_cnt += 1 + if s[i-1] == ""W"" and s[i] == ""W"": + cnt += 1 + ans_list.append(cnt) + +print(min(ans_list) + e_cnt)" +p02724,s763250196,Accepted,"x = int(input()) +a = x//500 +x = x - a*500 +b = x//5 +print(a*1000+b*5)" +p03705,s628454766,Accepted,"n,a,b = map(int,input().split()) + +ans = 0 +if n==0 or (n==1 and a!=b) or (a>b): + pass +elif (n==1) and (a==b): + ans = 1 +else: + ans = (n-2)*(b-a)+1 + +print(ans) " +p02663,s968968154,Wrong Answer,"h1, m1, h2, m2, k = map(int, input().split()) + +sabunh = h2 - h1 +sabunm = m2 - m1 +zikantai = sabunh * 60 + sabunm +ans = 0 +zikantai -= k +while(zikantai > 0): + zikantai -= k + ans += k +print(ans)" +p03986,s691003160,Wrong Answer,"x=input() +ans=0 +ind=x.find(""ST"") +while(ind!=-1): + ans+=2 + s_ind=ind-1 + t_ind=ind+2 + while(0<=s_ind and t_ind= H[i+1]: + cnt+=1 + else: + maxcnt = max(maxcnt,cnt) + cnt=0 + + +result = max(maxcnt,cnt) + + +print(result) +" +p03721,s556810612,Accepted,"N, M = map(int, input().split()) + +res = [0]*10**5 + +for i in range(N): + a, b = map(int, input().split()) + res[a-1]+=b + +count = 0 +for i,r in enumerate(res): + count+=r + if count >= M: + print(i+1) + break +" +p02608,s607359372,Accepted,"n = int(input()) +ans = [0 for i in range(10**5)] +for x in range(1,100): + for y in range(1,100): + for z in range(1,100): + ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1 + +for i in range(1,n+1): + print(ans[i])" +p02882,s571155496,Accepted,"from math import atan,degrees +a,b,x = map(int,input().split()) +if x <= a*a*b/2: + ans = atan(a*b*b/(2*x)) +else: + ans = atan(2*b/a-2*x/a**3) +print(degrees(ans))" +p02922,s534782734,Accepted,"a, b = map(int, input().split()) + +s=a-1 +t=b-1 +ans=(t+s-1)//s +print(ans)" +p02595,s765227390,Wrong Answer,"import math +n,d=map(int,input().split()) +a = [list(map(int, input().split())) for l in range(n)] +sum=0 +for i in range(len(a)-1): + for j in range(1): + if d >= math.sqrt(a[i][j]**2+a[i+1][j+1]**2): + sum+=1 +print(sum)" +p03437,s530853778,Accepted,"X,Y=map(int,input().split()) + +if X%Y==0: + print(-1) +else: + for i in range(1,(10**18)//X+1): + if i*X%Y!=0: + print(i*X) + break" +p04030,s686241900,Wrong Answer,"s = input() +ans = [] +ans_2 = """" +for i in range(len(s)): + if s[i] == ""0"": + ans.append(""0"") + elif s[i] == ""1"": + ans.append(""1"") + elif s[i] == ""B"": + if len(ans) == 0: + continue + else: + ans.remove(ans[len(ans)-1]) +for i in range(len(ans)): + ans_2 += str(ans[i]) +print(ans_2)" +p03001,s151594839,Accepted,"w,h,x,y = map(int, input().split()) + +print(w * h / 2, 1 if (x == w / 2) and (y == h / 2) else 0) + +" +p03838,s255833296,Accepted,"x, y = map(int, input().split()) +ans = abs(abs(x)-abs(y)) +if x*y > 0: + if x <= y: + print(ans) + else: + print(ans+2) +elif x*y < 0: + print(ans+1) +else: + if x <= y: + print(ans) + else: + print(ans+1) + " +p02765,s334853950,Wrong Answer,"N,R = map(int,input().split()) +if N < 10: + print(R + 100*(100-N)) +else: + print(R)" +p03623,s430163965,Wrong Answer,"a,b,c = map(int,input().split()) + +if abs(a-b) > abs(a-c): + print('A') +else: + print('B')" +p04043,s683825737,Accepted,"a = [int(x) for x in input().split()] + +if a.count(5) == 2 and a.count(7) == 1: + print(""YES"") +else: + print(""NO"")" +p02790,s301941348,Wrong Answer,"a, b = input().split() + +print(a*int(b) if ""a""*int(b) <= ""b""*int(a) else ""b""*int(a)) +" +p03042,s815513610,Accepted,"s = input() + +a = int(s[:2]) +b = int(s[2:]) + +if a <= 12 and a != 0: + if b <= 12 and b != 0: + print(""AMBIGUOUS"") + elif b > 12 or b == 0: + print(""MMYY"") +else: + if b > 12 or b == 0: + print(""NA"") + elif b <= 12: + print(""YYMM"") + " +p03071,s682186014,Wrong Answer,"A,B=map(int,input().split()) +print(min(2*A-1,A+B,2*B-1)) +" +p03644,s620368919,Accepted,"keep=0 +keeeep=1 +for i in range(1,int(input())+1): + count=0 + kept=i + while kept%2==0: + count+=1 + kept=kept//2 + if count>keep: + keeeep=i + keep=count +print(keeeep) +" +p02773,s329007342,Accepted,"N = int(input()) +S = [] +for _ in range(N): + S.append(input()) + +import collections +C = collections.Counter(S) +M = C.most_common()[0][1] +R = [c for c in C.keys() if C[c]==M] +R.sort() + +for r in R: + print(r)" +p03617,s314399533,Accepted,"Q,H,S,D = map(int,input().split()) +N = int(input()) + +ans = min(8 * Q,4 * H,2 * S ,D) * (N // 2) + min(4 * Q,2 * H,S) * (N % 2) + +print(ans)" +p02712,s939476130,Accepted,"def ifif(s): + if s: + print(""Yes"") + else: + print(""No"") + +###senkei + +def ri(): return int(input()) +def rli(): return list(map(int, input().split())) +def rls(): return list(map(str, input().split())) +def pl(a): print("" "".join(list(map(str, a)))) +def ma():return map(int,input().split()) +from itertools import accumulate as acc +import operator as op +import copy as cp +import math; import numpy +from bisect import bisect_left as bisl +from bisect import bisect_right as bisr +### +n=ri() +a=[] +for i in range(1,n+1): + if i%3==0 or i%5==0: + a.append(0) + else: + a.append(i) + +print(sum(a))" +p02880,s737287659,Wrong Answer,"n = int(input()) + +if n > 81: + print(""No"") +else: + for i in range(1, 10): + if (n % i) == 0: + print(""Yes"") + break + else: + print(""No"") + break" +p02624,s401621444,Wrong Answer,"n = int(input()) +ans = 0 +for i in range(1, n+1): + count = 0 + for j in (1, i+1): + if i % j == 0: + count += 1 + + ans = i * count +print(ans)" +p02963,s614312358,Accepted,"from math import ceil + + +def main(): + area = int(input()) + upper_limit = 10 ** 9 + answer = [0, 0, upper_limit, 1, 0, ceil(area / upper_limit)] + answer[4] = upper_limit * answer[5] - area + print("" "".join(map(str, answer))) + + +if __name__ == '__main__': + main() + +" +p02873,s962725590,Accepted,"import re +a=0 +for m in re.findall('(<*)(>*)',input()):u,v=map(len,m);a+=(u*u-u+v*v-v)//2+max(u,v) +print(a)" +p02688,s910872586,Accepted,"n,k = [int(ch) for ch in input().split()] +snuckList = [] +for i in range(n): + snuckList.append(i+1) +for i in range(k): + cnt = int(input()) + snucks = [int(ch) for ch in input().split()] + for snuck in snucks: + if snuck in snuckList: + snuckList.remove(snuck) +print(len(snuckList))" +p03779,s532672859,Wrong Answer,"x=int(input()) +i=1 +if x==0: + print(0) +else: + while True: + if (i-2)*(i-1)/2+1<=x<=i*(i-1)/2: + break + i+=1 + print(i)" +p03250,s606170271,Accepted,"l = sorted(map(int, input().split())) + +print(l[2] * 10 + l[1] + l[0])" +p03721,s644486287,Accepted,"def resolve(): + n, k = map(int, input().split()) + B = [0]*10**5 + for _ in range(n): + a, b = map(int, input().split()) + B[a-1] += b + cnt = 0 + for i in range(len(B)): + cnt += B[i] + if cnt >= k: + print(i+1) + break +resolve()" +p03136,s753378068,Wrong Answer,"N = int(input()) +L = list(map(int, input().split())) +L.sort() +if L[-1] > (sum(L) - L[-1]): + print(""Yes"") +else: + print(""No"")" +p02556,s415908174,Accepted,"N = int(input()) +xy = [map(int, input().split()) for _ in range(N)] +x, y = [list(i) for i in zip(*xy)] +dis1 = [0] * N +dis2 = [0] * N +for i in range(N): + dis1[i] = x[i] + y[i] + dis2[i] = x[i] - y[i] +max_dis1 = max(dis1) +min_dis1 = min(dis1) +max_dis2 = max(dis2) +min_dis2 = min(dis2) +max_dis = max([max_dis1 - min_dis1,-min_dis2 + max_dis2]) +print(max_dis)" +p02621,s673513854,Accepted,"a=int(input()) +print(a+a**2+a**3)" +p02683,s792265268,Accepted,"n,m,x=(int(i) for i in input().split()) +l=[] +ans=None +for i in range(n): + l.append([int(i) for i in input().split()]) +for i in range(2**n): + k=i + r=[0 for i in range(m)] + cost=0 + for j in range(n): + if k%2==1: + for y in range(m): + r[y]+=l[j][y+1] + cost+=l[j][0] + k=k//2 + if min(r)>=x: + if ans==None: + ans=cost + elif ans>cost: + ans=cost +if ans==None: + print('-1') +else: + print(ans)" +p03665,s247584137,Wrong Answer,"n, p = map(int, input().split()) +a = list(map(int, input().split())) + +jug = True +for i in range(n): + a[i] % 2 == 1 + jug = False + break + +if jug: + if p == 0: + print(2 ** n) + else: + print(0) + +else: + print(2 * (n - 1)) + +" +p02910,s815051401,Wrong Answer,"# B +S = input() +if ""R"" in S[::2] or ""L"" in S[1::2]: + print(""Yes"") +else: + print(""No"")" +p03472,s912821591,Wrong Answer,"from math import ceil +n, h = map(int, input().split()) +cut = set() +throw = [] + +for _ in range(n): + a, b = map(int, input().split()) + cut.add(a) + throw.append(b) + +throw.sort(reverse=True) +ans = 0 +tmp = [] +m_cut = max(cut) + +for t in throw: + if t > m_cut: + tmp.append(t) + +if h > sum(tmp): + ans += ceil((h - sum(tmp)) / m_cut) + h -= m_cut * ans + +if len(tmp) > ceil(h / m_cut): + ans += ceil(h / m_cut) +else: + ans += len(tmp) +print(ans)" +p02694,s265271762,Accepted,"x = int(input()) +money = 100 +years = 0 +while money < x: + money += int(money*0.01) + years += 1 +print(years)" +p02601,s353485525,Wrong Answer,"a, b,c = map(int, input().split()) +k = int(input()) + +for i in range(k): + if b > c: + c *= 2 + elif a > b: + b *= 2 + else: + c *= 2 + +if (b > a) and (c > b): + result = ""Yes"" +else: + result = ""No"" + +print(result)" +p02627,s261799213,Accepted,"def main(): + a = input() + if a.isupper(): + print('A') + else: + print('a') + +if __name__ == '__main__': + main()" +p03137,s182299190,Wrong Answer,"n, m = map(int, input().split()) +x = list(map(int, input().split())) +d = [] +if n >= m: + print(0) + +else: + x.sort() + for i in range(m - 1): + d.append(abs(x[i] - x[i + 1])) + d.sort() + print(sum(d[:n+1])) +" +p03632,s695901029,Wrong Answer,"a,b,c,d = map(int, input().split()) + +if (b<=c)|(d<=a): + print(0) +else: + if (a<=c)&(d<=b): + print(d-c) + elif (c<=a)&(b<=d): + print(b-c) + elif (a<=c)&(b<=d): + print(b-a) + else: + print(c-b)" +p02888,s556362577,Accepted,"import bisect +from copy import deepcopy +N = int(input()) +L = sorted(map(int, input().split())) + +ans = 0 +for i in range(N): + for j in range(i + 1, N - 1): + b = L[j] + L[i] + x = bisect.bisect_left(L, b) - j - 1 + if x > 0: + ans += x + +print(ans) +" +p03250,s085363045,Accepted,"a,b,c = map(int,input().split()) + +h = a + b + c +i = max(a,b,c) +j = i * 10 +print(j + h - i) " +p02676,s969264724,Wrong Answer,"k = int(input()) +s = input() + +if len(s) < k: + print(s) +else: + print(s[:k] + ""..."") +" +p03605,s694456691,Wrong Answer,"import random +a=input() +kekka=['Yes','No'] +print(random.choice(kekka))" +p02714,s697605439,Accepted,"n=int(input()) +s=input().rstrip() +r=s.count(""R"") +g=s.count(""G"") +b=s.count(""B"") +count=0 +for i in range(n-2): + for j in range(i+1,n-1): + if j+j-i= 4: + l1 = i + l2 = i + elif cnt[i] >= 2: + l1, l2 = i, l1 +print(l1 * l2)" +p03327,s388872507,Accepted,"N = int(input()) + +if N < 1000: + print(""ABC"") +else: + print(""ABD"")" +p02717,s323012179,Accepted,"inpl = lambda: list(map(int,input().split())) +X, Y, Z = inpl() +print(Z, X, Y)" +p02731,s121824122,Accepted,"length = int(input()) +ans = length**3 / 27 +print(ans)" +p02711,s316131025,Accepted,print('YNeos'[not ('7'in input())::2]) +p02897,s023789301,Accepted,"n=int(input()) + +def pro(n): + if n%2==0: + return 1/2 + else: + return ((n+1)/2)/n +print(pro(n))" +p02693,s416459488,Wrong Answer,"K = int(input()) +A, B = map(int, input().split()) + +p = A % K +q = B % K + +if A==B: + if p==0: + print(""OK"") + else: + print(""NG"") + +else: + if p+q >K: + print(""OK"") + else: + print(""NG"") +" +p03416,s034872176,Accepted,"a,b = map(int,input().split()) +ans = 0 +for i in range(a,b+1): + s = str(i) + if s[0] == s[4] and s[1] == s[3]: + ans += 1 +print(ans) +" +p03013,s324025010,Accepted,"n,m = map(int,input().split()) +A =[int(input()) for _ in range(m)] +dict = {i:False for i in range(n)} +for a in A: + dict[a]=True +dp = [0 for _ in range(n+2)] +dp[0] = 1 +MOD = 1000000007 +for i in range(n): + if not dict[i]: + dp[i+1] = (dp[i]+dp[i+1])%MOD + dp[i+2] = (dp[i]+dp[i+2])%MOD +print(dp[n]) +" +p02791,s022234482,Wrong Answer,"N = int(input()) +P = list(map(int, input().split())) +cnt = 0 +for n in range(N-1): + if P[n] >= P[n+1]: + cnt += 1 +cnt += 1 +print(cnt)" +p02645,s506159752,Wrong Answer,"a=input() +#str = list(a) +print(a[:2])" +p03672,s870994406,Accepted,"lis=list(input()) +lislen=len(lis) +ma=0 +for a in range(1,(len(lis)-1)//2+1): + if lis[0:a]==lis[a:a+a]: + ma=a*2 +print(ma)" +p02711,s585252784,Wrong Answer,"n=str(input()) +print(n[0]) +if n[0]==""7"": + print(""Yes"") +elif n[1]==""7"": + print(""Yes"") +elif n[2]==""7"": + print(""Yes"") +else: + print(""No"")" +p03261,s141511988,Accepted,"N = int(input()) +S = [input() for i in range(N)] +s = set() +p = None +for w in S: + if w in s: + print('No') + exit() + s.add(w) + if p and p != w[0]: + print('No') + exit() + p = w[-1] +print('Yes') +" +p03860,s953776269,Accepted,"a, s, c = map(str, input().split()) +ans = str(a[0]+s[0]+c[0]) +print(ans)" +p03705,s284530607,Wrong Answer,"n,a,b = map(int,input().split()) +if a > b: + print(0) +elif n < (b-a+1): + print(0) +else: + diff = b-a+1 + ans = (diff**(n-2))//2+1 + print(int(ans)) +" +p04031,s495114705,Accepted,"n = int(input()) +a_list = [int(x) for x in input().split()] + +a_sum = sum(a_list) +f = a_sum // n +c = (a_sum + n - 1) // n +b = f if abs(a_sum - f * n) < abs(a_sum - c * n) else c + +ans = 0 +for a in a_list: + ans += (a - b) ** 2 +print(ans)" +p02582,s928414417,Wrong Answer,"# -*- coding: utf-8 -*- +S = input() +ans = 0 +for i in range(len(S)): + if i > 0: + if S[i-1] == S[i] == ""R"": + ans += 1 + + elif S[i] == ""R"": + ans += 1 +print(ans)" +p03680,s211665890,Wrong Answer,"n=int(input()) +k=[] +i=1 +cnt=1 +for i in range(n): + l=int(input()) + k.append(l) +cnt += 1 +i = k[0] +if '2' not in k: + print(-1) +else: + while i != 2: + if i==k[i-1]: + cnt += 1 + i=k[i-1] + if cnt>n: + print(-1) + else: + print(cnt) " +p03456,s696712509,Wrong Answer,"a, b = input().split() +ab = int(a + b) + +for i in range(1, 101): + if i**2 == ab: + print(""Yes"") + break +else: + print(""No"")" +p02972,s031326625,Accepted,"import math +n = int(input()) +a = list(map(int,input().split())) + +b = [0]*n +s = [0]*(n+1) + +for i in reversed(range(1,n+1)): + for k in range(1,math.floor(n/i)+1): + j = int(k*i) + s[i] += b[j-1] + if s[i]%2 != a[i-1]: + b[i-1] += 1 + +L = [i+1 for i in range(n) if b[i] == 1] +print(len(L)) +print(*L)" +p03611,s516883814,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int, input().split())) + +ans = Counter() +for i in range(n): + ans[a[i]-1]+=1 + ans[a[i]]+=1 + ans[a[i]+1]+=1 +print(ans.most_common(1)[0][1])" +p02780,s157785276,Wrong Answer,"import sys +sys.setrecursionlimit(10 ** 7) + +S, T = list(map(int,(input().split()))) +p = list(map(int,(input().split()))) +ans = 0 +anss = [] +temp_sum= 0 +sum_max = [] +for i in range(T): + ans = 0 + samp = p[i:T+i] + if temp_sum < sum(samp): + temp_sum = sum(samp) + sum_max = samp + +#print(sum_max) +for i in sum_max: + x =(list(range(1,i+1))) + ans += sum(x)/len(x) + +print(ans) " +p03137,s246241187,Accepted,"k, n = list(map(int, input().split())) +x = list(map(int, input().split())) +x.sort() +df = [0] * (n - 1) +for i in range(n - 1): + df[i] = abs(x[i + 1] - x[i]) + +df = sorted(df, reverse=True) +print(sum(df[k - 1 :])) +" +p03329,s635911655,Accepted,"n = int(input()) +dp = [float(""Inf"")]*(n+1) +for i in range(min(6, n+1)): + dp[i] = i +for i in range(n): + for j in range(1,n//6+1): + if i + 6**j > n: + break + dp[i+6**j] = min(dp[i+6**j], dp[i] + 1) + for j in range(1,n//9+1): + if i + 9**j > n: + break + dp[i+9**j] = min(dp[i+9**j], dp[i] + 1) +print(dp[-1])" +p02996,s613810025,Accepted,"import sys +input = sys.stdin.readline + + +def main(): + AB = [] + n = int(input()) + for i in range(n): + a, b = map(int, input().split()) + AB.append([a, b]) + AB = sorted(AB, key=lambda x: (x[1], -x[0])) + time = 0 + for span, dead in AB: + time += span + if time > dead: + print('No') + return + print('Yes') + return + + +if __name__ == ""__main__"": + main() +" +p03774,s433159564,Accepted,"n, m = map(int, input().split()) +ab = [list(map(int, input().split())) for i in range(n)] +cd = [list(map(int, input().split())) for i in range(m)] +ans = [[] for i in range(n)] +for i in range(n): + for j in range(m): + ans[i].append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])) +for i in range(n): + print(ans[i].index(min(ans[i]))+1)" +p03131,s547733877,Accepted,"k , a, b = map(int, input().split()) + +ans = 0 + +if b-a <= 2: + ans = k+1 +else: + ans = a + k -= a - 1 + ans += (b-a) * (k//2) + k % 2 + +print(ans)" +p03457,s398811539,Accepted,"n = int(input()) +t = 0 +x = 0 +y = 0 +for i in range(n): + t_in,x_in,y_in = map(int,input().split()) + diff_t = t_in - t + diff_x = abs(x_in-x) + diff_y = abs(y_in-y) + sum_xy = diff_x + diff_y + if diff_t < sum_xy: + print('No') + exit() + else: + if diff_t%2 != sum_xy%2: + print('No') + exit() +print('Yes') +" +p02995,s360532129,Accepted,"import fractions + +A, B, C, D = [int(i) for i in input().split()] +A = A - 1 +l = (C * D) // fractions.gcd(C,D) + +b_sum = B -(B//C) - (B//D) + (B//l) +a_sum = A - (A//C) - (A//D) + (A//l) + +print(b_sum - a_sum) +" +p02970,s863323929,Accepted,"n,d = list(map(int, input().split())) +x = d*2 + 1 +ans = (-n//x)*-1 +print(ans)" +p02707,s724196753,Wrong Answer,"num = int(input()) +l_a = input().split() +s_a = set(l_a) + +dc = {} + +l_s = [] +for i in s_a: + dc[i] = l_a.count(i) + +index = 1 +k = 0 +l_key = sorted(dc.keys()) + +for i in l_key: + while int(i) + k < index: + print(0) + k += 1 + print(dc[i]) + index += 1 + +while index <= num: + print(0) + index += 1 +" +p02546,s148343438,Wrong Answer,"S = input() +print(S+'es' if S.endswith('s') else print(S+'s'))" +p02689,s947150167,Wrong Answer,"N,M = map(int,input().split()) +H= list(map(int,input().split())) + +X = [1]*N +for i in range(M): + a,b = map(int,input().split()) + x1 = H[a-1] + x2 = H[b-1] + if x1 < x2: + X[a-1] = False + if X[b-1] != False: + X[b-1] = True + + else: + X[b-1] = False + if X[a-1] != False: + X[a-1] = True +print(X.count(True)) " +p02663,s261457673,Accepted,"[h1,m1,h2,m2,k] = [int(i) for i in input().split()] + +print((h2 - h1) * 60 + (m2 - m1) - k) +" +p03379,s147558984,Accepted,"import statistics +n = int(input()) +a = list(map(int, input().split())) +median_low = statistics.median_low(a) +median_high = statistics.median_high(a) +for i in range(n): + if median_high > a[i]: + print(median_high) + elif median_low < a[i]: + print(median_low) + elif median_high == a[i]: + print(a[i]) + else: + print(a[i-1]) +" +p03351,s344610927,Accepted,"import sys +sys.setrecursionlimit(10 ** 5 + 10) +def input(): return sys.stdin.readline().strip() + +def resolve(): + + a,b,c,d=map(int,input().split()) + print('Yes' if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No') + +resolve()" +p02641,s537698849,Wrong Answer,"X,N = map(int,input().split()) +p = list(map(int,input().split())) +min1=[] +x_min = 100 +num_list = list(range(101)) +for i in range(N): + num_list.remove(p[i]) + +for j in reversed(num_list): + x = abs(j-X) + if x_min >= x: + x_min = x + close=j +print(close)" +p02665,s943400043,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +if N == 0: + if A[0] == 1: + print(1) + else: + print(-1) + exit() + +if A[0] != 0: + print(-1) + exit() + +ans = 1 +prev = 1 +P = [] +for a in A[1:]: + P.append(prev) + mx = prev * 2 + + if mx < a: + print(-1) + exit() + + ans += mx + prev = mx - a + +while prev and P: + ans -= prev + pr = P.pop() + prev = max(0, prev - pr) + +print(ans) +" +p02783,s920191916,Wrong Answer,"h, a = map(int, input().split()) + +n = h/a + +if n != 0: + print(n+1) +else : + print(n)" +p03339,s985185790,Accepted,"N = int(input()) +S = input() +num = S[1:].count(""E"") +ans = num +for i in range(1, N): + if S[i - 1] == ""W"": + num += 1 + if S[i] == ""E"": + num -= 1 + ans = min(num, ans) +print(ans) + " +p02802,s462316223,Accepted,"import math + +def makelist(n, m): + return [[0 for _ in range(m)] for _ in range(n)] + +# n = int(input()) +# a, b +# s = input() + +N, M = list(map(int, input().split())) + +ac = 0 +wa = 0 +memo = [0]*(N+1) + +for _ in range(M): + p, S = input().split() + p = int(p) + + if S == ""AC"": + if memo[p] != -1: + ac += 1 + wa += memo[p] + memo[p] = -1 + else: + if memo[p] != -1: + memo[p] += 1 + +print(ac, wa) +" +p02796,s029915835,Accepted,"#B +n = int(input()) +robot = [] +for i in range(n): + x,l = map(int, input().split()) + ri = x - l + le = x + l + robot.append([ri, le]) +robot.sort(key=lambda x: x[1]) +# print(robot) +a = robot[0][1] +count=1 +for i in range(1, n): + if a > robot[i][0]: + pass + else: + # print(robot[i]) + #残せる + a = robot[i][1] + count += 1 +print(count)" +p03478,s317521116,Wrong Answer,"n,a,b = map(int, input().split()) +cnt = 0 + +def digidsum(x): + s = str(n) + array_list = list(map(int,s)) + return sum(array_list) + + + +for i in range(n): + if digidsum(i+1) >= a and digidsum(i+1) <= b: + cnt += i+1 +print(cnt)" +p03324,s579366708,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + D, N = map(int, input().split()) + + if N == 100: + ans = 100 ** D * (N + 1) + else: + ans = 100 ** D * N + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03038,s829216221,Accepted,"n, m = [int(i) for i in input().split()] +a = [int(i) for i in input().split()] +a.sort() +bc = [[int(i) for i in input().split()] for _ in range(m)] +bc.sort(key=lambda x: -x[1]) + +i = 0 +for b, c in bc: + for _ in range(b): + a[i] = max(a[i], c) + i += 1 + if i == n: + break + if i == n: + break +print(sum(a))" +p02833,s973327011,Wrong Answer,"n=int(input()) +r=0 +i=1 +while 2*5**i<=n: + r+=n//(2*5**i) + i+=1 +print(r)" +p02771,s756040613,Accepted,"a, b, c = map(int, input().split()) + +if (a == b and b != c) or (b == c and c != a) or (c == a and a != b): + print(""Yes"") +else: + print(""No"")" +p03086,s908023521,Accepted,"s=input() +ans=0 +c=0 +for i in range(len(s)): + if s[i] in [""A"",""C"",""G"",""T""]: + c+=1 + else: + c=0 + ans=max(ans,c) +print(ans)" +p03471,s607149599,Accepted,"import sys +input = sys.stdin.readline + +def main(): + N, Y = map(int, input().split()) + ans = ""-1 -1 -1"" + for i in range(N+1): + for j in range(N+1-i): + if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y: + ans = ""{} {} {}"".format(i, j, N-i-j) + break + if ans != ""-1 -1 -1"": + break + print(ans) + +if __name__ == '__main__': + main() +" +p03910,s196582301,Accepted,"N = int(input()) + +for x in range(N+10): + if (x*(x+1))//2 >= N: + break + +ans = list(range(1, x+1)) +rem = (x*(x+1))//2 - N +for a in ans: + if a != rem: + print(a)" +p03633,s864822296,Wrong Answer," +N = int(input()) +T = [] +for i in range(N): + T.append(int(input())) +print('T:',T) + +if N==1: + f2 = T[0] + +elif N==2: + import math + a,b = T[0], T[1] + f=math.gcd(a,b) + f2=a*b//f + +else: + import math + a,b = T[0], T[1] + f=math.gcd(a,b) + f2=a*b//f + for i in range(2,N): + a,b=f2, T[i] + f=math.gcd(a,b) + f2=a*b//f + +print(f2) +" +p03359,s087026202,Wrong Answer,"a, b = map(int,input().split()) +print(a) if a < b else print(a-1)" +p03524,s239334308,Accepted,"def myAnswer(S:str)-> str: + N = len(S) + if(N == 1): return ""YES"" + dic = {""a"":0,""b"":0,""c"":0} + for s in S: + dic[s] += 1 + # print(dic) + dic = list(dic.values()) + dic.sort(reverse = True) + first = dic.pop(0) + seccond = dic.pop(0) + third = dic.pop(0) + if(first - third <= 1): + return ""YES"" + else: + return ""NO"" + + + + +def modelAnswer(): + return +def main(): + S = (input()) + print(myAnswer(S)) +if __name__ == '__main__': + main()" +p02598,s177215912,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +top = max(a) +bottom = 0 + +while (top - bottom) > 1: + mid = (top + bottom) // 2 + div_n = lambda a: (a + mid - 1) // mid - 1 + cnt = sum(map(div_n, a)) + if cnt <= k: + top = mid + else: + bottom = mid + +print(top)" +p03011,s108313686,Accepted,"P,Q,R = map(int,input().split()) +print(P+Q+R-max(P,Q,R))" +p03161,s951677047,Accepted,"n,k=map(int,input().split()) +h=list(map(int,input().split())) +dp=[float('inf')]*n +dp[0]=0 + +for i in range(n): + for j in range(1,k+1): + if 0<=i-j1: + print(0) + exit() +import math +#print(math.factorial(4)) +if abs(n-m)==1: + n_=math.factorial(n)%(10**9+7) + m_=math.factorial(m)%(10**9+7) + print((n_*m_)%(10**9+7)) +if abs(n-m)==0: + n_=math.factorial(n)%(10**9+7) + m_=math.factorial(m)%(10**9+7) + print((2*n_*m_)%(10**9+7)) +" +p03211,s932839497,Accepted,"S = input() +MIN = 1000 +for T in range(0,len(S)-2): + X = int(S[T:T+3]) + Num = abs(X-753) + if Num0: + print('no') +else: + print('yes')" +p02916,s515710195,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) +C = list(map(int,input().split())) + +count = 0 +for i in range(N): + count += B[A[i]-1] + # 最後は追加の満足度はないから省く + if i != N-1: + try: + # 追加の満足度 + count += C[A[i]-1] + except IndexError as e: + pass + +print(count) +" +p03767,s473512593,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +a=sorted(a) + +print(sum(a[n:2*n])) +" +p03087,s595818542,Accepted,"import math +n, q = map(int, input().split()) + +s = input() + +t = [0] + +tmp = 0 +for i in range(len(s)-1): + if s[i] == ""A"" and s[i+1] == ""C"": + tmp += 1 + + t.append(tmp) + +for _ in range(q): + l,r = map(int, input().split()) + print(t[r-1]-t[l-1])" +p02694,s968267955,Wrong Answer,"X = list(map(int,input().split()))[0] +yen = 100 + +for i in range(1,10**18): + yen = int(yen*1.01) + if yen > X: + break + +print(i)" +p02600,s769356380,Accepted,"def a(): + X = int(input()) + print(10 - X//200) + + +########## +if __name__ == ""__main__"": + a() +" +p02707,s554390300,Wrong Answer,"def resolve(): + N = int(input()) + A = list(map(int, input().split())) + for i in range(N-1): + print(A.count(i+1)) +resolve()" +p03105,s414947682,Wrong Answer,"import math +A,B,C = map(int,input().split()) + +if B/A>C: + print(C) +elif B/A 21 else ""win"") + +" +p02953,s690988914,Accepted,"N = int(input()) +H = list(map(int,input().split())) + +maxH = 0 +for i in range(N-1): + if H[i+1] >= maxH-1: + maxH = max(maxH,H[i+1]) + else: + print(""No"") + exit() + +print(""Yes"")" +p03163,s295283002,Accepted,"n,w = map(int,input().split()) +v = [0]*(n+1) +for i in range(1,n+1): + v[i] = list(map(int,input().split())) + +dp = [[0 for j in range(w+1)] for i in range(n+1)] + +for i,[W,V] in enumerate(v[1:],1): + for j in range(w): + dp[i][w-1-j] = dp[i-1][w-1-j] + if w-1-j + W <= w: + dp[i][w-1-j+W] = max(dp[i][w-1-j]+V, dp[i][w-1-j+W]) + +ans = 0 +for i in range(n+1): + ans = max(ans, max(dp[i])) +print(ans)" +p03693,s139710962,Accepted,"def resolve(): + r,g,b=map(int, input().split()) + if eval(str(r)+str(g)+str(b))%4==0: + print('YES') + else: + print('NO') +resolve() +" +p02594,s968954503,Accepted,"X = int(input()) +print(""Yes"") if X >= 30 else print(""No"") +" +p03351,s509525641,Accepted,"a,b,c,d = map(int,input().split()) +print(""Yes"") if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d) else print(""No"") " +p03773,s471806449,Accepted,"def main(): + now_time, start_in = map(int, input().split()) + print((now_time + start_in) % 24) + + +if __name__ == '__main__': + main() + +" +p02791,s045060130,Accepted,"def solve(): + N, *P = map(int, open(0).read().split()) + + ans = 0 + tmp = 10 ** 6 + for i in range(N): + tmp = min(tmp, P[i]) + if P[i] <= tmp: + ans += 1 + print(ans) + + +if __name__ == '__main__': + solve() +" +p03962,s700106801,Accepted,"A = list(map(int,input().rstrip().split("" ""))) +A.sort() +if A[0] == A[1]: + if A[1] == A[2]: + print(1) + else: + print(2) +else: + if A[1] == A[2]: + print(2) + else: + print(3) +" +p03711,s385248339,Wrong Answer,"x,y=map(int,input().split()) +data=[[1,3,5,7,8,10,12], + [4,6,9,11], + [2]] +a=0 +b=0 +for i in range(0,3): + for j in range(0,len(data[i])): + if x==data[i][j]: + a=i+1 +for k in range(0,3): + for l in range(0,len(data[k])): + if x==data[k][l]: + b=k+1 +if a==b: + print('Yes') +else: + print('No') + +" +p02606,s731439509,Wrong Answer,"L, R, d = (int(x) for x in input().split()) +a = L // d +b = R // d +if R % d == 0: + b += 1 +print(b - a) +" +p03633,s402301943,Accepted,"import fractions +from functools import reduce + +n = int(input()) +lst = [0 for _ in range(n)] +for i in range(n): + lst[i] = int(input()) + +def lcm_base(x, y): + return (x * y) // fractions.gcd(x, y) + +def lcm(*numbers): + return reduce(lcm_base, numbers, 1) + +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +print(lcm_list(lst)) +" +p02939,s106798142,Accepted,"S = input() +before = '' +b = 0 +c = 0 +for i in range(1, len(S)+1): + if S[b:i] != before: + before = S[b:i] + b =i + c += 1 +print(c) + +" +p02972,s838919511,Wrong Answer,"import math + +N = int(input()) +a = [0]+list(map(int, input().split())) +b = [0 for _ in range(N+1)] +for j in range(2, N+1): + for i in range(N//j+1, N//(j-1)+1): + b[i] = sum(a[i*k] for k in range(1,j)) % 2 +print(sum(b[1:])) +print(*[j for j in b if j == 1])" +p03371,s581278666,Accepted,"A,B,C,X,Y=map(int,input().split()) + +ans=[A*X+B*Y,2*C*max(X,Y),2*Y*C+A*max(0,X-Y),2*X*C+B*max(0,Y-X)] +print(min(ans))" +p02780,s249342693,Accepted,"N ,K = list(map(int, input().split())) +p = list(map(lambda x: (1+int(x))/2, input().split())) +s = [0]*N +s[0]=p[0] +for i in range(1,N): + s[i] = s[i-1]+p[i] + +l = [s[K-1]] +for i in range(N-K): + l.append(s[i+K]-s[i]) + +print(max(l))" +p02695,s959044880,Accepted,"import sys +import itertools + +N,M,Ql = map(int, sys.stdin.readline().strip().split()) +Q = [] +for _ in range(Ql): + Q.append(list(map(int, sys.stdin.readline().strip().split()))) + +max = 0 +for A in itertools.combinations_with_replacement(range(1,M+1), N): + ans = 0 + for Qi in Q: + a,b,c,d = Qi + + if (A[b-1] - A[a-1]) == c: + ans += d + if max < ans: + max = ans + +print(max) +" +p03329,s010143632,Accepted,"N = int(input()) +dp = [0] + +for i in range(1, N + 1): + cur = min(1 + dp[i - 1], 10 ** 10) + + j = 1 + while i - 6 ** j >= 0: + cur = min(1 + dp[i - 6 ** j], cur) + j += 1 + + j = 1 + while i - 9 ** j >= 0: + cur = min(1 + dp[i - 9 ** j], cur) + j += 1 + + dp.append(cur) + +print(dp[-1])" +p04033,s334039332,Wrong Answer,"# + +import sys +from copy import deepcopy +input=sys.stdin.readline + +def main(): + a,b=map(int,input().split()) + if a*b<=0: + print(""Zero"") + elif a>0: + print(""Positive"") + else: + pm=(-1)*(b-a+1) + if pm==1: + print(""Positive"") + else: + print(""Negative"") + +if __name__==""__main__"": + main() +" +p02814,s155466551,Accepted,"from fractions import gcd +def lcm(a,b): + return (a*b)//gcd(a,b) +n,m = map(int,input().split()) +a = list(map(int,input().split())) +ans = 1 +for i in a: + ans = lcm(ans,i) +for i in a: + if (ans//i) % 2 == 0: + print(0) + exit() +print(((m//(ans//2))+1)//2)" +p03329,s615535284,Accepted,"n=int(input()) + +dp=[float('inf')]*(n+1) +dp[0]=0 + +for i in range(1,n+1): + + power=1 + while(power<=i): + dp[i]=min(dp[i],dp[i-power]+1) + power*=6 + + power=1 + while(power<=i): + dp[i]=min(dp[i],dp[i-power]+1) + power*=9 + +print(dp[n]) + +" +p03487,s671850717,Wrong Answer,"from collections import Counter +N = int(input()) +A = Counter(map(int, input().split())) +ans = 0 +for x, y in A.items(): + if y > x: + ans += y - x + else: + ans += y +print(ans)" +p03486,s791687597,Accepted,"s = input() +t = input() +import sys +if s==t: + print(""No"") + sys.exit() +ss = sorted(list(s)) +tt = sorted(list(t))[::-1] +if sorted([ss,tt])[0] == ss: + print(""Yes"") +else: + print(""No"")" +p03077,s947917918,Accepted,print(abs(-int(input())//min(int(input()) for _ in range(5)))+4) +p02677,s565102441,Accepted,"import math +a,b,h,m=map(int,input().split()) +ang=6*m-30*h-m/2 +if ang<0: + ang*=-1 +ang=ang*math.pi/180 +#c=math.cos(ang) +#print(c) +r=math.sqrt(a*a+b*b-2*a*b*math.cos(ang)) +print(r) +" +p03419,s030312326,Wrong Answer,"n, m = map(int, input().split()) +print(n*m - (n*2+m*2-4))" +p03998,s359345293,Wrong Answer,"a=input() +b=input() +c=input() +n=a +while True: + if n!="""": + k=n[0] + if n==a: + a=a[1:] + elif k==b: + b=b[1:] + else: + c=c[1:] + if k==""a"": + n=a + elif k==""b"": + n=b + else: + n=c + else: + if n==a: + print(""A"") + elif n==b: + print(""B"") + else: + print(""C"") + break" +p02702,s606114125,Accepted,"S=input() +P=2019 + +mod_table=[0]*P +mod_table[0]=1 + +modp=0 +mod10=1 +for i in reversed(range(len(S))): + si=int(S[i]) + modp=(si*mod10+modp)%P + mod_table[modp]+=1 + mod10=(mod10*10)%P + +answer=0 +for m in mod_table: + answer+=m*(m-1)//2 + +print(answer)" +p03329,s081355941,Wrong Answer,"N = int(input()) + +array = [] +cnt6 = 0 +while 6**cnt6 < N: + array.append(6**cnt6) + cnt6 += 1 + +cnt9 = 0 +while 9**cnt9 < N: + array.append(9**cnt9) + cnt9 += 1 + +a = sorted(list(set(array))) +# 最小 +dp = [i for i in range(N+1)] +# print(dp) +n = 6 +for n in a: + for i in range(N+1): + if i+n <= N: + dp[i+n] = min(dp[i]+1, dp[i+n]) +print(dp[N]) +" +p02785,s397782841,Wrong Answer,"# -*- coding: utf-8 -*- + + +def main(): + n, k = map(int, input().split()) + h = list(map(int, input().split())) + + total = sum(h) + + if k >= n: + print(0) + elif k == 0: + print(total) + else: + print(total - sum(sorted(h[k + 1:], reverse=True))) + + +if __name__ == '__main__': + main() +" +p02631,s633473530,Accepted,"from functools import reduce + + +N = int(input()) +A = list(map(int, input().split())) +base = reduce(lambda x, y: x ^ y, A) +print(*[base ^ A[i] for i in range(N)]) +" +p03161,s502370766,Wrong Answer,"#DP B +import sys +N, K = map(int, sys.stdin.readline().split()) +H = list(map(int, sys.stdin.readline().split())) + +dp = [-1 for _ in range(N)] +#print(dp) +#print(H) +dp[1] = abs(H[1]-H[0]) +#print(dp) + +for i in range(2, N): + for k in range(1, K+1): + if i-k>=0: + tmp = abs(H[i]-H[i-k]) + dp[i-k] + if dp[i] ==-1 or tmp < dp[i]: + dp[i] = tmp + #print(dp) +print(dp[-1])" +p03035,s495544682,Wrong Answer,"a,b=input().split() +a=int(a) +b=int(b) +if a>=12: + print(b) +if 6<=a<12: + print(int(b/2)) +else: + print(""0"")" +p03804,s695866234,Accepted,"n ,m = map(int, input().split()) +ln = [] +lm = [] + +for i in range(n): + ln.append(input()) +for i in range(m): + lm.append(input()) + +lim = n - m + 1 +for i in range(lim): + for j in range(lim): + l = 0 + for k in ln[i:i+m]: + if k[j:j+m] != lm[l]: + break + l += 1 + else: + print(""Yes"") + break + else: + continue + break + +else: + print(""No"") +" +p02922,s356240976,Accepted,"import math + +A, B = [int(i) for i in input().split()] + +B2 = B - A +A2 = A - 1 +print(math.ceil(B2 / A2) + 1) +" +p03592,s673298964,Wrong Answer,"a,b,c=map(int,input().split()) +for i in range(a): + for j in range(b): + if i*b+j*a==c: + print('Yes') + exit() +print('No')" +p03821,s584903735,Accepted,"n = int(input()) +ab = [list(map(int, input().split())) for _i in range(n)][::-1] + +r = 0 +for i in range(n): + a, b = ab[i] + if (r+a)%b==0: + continue + r += b-(r+a)%b +print(r)" +p03385,s216237074,Accepted,"list_s = list(input()) +if len(list_s) == 3 and list_s.count('a') == 1 and list_s.count('b') == 1 and list_s.count('c') == 1 : + print(""Yes"") +else: + print('No')" +p04005,s634012457,Wrong Answer,"a,b,c = map(int,input().split()) +print(a*b*c//max(a,b,c))" +p02924,s612559419,Accepted,"n=int(input()) +print(n*(n-1)//2)" +p02912,s362022424,Accepted,"import heapq +n,m=map(int,input().split()) +a=list(map(int,input().split())) +a = list(map(lambda x: x*(-1), a)) # 各要素を-1倍 + +heapq.heapify(a) + +for i in range(m): + minimum=heapq.heappop(a) + mini=((minimum*(-1))//2)*(-1) + heapq.heappush(a,mini) + +print(-sum(a)) + + +" +p02833,s970139795,Wrong Answer,"import sys + +n = int(input()) + +# 奇数始まりは必ず0 +if n % 2 == 1: + print(0) + sys.exit() + +# 5の因子を数える +# 5の倍数は10個ごと、25の倍数は50個ごと、125の倍数は250個ごとに登場する +ans = 0 +cnt = 1 +while 5**cnt * 2 < n: + ans += n // (5**cnt * 2) + cnt += 1 +print(ans)" +p03493,s113189348,Wrong Answer,"a = input() + +cnt = 0 + +for c in a: + cnt=cnt + 1 + +print(c)" +p02577,s717654310,Accepted,"from math import gcd + +from math import factorial as f + +from math import ceil, floor, sqrt +import math + +import bisect +import re +import heapq + +from copy import deepcopy +import itertools +from itertools import permutations + +from sys import exit + +ii = lambda: int(input()) +mi = lambda: map(int, input().split()) +li = lambda: list(map(int, input().split())) + +yes = ""Yes"" +no = ""No"" + + +def main(): + s = input() + div = 0 + for tmp in s: + i = int(tmp) + div += i + div %= 9 + if div == 0: + print(yes) + else: + print(no) + + +main() +" +p03623,s491647853,Wrong Answer,"a,b,x=map(int,input().split()) +da=abs(x-a) +db=abs(x-b) +if dadb: + print(""B"") + +" +p04045,s842493724,Wrong Answer,"import itertools + +list_of_num = list(range(10)) +inputs = input().split(' ') +n, k = int(inputs[0]), int(inputs[1]) +[list_of_num.remove(int(i))for i in input().split(' ')] + +if len(str(n)) == sum([1 for i in list(str(n)) if int(i) in list_of_num]): + print(n) +else: + list_of_num = [str(i) for i in list_of_num] + + answer = itertools.product(str(''.join(list_of_num)), repeat=10000) + for j in answer: + buf = int(''.join(j)) + if n < buf: + print(buf) + break" +p02553,s616900630,Accepted,"a, b, c, d = map(int, input().split()) +print(max(a*c, a*d, b*c, b*d))" +p02663,s613369809,Wrong Answer,"H, M, h, m, K = map(int, input().split()) +print(((60*h + m - 60*H - M)//K - 1)*K)" +p03760,s592981072,Accepted,"# -*- coding: utf-8 -*- + +#---------- +O = input().strip() +E = input().strip() +#---------- + +new_S="""" +for i in range(1,len(O)+len(E)+1): + if (i % 2) == 1: + new_S += O[i // 2] + else: + new_S += E[i // 2 - 1] + +print(new_S) +" +p03210,s742054380,Wrong Answer,"x = int(input()) +print('YES' if x == 7 or 5 or 3 else 'NO')" +p03331,s307184066,Accepted,"n = int(input()) + +ans = float(""inf"") +for a in range(1,n): + b = n-a + sa = str(a).rjust(6,""0"") + sb = str(b).rjust(6,""0"") + cnt = 0 + for i in range(6): + cnt += int(sa[i]) + int(sb[i]) + + ans = min(ans, cnt) + +print(ans)" +p03221,s664552145,Wrong Answer,"n, m = map(int,input().split()) +p = [[i] + list(map(int,input().split())) for i in range(m)] +p = sorted(p, key=lambda x:(x[1], x[2])) +for i in range(m): + p[i][1] = str(p[i][1]).zfill(6) + p[i][2] = str(p[i][2]).zfill(6) +p = sorted(p, key=lambda x:(x[0])) +for i in range(m): + print(p[i][1]+p[i][2])" +p02767,s701430135,Accepted,"N = int(input()) +X = list(map(int,input().split())) +ans = 10**36 +S = 0 + +for p in range(100): + S =0 + for x in X: + S += (x-p)**2 + ans = min(ans,S) + +print(ans)" +p02756,s513726228,Wrong Answer,"import sys; input = sys.stdin.readline +def main(): + S = input() + Q = int(input()) + for i in range(Q): + TFC = input().split() + S = S[::-1] if TFC[0]==""1"" else (TFC[2]+S if TFC[1]==""1"" else S+TFC[2]) + print(S) + +if __name__==""__main__"": + main() +" +p02866,s727506824,Accepted,"import collections +N = int(input()) +D = list(map(int, input().split())) +d = collections.Counter(D) +maxnum = max(D) +ans = 1 +for i in range(maxnum+1): + if i == 0: + if D[0] != 0 or d.get(0,0) != 1: + ans = 0 + break + else: + if d.get(i, 0) == 0: + ans = 0 + break + ans *= d[i-1]**d[i] + +print(ans%998244353)" +p03433,s211527625,Accepted,"if int(input())%500 > int(input()): + print(""No"") +else: + print(""Yes"")" +p02994,s921858248,Accepted,"def main(): + n,l = map(int,input().split()) + a = [l+i-1 for i in range(1, n+1)] + b = [abs(i) for i in a] + m = min(b) + i = b.index(m) + del a[i] + print(sum(a)) + +if __name__ == ""__main__"": + main()" +p03767,s677553335,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a = sorted(a, reverse=True) +ans = a[1: 1+2*n:2] +#print(ans) +print(sum(ans))" +p03624,s521140334,Wrong Answer,"s=input() +x=ord('a') +z=0 +for i in range(x,x+27): + y=chr(i) + if y not in s: + print(y) + z=1 + break +if z==0: + print('None')" +p03407,s683049185,Accepted,"a, b, c = map(int, input().split()) +if a + b >= c: + print('Yes') +else: + print('No')" +p02789,s942052814,Wrong Answer,"n, m = map(int, input().split()) +if n==m: + print(""AC"") +else: + print(""WA"")" +p03695,s508542105,Accepted,"n = int(input()) +A = list(map(int,input().split(' '))) +rate = [0]*9 +for a in A: + c = min(a//400, 8) + rate[c] += 1 +count = 0 +i = 0 +while i < 8: + if rate[i] != 0: + count += 1 + i += 1 +cmax = count+rate[8] +cmin = max(1, count) + +print(str(cmin)+' '+str(cmax))" +p03264,s440053583,Accepted,"k=int(input()) +if k%2==0: + print(((k//2)**2)) +else: + print(((k//2)+1)*(k//2))" +p02548,s056234986,Wrong Answer,"N = int(input()) +NR = int(N**0.5) +count = 0 +if int(N/2)-N/2 == 0: + for i in range(1,int(N/2)): + if int(N/i)-N/i == 0: + count += int(N/i)-1 + else: + count += int(N/i) +else: + for i in range(1,int(N/2)+1): + if int(N/i)-N/i == 0: + count += int(N/i)-1 + else: + count += int(N/i) + + +print(count)" +p03103,s702785070,Wrong Answer,"N, M = map(int,input().split()) +P = [input().split() for i in range(N)] +P.sort() + +j = 0 +total = 0 + +for i in range(N): + if (j + int(P[i][1])) < M: + total += int(P[i][0]) * int(P[i][1]) + j += int(P[i][1]) + else: + total += int(P[i][0]) * (M - j) + break +print(total) +" +p02696,s446587392,Accepted,"a, b, n = map(int, input().split()) + +x = n +if n >= b-1: + x = b-1 + +ans = (a*(x%b))//b +print(ans) +" +p03637,s530368284,Accepted,"from collections import Counter + +n = int(input()) +A = list(map(int, input().split())) +A = [min(x & -x, 4) for x in A] + +CA = Counter(A) +num0 = CA[1] +num1 = CA[2] +num2 = CA[4] +if num1: + num1 = 1 +if num2 - (num1 + num0) >= -1: + print(""Yes"") + +else: + print(""No"") +" +p04043,s547009775,Wrong Answer,"a,b,c =map(int,input().split() ) +d = a + b + c +e = a * b * c +if(d == 17 and e == 175): + print(""Yes"") +else: + print(""No"")" +p04044,s775485605,Wrong Answer,"n, l = map(int, input().split()) +ll = [] +for i in range(n): + ll.append(input()) +print(ll) +ll.sort() +print(ll) +ans = """" +for j in ll: + ans += j + +print(ans)" +p03150,s608481177,Accepted,"s=input() +rem = len(s)-7 + +if s[rem:] == 'keyence': + print('YES') + exit() +for i in range(8): + news = s[0:i] + s[i+rem:] + if news == 'keyence': + print('YES') + break +else: + print('NO')" +p03386,s047492702,Accepted,"a,b,k = map(int, input().split()) + +if b-a+1 > 2*k: + for i in range(a,a+k): print(i) + for i in range(b-k+1,b+1): print(i) +else: + for i in range(a,b+1): print(i)" +p02697,s543136499,Wrong Answer,"import sys +sys.setrecursionlimit(10**9) + +def mi(): return map(int,input().split()) +def ii(): return int(input()) +def isp(): return input().split() +def deb(text): print(""-------\n{}\n-------"".format(text)) + +INF=10**20 + +def main(): + N,M=mi() + X = list(range(1,N+1)) + + ans = 0 + for i in range(M): + print(X[i],X[::-1][i]) + + +if __name__ == ""__main__"": + main()" +p03274,s541902008,Accepted,"n,k=map(int,input().split()) +xs=list(map(int,input().split())) +m=float('inf') +for l,r in zip(xs,xs[k-1:]): + d=min(abs(l),abs(r))+abs(r-l) + m=min(m,d) +print(m) +" +p02787,s884862990,Accepted,"H,N=map(int,input().split()) +A=[] +B=[] +for i in range(N): + a,b=map(int,input().split()) + A.append(a) + B.append(b) + +DP=[[0]*(H+max(A)) for i in range(N)] +DP.insert(0,[10**8+1]*(H+max(A))) +DP[0][0]=0 + +for i in range(1,N+1): + for j in range(1,H+max(A)): + if j-A[i-1]>0: + DP[i][j]=min(DP[i-1][j],DP[i][j-A[i-1]]+B[i-1]) + else: + DP[i][j]=min(DP[i-1][j],B[i-1]) + +print(DP[N][H])" +p03673,s249263357,Wrong Answer,"n=int(input()) +a=list(input().split()) +if n > 3: + ans='' + ans += ' '.join(a[::-2]) + print(a[::2]) + if n%2==0: + ans += ' ' + ' '.join(a[0::2]) + else: + ans += ' ' + ' '.join(a[1::2]) + print(ans) +else: + ans=[] + for i in range(n): + ans.append(a[i]) + ans.reverse() + print(' '.join(ans))" +p03107,s443305448,Wrong Answer,"import sys +import math +import itertools +import collections +import heapq +import re +import numpy as np +from functools import reduce + +rr = lambda: sys.stdin.readline().rstrip() +rs = lambda: sys.stdin.readline().split() +ri = lambda: int(sys.stdin.readline()) +rm = lambda: map(int, sys.stdin.readline().split()) +rl = lambda: list(map(int, sys.stdin.readline().split())) +inf = float('inf') +mod = 10**9 + 7 + + +n = ri() +s = collections.Counter(rr()) +print(min(s['0'], s['1'])) + + + + + + + + + + + + + +" +p03437,s517306178,Accepted,"x, y = map(int, input().split()) + +if x % y == 0: + print(-1) +else: + print(x * (y + 1))" +p03862,s527234244,Accepted,"n,x=map(int,input().split()) +a=list(map(int,input().split())) +ans=0 +if a[0]>x: + ans+=a[0]-x + a[0]=x +for i in range(n-1): + if a[i]+a[i+1]>x: + if a[i+1]>(x-a[i]): + ans+=(a[i+1]-(x-a[i])) + a[i+1]=(x-a[i]) +if a[-2]+a[i-1]>x: + if a[-1]>(x-a[-2]): + ans+=(a[-1]-(x-a[-2])) + a[-1]=(x-a[-2]) +print(ans) + + " +p02777,s139886615,Wrong Answer,"S = input() +print('x' * len(S)) +" +p03699,s441429272,Accepted,"N = int(input()) +s = [int(input()) for _ in range(N)] +s = sorted(s) +if sum(s) % 10 != 0: + print(sum(s)) + exit() +else: + for i in range(N): + if (sum(s) - s[i]) % 10 != 0: + print((sum(s) - s[i])) + exit() + +print(0)" +p02996,s999496183,Accepted,"N = int(input()) +tasks = [] +for i in range(N): + A, B = [int(x) for x in input().split()] + tasks.append([B, A]) +tasks.sort() + +ok = True +S = 0 +for i in range(N): + B, A = tasks[i][0], tasks[i][1] + S += A + if S > B: + ok = False + break + +if ok == True: + print(""Yes"") +else: + print(""No"")" +p03338,s933032809,Accepted,"N = int(input()) +S = input() +tmp = 0 +for i in range(N): + S1 = set(S[:i]) + S2 = set(S[i:]) + Sintcnt = len(S1 & S2) + tmp = max(tmp, Sintcnt) +print(tmp)" +p02578,s575416470,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +count=0 +high=0 + +for i in range(n): + if high>=a[i]: + count+=high-a[i] + else: + high=a[i] + +print(count)" +p02753,s755200090,Accepted,"stations = input() +listStations = list(stations) +if len(set(listStations)) == 2: + print(""Yes"") +else: + print(""No"")" +p02546,s416512307,Accepted,"s=str(input()) +if(s[-1]==""s""): + print(s+""es"") +else: + print(s+""s"")" +p02811,s378407401,Wrong Answer,"K, X = map(int,input().split()) +if 500*K > X: + print('Yes') +else: + print('No') + +" +p02718,s735681524,Accepted,"N,M=map(int,input().split()) +A=list(map(int,input().split())) +a=sum(A) +c=0 +for i in range(N): + if A[i]*4*M>=a: + c+=1 +if c>=M: + print('Yes') +else: + print('No')" +p02989,s983105235,Accepted,"def main(): + n = int(input()) + inlis = list(map(int,input().split())) + inlis.sort() + + left = inlis[int(n//2)-1] + right = inlis[int(n//2)] + + print(right-left) + +if __name__ == ""__main__"": + main() +" +p02768,s566305218,Accepted,"def main(): + import sys + + def input(): return sys.stdin.readline().rstrip() + + n, a, b = map(int, input().split()) + mod = 10 **9 + 7 + ans = pow(2, n, mod) -1 + c = 1 + for i in range(b): + c *= n-i + c%= mod + c *= pow(i+1, mod-2, mod) + c %= mod + if i == a-1: + ca = c + ans -= (c+ca)%mod + ans %= mod + print(ans) + + + + + + +if __name__ == '__main__': + main()" +p03475,s610600315,Accepted,"N = int(input()) + +ans = [0]*N +for i in range(N-1): + c,s,f = map(int,input().split()) + ans[i] += c+s + for j in range(i): + ans[j] = max((ans[j]+f-1)//f*f, s)+c +for a in ans: + print(a) + +" +p03145,s683977554,Accepted,"ab, bc, ca = map(int, input().split()) +print(ab * bc // 2) +" +p02860,s845044801,Accepted,"n = int(input()) +s = input() + +if n%2 == 0 and s[:(n//2)] == s[n//2:]: + print('Yes') +else: + print('No')" +p02596,s774408974,Accepted,"k = int(input()) +m = [False] * k +s = 0 +d = 7 % k +i = 0 +while True: + s = (s + d) % k + d = d * 10 % k + i += 1 + if s == 0: + print(i) + break + if m[s]: + print(-1) + break + m[s] = True +" +p03836,s643916246,Wrong Answer,"def main(): + a, b, c, d = map(int, input().split()) + dx, dy = (c - a), (d - b) + ans = ""U"" * dy + ""R"" * dx + ""D"" * dy + ""L"" * dx + print(ans) + + +if __name__ == '__main__': + main() +" +p03352,s019283955,Wrong Answer,"import math +A = int(input()) +B = math.floor(math.sqrt(A)) +print(B ** 2)" +p02958,s944443865,Wrong Answer,"N = int(input()) +P = list(input(). split()) +Q = sorted(P) +cnt = 0 +i = 0 + +while cnt <= 2 and i < len(P): + if Q[i] != P[i]: + cnt += 1 + i += 1 + +if cnt == 0 or cnt == 2: + print(""YES"") +else: + print(""NO"")" +p03252,s753129706,Accepted,"def get_char_set(word): + char_index = {} + for i, c in enumerate(word): + if c not in char_index.keys(): + char_index[c] = [] + char_index[c].append(i) + char_set = set() + for char_index_list in char_index.values(): + char_set.add(tuple(char_index_list)) + return char_set + +s = input() +t = input() + +s_char_set = get_char_set(s) +t_char_set = get_char_set(t) +if s_char_set == t_char_set: + print('Yes') +else: + print('No') +" +p02963,s420835205,Wrong Answer,"import sys + +sys.setrecursionlimit(10 ** 7) +f_inf = float('inf') + + +def resolve(): + s = int(input()) + x0, y0 = 0, 0 + if s == 10 ** 18 or 10 ** 9: + x1, y1 = 10 ** 9, 0 + else: + x1, y1 = 10 ** 9, 1 + + y2 = (s + x1 - 1) // x1 + x2 = 10 ** 9 - s % x1 + print(x0, y0, x1, y1, x2, y2) + # print(s - abs(x1 * y2 - x2 * y1)) + + +if __name__ == '__main__': + resolve() +" +p02701,s458851856,Accepted,"myset = set() +N = int(input()) +for i in range(N): + s = input() + myset.add(s) +print(len(myset)) +" +p02982,s791321305,Accepted,"#!/usr/bin/env python3 +n, d = map(int, input().split()) +l = [] +ans = [] + +for i in range(n): + l.append(list(map(int, input().split()))) + +for i in range(n-1): + for j in range(i+1, n, 1): + total = 0 + for k in range(d): + total += abs(l[i][k] - l[j][k]) ** 2 + + ans.append(total) + +cnt = 0 + +for i in ans: + for j in range(i+1): + if j**2 == i: + cnt += 1 + break + +print(cnt) +" +p02854,s896984382,Wrong Answer,"n = int(input()) +*a, = map(int, input().split()) +s = sum(a) +ans = 1001001001 +tmp = 0 +for i in a[:-1]: + tmp += i + ans = min(ans, abs(tmp*2 - s)) +print(ans)" +p04045,s540926871,Wrong Answer,"n, k = input().split() + +lst = list(map(int, input().split())) +res = """" +for i in range(len(n)): + append = int(n[i]) + while (1): + if append in lst: + append = append + 1 + else: + break + res += str(append) + +print(res)" +p02836,s262491525,Accepted,"s = input() +x = len(s) +ans = 0 +for i in range(int(x/2)): + if s[i] != s[x-1-i]: + ans += 1 +print(ans)" +p03339,s590211759,Accepted,"N = int(input()) +S = input() + +eastNumber = S.count('E') +westNumber = 0 +minimum = N + +for i in range(N): + if S[i] == 'E': + eastNumber -= 1 + number = eastNumber + westNumber + if minimum > number: + minimum = number + else: + number = eastNumber + westNumber + if minimum > number: + minimum = number + westNumber += 1 + +print(minimum)" +p02554,s230485168,Accepted,"#178-C + +N = int(input()) + +ans = 10**N - 2*9**N + 8**N + +print(ans % (10**9+7))" +p03827,s647340080,Accepted,"def main(): + N = int(input()) + S = list(input().rstrip()) + vals = [0] + for s in S: + if s == ""I"": + vals.append(vals[-1] + 1) + else: + vals.append(vals[-1] - 1) + print(max(vals)) + + +if __name__ == '__main__': + main() +" +p03861,s961096798,Accepted,"a, b, x = map(int, input().split("" "")) + +ad = a // x +bd = b // x +ans = bd - ad +if a % x == 0: + ans += 1 +print(ans)" +p04019,s838412637,Accepted,"s = set(input()) +if (""W"" in s and not ""E"" in s) or (""E"" in s and not ""W"" in s) or (""N"" in s and not ""S"" in s) or (""S"" in s and not ""N"" in s): + print(""No"") +else: + print(""Yes"")" +p03145,s768099864,Wrong Answer,"a,b,c = map(int,input().split()) +print(a*b/2)" +p04044,s255183723,Wrong Answer,"N,L=map(int, input().split("" "")) +s=[] +for i in range(N): + s.append(input()) + +s.sort() +print(s)" +p03592,s772270942,Wrong Answer,"n,m,k=map(int,input().split()) + +for i in range(n+1): + for j in range(m+1): + if i*m+j*n-i*j==k or i*m+j*n-i*j==n*m-k: + print('Yes') + exit() + + +print('No') + +" +p03001,s046902105,Wrong Answer,"w,h,x,y = map(int,input().split()) +sy = [] +sx = [] +sy.append((h-y)*w) +sy.append(y*w) +sx.append((w-x)*h) +sx.append(x*h) +sx_min = min(sx) +sy_min = min(sy) +if sx_min == sy_min: + print(sx_min, 1) +else: + print(max(sx_min,sy_min),0)" +p03416,s020656448,Accepted,"a, b = map(int, input().split()) + +cnt = 0 +for i in range(a, b+1): + s = str(i) + if s[0] == s[-1] and s[1] == s[-2]: + cnt += 1 + +print(cnt)" +p02933,s862309342,Wrong Answer,"a = int(input()) +s = input() + +if a >= 3200: + print(""red"") +else: + print(s) + +" +p02973,s614323936,Wrong Answer,"import heapq, bisect + +N = int(input()) +H = [] +min_lst = 10 ** 9 +for _ in range(N): + a = int(input()) + if min_lst >= a: + min_lst = a + heapq.heappush(H, -a) + else: + H[bisect.bisect_left(H, -a)] = a +print(len(H)) +" +p03254,s941395319,Accepted,"N,x=map(int,input().split()) +A=list(map(int,input().split())) +A.sort() +for i in range(len(A)): + if x-A[i]<0: + print(i) + exit() + else: + x-=A[i] +if x==0:print(N) +else:print(N-1) + +" +p03208,s882198061,Wrong Answer,"n, k = map(int, input().split()) +hl = [] +for i in range(n): + hl.append(int(input())) + +hl.sort(reverse=True) + +ans = 100000001 + +for j in range(n-k+1): + s = hl[j] - hl[j+k-1] + if s < ans: + ans = s + else: + pass +print(ans)" +p03067,s112775306,Accepted,"a,b,c=map(int,input().split()) +if((a ondo_sa: + r = ondo_sa + results = index + 1 +print(results)" +p02860,s636688686,Wrong Answer,"n=int(input()) +s=input() +m=0 +if n%2==0: + for i in range(n//2): + if s[i]==s[i+n//2]: + m+=1 +print(""Yes"" if m==(n//2) else ""No"")" +p02699,s236477595,Accepted,"S, W = map(int, input().split()) +if S <= W: + print('unsafe') + +else: + print('safe') +" +p03037,s496709374,Wrong Answer,"N, M = list(map(int, input().split())) + +min_num = 1 +max_num = N +for i in range(M): + min_input, max_input = list(map(int, input().split())) + if min_input > min_num: + min_num = min_input + + if max_input < max_num: + max_num = max_input + +print(max_num- min_num + 1)" +p03250,s404210349,Wrong Answer,"a, b, c = input().split() +if int(str(a+b)) >= int(str(b+c)): + print(int(str(a+b))+int(c)) +else: + print(int(str(b+c))+int(a))" +p02831,s767559919,Accepted,"from fractions import gcd + +A, B = map(int, input().split()) +res = A * B // gcd(A, B) + +print(res)" +p02779,s089475343,Wrong Answer,"n=int(input()) +a=[int(i) for i in input().split()] +a.sort() +flag=False +for j in range(n): + if j p[i] > p[i+1]: + cnt += 1 +print(cnt)" +p03524,s838635691,Wrong Answer,"from collections import Counter + +S = input() +c = Counter(S) + +if len(c) == 3 and max(c.values()) - min(c.values()) <= 1: + print(""YES"") +elif len(c) == 2 and max(c.values()) == min(c.values()): + print(""YES"") +elif len(c) == 1: + print(""YES"") +else: + print(""NO"") +" +p02658,s274879251,Accepted,"n=int(input()) +multi3 = [int(x.strip()) for x in input().split()] +ans=1 +flag=True +for i in multi3: + if ans*i>10**18: + flag=False + elif i==0: + flag=True + ans=0 + break + else: + ans*=i +if(flag): + print(ans) +else: + print(-1) +" +p03612,s151355333,Accepted,"N = int(input()) +p = list(map(int,input().split())) +ans = 0 +for i in range(N-1): + if p[i] == i+1: + p[i],p[i+1] = p[i+1],p[i] + ans += 1 +if p[N-1] == N: + ans += 1 +print(ans)" +p02689,s898412356,Wrong Answer,"n,m=map(int,input().split()) +hill=list(range(1,n+1)) +l=list(map(int,input().split())) +d={} +for i in range(n): + d[i+1]=l[i] + +for i in range(m): + a,b=map(int,input().split()) + if d[a]>d[b]: + if b in hill: + hill.remove(b) + if d[a]= k: + print("":("") +else: + print(""Yay!"")" +p03331,s336521783,Accepted,"n=int(input()) +ans=float(""inf"") +for i in range(1,n): + j=n-i + tmp=0 + I=str(i) + J=str(j) + for ii in range(len(I)): + tmp+=int(I[ii]) + for jj in range(len(J)): + tmp+=int(J[jj]) + if tmp K: + b = B + + if A == 0 and B == 0: + a = b = 0 + print(a, b) + + +main() +" +p02681,s528738845,Accepted,"s = input() +t = input() +l = len(t) +if s == t[:l-1]: + print('Yes') +else: + print('No')" +p03705,s365884257,Accepted,"N, A, B = map(int, input().split()) +if A > B: + print(0) +else: + if N == 1 and A == B: + print(1) + elif N == 1: + print(0) + else: + print((B-A)*(N-2)+1)" +p02708,s380895841,Wrong Answer,"import itertools + +n,i = map(int,input().split()) +a = [i + 10**100 for i in range(n+1)] +#a = [i + 10**1 for i in range(n+1)] +ans = {} +s = 0 +m = i +print(i,n) +while i <= n+1: + wrk = list(itertools.combinations(a,i)) + for l in wrk: + s = sum(l) + if s not in ans: + ans[s] = int(1) + else: + ans[s] += int(1) + i += 1 +print(len(ans))" +p02971,s859022171,Wrong Answer,"N = int(input()) +A = [] +for _ in range(N): + A.append(int(input())) + +maxA = sorted(set(A), reverse=True) +maxA1 = maxA[0] +maxA2 = -1 if len(maxA) == 1 else maxA[1] + +for i in range(N): + if A[i] == maxA1 and maxA2 != -1: + print(maxA2) + else: + print(maxA1) + " +p02742,s043329816,Accepted,"from decimal import * +H,W=map(int,input().split()) +if H==1 or W==1: + print(1) + exit() +t = H//2 + H%2 +t2 = t + H//2 +x = Decimal((W//2*t2)) + Decimal((W%2*t)) +print(x)" +p02953,s355123517,Accepted,"n = int(input()) +h = list(map(int, input().split())) +#b = list(map(int, input().split())) +flag = [0]*n +for i in reversed(range(1, n)): + if h[i] < h[i-1]: + h[i-1] -= 1 + +for i in range(n-1): + if h[i] > h[i+1]: + print(""No"") + exit() +print(""Yes"") +" +p02608,s600156061,Accepted,"# coding: utf-8 +import math +import itertools + +n = int(input()) + +ans = [0] * n + +for x, y, z in itertools.product(range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n)))): + idx = x**2 + y**2 + z**2 + x*y + y*z + z*x + if idx <= n: + ans[idx-1] += 1 + +print(*ans, sep=""\n"")" +p03352,s507099197,Wrong Answer,"x = int(input()) +min = 10000 +for i in range(1,1000): + for j in range(2,40): + if x-i**j < min and 0 < x-i**j: + min = x-i**j +if min > 1000: + print(x) +else: + print(x-min)" +p03252,s650868292,Accepted,"S=input() +T=input() +d=[[] for i in range(26)] +for i,c in enumerate(S): + d[ord(c)-ord('a')].append(i) +d2=[[]for i in range(26)] +for i,c in enumerate(T): + d2[ord(c)-ord('a')].append(i) +print(['No','Yes'][set((tuple(x) for x in d))==set((tuple(x) for x in d2))])" +p03680,s855786468,Accepted,"n = int(input()) +l = [0 for _ in range(n)] +already = set() +next = 1 +c = 0 +for i in range(n): + a = int(input()) + l[i] = a +while c <= n: + next = l[next-1] + c += 1 + if next == 2: + print(c) + break + elif next in already: + print(-1) + break + already.add(next)" +p03136,s511680670,Accepted,"import sys +import math +import bisect + + +def main(): + n = int(input()) + A = list(map(int, input().split())) + if sum(A) - max(A) > max(A): + print('Yes') + else: + print('No') + +if __name__ == ""__main__"": + main() +" +p03785,s119369524,Accepted,"n,c,k = map(int,input().split()) +t = sorted([int(input()) for i in range(n)]) +ans = 0 +j = 1 +rimit = 0 +for i in t: + if j=i: + j+=1 + else: + ans+=1 + rimit=i+k + j=1 +print(ans)" +p03644,s155892752,Accepted,"from math import log +N = int(input()) +print(2 ** int(log(N, 2)))" +p03105,s781659180,Accepted,"a, b, c = map(int, input().split()) +ans = min(c, b // a) +print(ans)" +p02730,s934805615,Accepted,"S = input() +N = len(S) +if S == S[::-1] and S[:int((N-1)/2)] == S[:int((N-1)/2)][::-1]: + print('Yes') +else: + print('No')" +p02711,s075621868,Accepted,"val= list(input()) +flag=0 +for i in range(0,len(val)): + if val[i]==""7"": + flag=1 +if flag == 1: + print(""Yes"") +else: + print(""No"")" +p02953,s688944015,Accepted,"n=int(input()) +h=list(map(int,input().split())) +k=h[0]-1 +for i in range(1,n-1): + if k<=h[i]-1:k=h[i]-1 + if k>h[i+1]: + print('No') + exit() +print('Yes')" +p02622,s648848086,Wrong Answer,"S = input() +T = input() +ans = 0 +for i in range(len(S)): + if S[i] != T[i]: + ans += 1 +print(i)" +p03087,s451135334,Accepted,"N,Q=map(int,input().split()) +S=input() +LR=[] +for i in range(Q): + LR.append(list(map(int,input().split()))) +t=[0]*(N+1) +for i in range(N): + if S[i:i+2]=='AC': + t[i+1]=t[i]+1 + else: + t[i+1]=t[i] +for i in range(Q): + print(t[LR[i][1]-1]-t[LR[i][0]-1])" +p02684,s826107316,Accepted,"import sys +readline = sys.stdin.readline +N,K = map(int,readline().split()) +A = [0] + list(map(int,readline().split())) +c = 1 +while K: + if K & 1: + c = A[c] + A = [A[A[i]] for i in range(len(A))] + K >>= 1 +print(c)" +p02711,s848205176,Accepted,"n=input() + +if ""7"" in n: + print(""Yes"") +else: + print(""No"")" +p03319,s023009361,Wrong Answer,"import math +N,K=map(int,input().split()) +A=list(map(int,input().split())) +saishou=A.index(1) +if K==N: + print(1) +elif saishou==0 or saishou==N-1: + answer=math.ceil((N-1)/(K-1)) + print(answer) +elif saishou+1<=K: + answer=1+math.ceil((N-K)/(K-1)) + print(answer) +elif N-saishou<=K: + answer=math.ceil((N-K)/(K-1))+1 + print(answer) +else: + print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1))) +" +p02862,s391370716,Accepted,"X,Y=map(int,input().split()) +mod=10**9+7 +if (X+Y)%3!=0: + print(0);exit() +if X*20: + cnt-=1 + else: + q.appendleft('(') + q.append(')') + else: + q.append('(') + cnt += 1 +if cnt: + for _ in range(cnt): + q.append(')') +print(''.join(q)) + +" +p03705,s573210036,Wrong Answer,"def main(): + N, A, B = (int(i) for i in input().split()) + if (N == 1 and A != B) or (B - A < 0): + print(0) + elif N == 1: + print(1) + elif N == 2: + print(1) + else: + print((B-A)*B - (B-A)*A + 1) + + +if __name__ == '__main__': + main() +" +p02947,s537197860,Accepted,"def main(): + n = int(input()) + s = ["""".join(sorted(input())) for i in range(n)] + + from collections import Counter + c = Counter(s) + res = 0 + for i in c.values(): + if i < 2: + continue + else: + res += i * (i-1) // 2 + print(res) + +if __name__ == '__main__': + main() + " +p02987,s619042811,Wrong Answer,"S = list(input()) + +S.sort() +#print(S) + +if S[0] == S[1]: + if S[2] == S[3]: + print(""Yes"") + else: + print(""No"") + + +else: + print(""No"") + + " +p02963,s151772508,Accepted,"import math + +N = int(input()) +a = math.ceil(N/(10**9)) +b = a*10**9-N +print(0, 0, 10**9, b, 1, a)" +p03137,s038463631,Accepted,"N, M = map(int, input().split()) +X = sorted(list(map(int, input().split()))) + +D = [] +for i in range(1, M): + d = X[i] - X[i - 1] + D.append(d) +D.sort() + +if N != 1: + D = D[:-1 * (N - 1)] + +print(sum(D)) +" +p02731,s026429360,Wrong Answer,"l=int(input()) +if l==1: + print(""%.18f""%((1/3)**3)) + exit() +if l==2: + tt=2/3 + print(""%.18f""%((tt)**3)) + exit() +a=l/3 +b=l/3 +c=l/3 +temp=l%3 +# ans=0 +if temp==0: + ans=(a*b*c) + print(""%.18f""%(ans)) + exit() +if temp==1: + a+=(1/3) + b+=(1/3) + c+=(1/3) + ans=a*b*c + print(""%.18f""%(ans)) + exit() +if temp==2: + tt=2/3 + ans=(a+tt)*(b+tt)*(c+tt) + print(""%.18f""%(ans)) + exit()" +p03997,s797110918,Accepted,"a = int(input()) +b = int(input()) +h = int(input()) + +print(int((a+b)*h/2))" +p03836,s510229265,Wrong Answer,"sx, sy, tx, ty = map(int, input().split()) +ans = """" +gx, gy = (tx - sx, ty - sy) +# go +ans += ""R"" * gx + ""U"" * gy +ans += ""R"" + ""D"" * (gy + 1) + ""L"" * gx + ""U"" + +# return +ans += ""U"" * gx + ""R"" * gy +ans += ""U"" + ""L"" * (gx + 1) + ""D"" * gy + ""R"" + +print(ans) +" +p03061,s774843553,Wrong Answer,"import fractions +from functools import reduce + +def gcd_list(numbers): + if numbers != []: + return reduce(fractions.gcd, numbers) + else: + return 0 + +if __name__ == '__main__': + n = int(input()) + a_lst = [int(elem) for elem in input().split()] + left_gcd = [0] * n + right_gcd = [0] * n + ans = 0 + for i in range(0,n): + left_gcd[i] = gcd_list(a_lst[:i]) + right_gcd[i] = gcd_list(a_lst[i+1:]) + print(left_gcd, right_gcd) + for i in range(n): + ans = max(ans, fractions.gcd(left_gcd[i],right_gcd[i])) + print(ans)" +p03241,s507894170,Accepted,"n,m = map(int,input().split()) +ans = 0 +lst = [] +for i in range(1,int(m**0.5)+1): + if m%i == 0: + if m//i < n: + break + else: + ans = i + lst.append(m//i) +lst.sort() +for i in lst: + if m//i < n: + break + else: + ans = i + +print(ans)" +p03286,s823794253,Accepted,"#!/usr/bin/python3 +# -*- coding:utf-8 -*- + +def main(): + n = int(input()) + s = 0 + ans = [] + for i in range(50): + if (n - s) % (2**(i+1)) == 0: + ans.append('0') + else: + ans.append('1') + s += ((-2) ** i) + if s == n: + break + print(''.join(ans[::-1])) + +if __name__=='__main__': + main() + +" +p03730,s469837509,Wrong Answer,"a, b, c = map(int, input().split()) +l = [] + +#aに1~bの数をかけたリストを作る +for i in range(b + 1): + if i == 0: + pass + else: + l.append((i * a) % b) + +if c in l == True: + print(""Yes"") +else: + print(""No"")" +p02747,s571777480,Wrong Answer,"while True: + s = input() + if 1 <= len(s) <= 10: + break + +flag = False + +for l in range(len(s)): + print(s[len(s)-2] + s[len(s)-1]) + if s[len(s)-2]==""h"" and s[len(s)-1]==""i"": + print(""Yes"") + flag = True + break + + if s[l]==""h"" and s[l+1]==""i"" and s[l+2]!=""i"": + print(""Yes"") + flag = True + break + + +if flag == False: + print(""No"") +" +p03293,s939855482,Accepted,"s = input() +t = input() + +flag = False + +for i in range(1, len(s)+1): + s1 = s[:i] + s2 = s[i:] + if s2 + s1 == t: + flag = True +if flag: + print(""Yes"") +else: + print(""No"")" +p04034,s805697989,Wrong Answer,"import numpy as np + +n, m = map(int, input().split()) +possibility = [0 for _ in range(n)] +ball = [1 for _ in range(n)] +possibility[0] = 1 +for i in range(m): + x, y = map(int, input().split()) + if ball[x-1] != 0: + possibility[y-1] = 1 + ball[x-1] -= 1 + ball[y-1] += 1 +print(np.sum(np.array(possibility) > 0))" +p02677,s466774376,Wrong Answer,"import math +a, b, h, m = map(int, input().split()) +m_rad = 6 * m +h_rad = 30 * h + m / 2 +rad = abs(h_rad - m_rad) +rad = rad +if rad > 180: + rad = 360 - rad + print(rad) +length_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(rad)) +print(length_2**0.5)" +p02933,s336456862,Wrong Answer,"a = int(input()) +s = input() + +if a >= 3200: + print(s) +else: + print(""res"")" +p03359,s013826311,Accepted,"lst = input().split() +a = int(lst[0]) +b = int(lst[1]) + +if a <= b: + print(a) +else: + print(a - 1)" +p02595,s899996600,Accepted,"n, d=(int(x) for x in input().split()) +d *= d +ans = 0 +for i in range(n): + a, b = (int(x) for x in input().split()) + if a*a + b*b <= d: + ans += 1; + +print(ans)" +p03797,s917237501,Accepted,"n,m=map(int,input().split()) + +if 2*n= b: + print(y + 1) + break + else: + y += 1" +p02823,s046079402,Accepted,"n,a,b = map(int, input().split()) +if a > b : a,b = b,a #swap +### 差が偶数 +if (b-a)%2 == 0: + print((b-a)//2) +if (b-a)%2 == 1: + ### 1側で調整 + ichi = a + (b-a-1)//2 + ### n側で調整 + b = n-b + a = n-a + enu = b + 1 + (a-b-1)//2 + print(min(ichi,enu))" +p03623,s887347662,Accepted,"x, a,b = map(int, input().split()) +xa = abs(a-x) +xb = abs(b-x) +if xa > xb: + print('B') +else: + print('A')" +p03331,s912594593,Accepted,"N=int(input()) +if N==10 or N==10**2 or N==10**3 or N==10**4 or N==10**5: + print(10) +else: + a=list(str(N)) + b=sum([int(i) for i in a]) + print(b) +" +p02646,s194048934,Accepted,"A,V = (int(x) for x in input().split()) +B,W = (int(x) for x in input().split()) +T = int(input()) + +if V>W and abs(A-B)/(V-W)<=T: + Flag = True +else: + Flag = False + +if Flag: + print('YES') +else: + print('NO')" +p03323,s020407515,Accepted,"[A,B] = list(map(int,input().split())) +if A<=8 and B<=8: + print(""Yay!"") +else: + print("":("") +" +p02820,s208533859,Wrong Answer,"def main(): + N, K = map(int, input().split()) + R, S, P = map(int, input().split()) + T = input() + scores = [] + for t in T: + if t == 'r': + scores.append(P) + elif t == 's': + scores.append(R) + else: + scores.append(S) + for i in range(N-K): + if scores[i] == scores[i+K]: + scores[i+K] = 0 + print(sum(scores)) + + +if __name__ == '__main__': + main() +" +p03951,s957294854,Wrong Answer,"n = int(input()) +s = input() +t = input() +cnt = 0 +for i in range(n): + print(s[i:]) + print(t[:n-i]) + if s[i:] == t[:n-i]: + cnt += n - i + break +print(2 * n - cnt)" +p02664,s127502321,Accepted,"s = input() +s = list(str(s)) + +for i in range(len(s)): + if s[i] == '?': + s[i] = 'D' + +print(''.join(s))" +p04031,s797729402,Accepted," +n=int(input()) +a=list(map(int,input().split())) + +amin=min(a) +amax=max(a) + +smin=(amax**2)*n +for y in range(amin,amax+1): + ssum=0 + for i in range(n): + ssum=ssum+(a[i]-y)**2 + smin=min(smin,ssum) + +print(smin) +" +p03495,s639120338,Accepted,"from collections import Counter + +N, K = [int(x) for x in input().split()] +A = [int(x) for x in input().split()] + +cntA = Counter(A) +cntvalA = sorted(list(cntA.values())) +ans = sum(cntvalA[i] for i in range(len(cntvalA) - K)) +print(ans)" +p03779,s303018038,Accepted,"X = int(input()) +pos = 0 +for i in range(1, 100001): + pos += i + if pos >= X: + print(i) + break +" +p02971,s777704008,Wrong Answer,"N = int(input()) +li = [int(input()) for i in range(N)] + +for index, i in enumerate(li): + new = sorted(li) + + s = max(li) + + if s == li[index]: + print(new[1]) + else: + print(s)" +p02708,s946759313,Accepted,"#!/usr/bin/env python + +def main(): + n, k = map(int, input().split()) + + cnt = 0 + min_ = 0 + max_ = 0 + + for i in range(1, n+2): + min_ += i - 1 + max_ += n - i + 1 + + if i >= k: + cnt += max_ - min_ + 1 + cnt %= 10 ** 9 + 7 + + print(cnt) + + +if __name__ == '__main__': + main() +" +p03632,s816443421,Accepted,"a, b, c, d = map(int, input().split()) + +print(max(min(b, d) - max(a, c), 0))" +p02576,s047179709,Accepted," +import math + +to_make, at_most, batch_time = map(int, input().split()) + +batches = math.ceil(to_make / at_most) +print(batch_time * batches) + +" +p02705,s533880759,Wrong Answer,"R=int(input()) +ans=R*3.14159 +print(ans)" +p03486,s587897701,Accepted,"s = list(input()) +t = list(input()) + + +s.sort() +t.sort(reverse=True) + +if ''.join(s) < ''.join(t): + print('Yes') +else: + print('No') + " +p03659,s629335819,Wrong Answer,"from itertools import accumulate + +N = int(input()) +lst = list(map(int, input().split())) + +cumsum = list(accumulate(lst)) + +mi = 2 * 10 ** 9 +su = cumsum[-1] +for i in cumsum: + mi = min(mi, abs(su - 2 * i)) +print(mi)" +p02953,s987528832,Wrong Answer,"n=int(input()) +h=list(map(int,input().split())) +f=1 +for i in range(n-2): + if h[i+1]-h[i]<-1 or h[i+2]-h[i+1]<-1: + f=0 + break + if h[i+1]-h[i]<=0 and h[i+2]-h[i+1]<0: + f=0 + break + +if f: + print(""Yes"") +else: + print(""No"")" +p02835,s446739629,Accepted,"A1,A2,A3 = map(int,input().split()) + +if (A1+A2+A3)>=22: + print('bust') +else: + print('win')" +p02780,s138045161,Accepted,"N, K = map(int, input().split()) +P = list(map(int, input().split())) + +next_end = K + +num = sum(P[:next_end]) + +max_num = num + +for start in range(1, N - K + 1): + num -= P[start - 1] + num += P[next_end] + max_num = max(num, max_num) + next_end += 1 + +print((max_num + K) / 2)" +p02723,s593127414,Accepted,"s=input() +if s[2]==s[3] and s[4]==s[5]: + print(""Yes"") + exit() +print(""No"")" +p03479,s076086748,Accepted,"x,y = map(int,input().split()) +nsum = x +ans = 1 +while(nsum<=y): + nsum=nsum*2 + if(nsum>y): + break + ans += 1 +print(ans)" +p02621,s829535302,Wrong Answer,"a=5 +if 10: + print('Yes') + else: + print('No')" +p02862,s638393214,Accepted,"mod = 10**9 + 7 + +def ncr(n, r): + r = min(r, n-r) + x, y = 1, 1 + for i in range(r): + x = (x * (n-i)) % mod + y = (y * (i+1)) % mod + + return x * pow(y, mod-2, mod) % mod + + +X, Y = map(int, input().split()) + + +if 2*Y - X < 0 or 2*X - Y < 0 or (2*Y - X) % 3 != 0 or (2*X - Y) % 3 != 0: + print(""0"") +else: + M = (2*Y - X) // 3 + N = (2*X - Y) // 3 + print(ncr(M+N,N))" +p03524,s881012100,Wrong Answer,"S=input() +L=[0,0,0] +for i in range(len(S)): + if S[i]==""a"": + L[0]+=1 + elif S[i]==""b"": + L[1]+=1 + else: + L[2]+=1 + +L.sort() +if L[2]-L[0]<=1: + print(""Yes"") +else: + print(""NO"")" +p03105,s268442071,Accepted,"a,b,c = map(int, input().split()) + +tmp =int(b/a) + +if tmp > c: + print(c) +else: + print(tmp)" +p03037,s144434631,Accepted,"n,m = map(int,input().split()) +l,r = [],[] +for i in range(m): + a,b = map(int,input().split()) + l.append(a) + r.append(b) +num = list(range(1,n+1)) +lmax = max(l) +rmin = min(r) +if lmax > rmin: + print(0) +else: + gate = set(range(lmax,rmin+1)) + ans = list(set(num) & gate) + print(len(ans))" +p02793,s512904668,Accepted,"from fractions import gcd +import sys +input = sys.stdin.readline +MOD = 10 ** 9 + 7 + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + + l = A[0] + for i in range(1, N): + l = l * A[i] // gcd(l, A[i]) + + print(sum([l // a for a in A]) % MOD) + + +if __name__ == '__main__': + main() +" +p02553,s041212141,Wrong Answer,"a,b,c,d = map(int, input().split()) + +if b < 0: + if c > 0: + print(b*c) + else: + print(a*c) +elif a < 0: + if d < 0: + print(a*c) + elif c < 0: + print(max(a*c,b*d)) + else: + print(b*d) +else: + if d < 0: + print(b*c) + else: + print(b*d) + +" +p02571,s884124969,Accepted,"S = str(input()) +T = str(input()) +ans = 1000 +for i in range(len(S) - len(T) + 1): + c = 0 + for j in range(len(T)): + if S[i] != T[j]: + c += 1 + i += 1 + ans = min(ans, c) +print(ans)" +p03997,s176852402,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) +s = (a + b) * h / 2 +print(s)" +p03329,s090161319,Accepted,"N=int(input()) +dp=[float(""inf"")]*(10**5+10) +dp[0]=0 +for i in range(1,N+1): + dp[i]=1+dp[i-1] + X=6 + Y=9 + j=1 + k=1 + while(i>=X**j): + dp[i]=min(dp[i],1+dp[i-X**j]) + j+=1 + while(i>=Y**k): + dp[i]=min(dp[i],1+dp[i-Y**k]) + k+=1 +print(dp[N]) +" +p03672,s667979143,Accepted,"def evenstring(s) : + while len(s) > 0 : + s = s[ : -2] + t1 = s[ : int(len(s) / 2)] + t2 = s[int(len(s) / 2) : ] + if t1 == t2 : + return len(t1) + len(t2) + + +s = input() + +print(evenstring(s)) +" +p03481,s321045253,Accepted,"def solve(): + X, Y = [int(i) for i in input().split()] + ans = 0 + while X <= Y: + ans += 1 + X *= 2 + print(ans) + + +if __name__ == ""__main__"": + solve()" +p03062,s917677560,Accepted,"N = int(input()) +A = map(int, input().split()) + +A_plus = [] +A_minus = [] + +for a in A: + if a >= 0: + A_plus.append(a) + else: + A_minus.append(a) + +A_plus = sorted(A_plus) +A_minus = sorted(A_minus) + + +if len(A_minus) % 2 == 0: + res = sum(A_plus) - sum(A_minus) +else: + if len(A_plus) > 0: + res = sum(A_plus) - sum(A_minus) - 2*min(A_plus[0], (-1)*A_minus[-1]) + else: + res = sum(A_plus) - sum(A_minus) + 2*A_minus[-1] + +print(res) +" +p02829,s816848093,Accepted,"lst = [""1"",""2"",""3""] +for i in range(2): + lst.remove(input()) +print(lst[0])" +p03150,s424277449,Accepted,"s = input() +n = len(s) + +if ""keyence"" == s: + print(""YES"") + exit() + +for i in range(n): + for j in range(i+1, n): + if s[:i] + s[j:] == ""keyence"": + print(""YES"") + exit() + +print(""NO"") +" +p02556,s164278110,Wrong Answer,"n = int(input()) + +mx_dis1, mn_dis1 = 0, 10**9 +mx_dis2, mn_dis2 = 0, 10**9 +for i in range(n): + x, y = map(int, input().split()) + dis1 = x + y + dis2 = x - y + mx_dis1 = max(dis1, mx_dis1) + mn_dis1 = min(dis1, mn_dis1) + mx_dis2 = max(dis2, mx_dis2) + mn_dis2 = min(dis2, mn_dis2) + +ans1 = mx_dis1 - mn_dis1 +ans2 = mx_dis2 - mn_dis2 + +print(max(ans1, ans2))" +p03971,s132840836,Wrong Answer,"n, a, b = map(int, input().split()) +s = input() +cnt = 0 +memo = 0 +for i in range(n): + if s[i] == 'c': + print('No') + else: + if cnt < a + b: + cnt += 1 + if s[i] == 'b' and memo <= b: + memo += 1 + print('Yes') + elif s[i] == 'a': + print('Yes') + else: + print('No') + else: + print('No') +" +p03105,s093642677,Accepted,"A, B, C = map (int, input().split()) + +print(min(C, B // A))" +p03657,s015438117,Wrong Answer,"A,B = map(int,input().split()) + +if (A + B) % 3 == 0 and (A + B)//3 == A and (A + B)//3 == B and (A + B)//3 == A + B: + print(""Yes"") +else: + print(""No"")" +p03962,s627062192,Accepted,"print(len(set(map(int, input().split(' '))))) +" +p02743,s734220912,Accepted,"a,b,c = map(int,input().split()) +if a + b > c: + print('No') + exit() +if ((c - a - b) ** 2) - 4 * a * b > 0: + print('Yes') +else: + print('No') +" +p03611,s147706047,Wrong Answer,"N = int(input()) +a = list(map(int, input().split())) +X1, X2, X3 = 0, a.count(0), a.count(1) +count = X1 + X2 + X3 +ans = 0 +for i in range(2, max(a) + 1): + count -= X1 + X1, X2, X3 = X2, X3, a.count(i) + count += X3 + ans = max(ans, count) +else: + print(ans)" +p02598,s359623474,Accepted,"import sys +import heapq +import math +import fractions +import bisect +import itertools +from collections import Counter +from collections import deque +from operator import itemgetter +def input(): return sys.stdin.readline().strip() +def mp(): return map(int,input().split()) +def lmp(): return list(map(int,input().split())) + +n,k=map(int,input().split()) +a=lmp() + +def ok(s): + c=0 + for i in a: + c+=-(-i//s)-1 + return c<=k + + +l=0 +r=max(a) +while r>l+1: + md=(r+l)//2 + if ok(md): + r=md + else: + l=md +print(r)" +p03069,s506377801,Accepted,"from collections import Counter + +N = int(input()) +S = input() +counter_s = Counter(S) +min_stone = counter_s.most_common()[-1][1] +if min_stone == N: + min_stone = 0 +A, B = 0, counter_s['.'] +for s in S: + if s == '#': + A += 1 + else: + B -= 1 + if min_stone > A+B: + min_stone = A+B +print(min_stone)" +p02708,s576730574,Accepted,"N, K = map(int, input().split()) +num = list(range(N+1)) +count = 0 +base_minimum = sum([i for i in num[:K]]) +base_maximum = sum([i for i in num[-K:]]) +count += base_maximum - base_minimum + 1 + +for k in range(K, N+1): + base_minimum += num[k] + base_maximum += num[-k-1] + count += base_maximum - base_minimum + 1 + +print(int(count%(1e9+7)))" +p02717,s184370738,Accepted,"input_line = input().split() +input_line = [int(s) for s in input_line] +print(str(input_line[2]) + "" "" + str(input_line[0]) + "" "" + str(input_line[1]))" +p03681,s541143668,Wrong Answer,"import math +n,m=map(int,input().split()) +mod=10**9+7 +a=math.factorial(n)*math.factorial(m) +if abs(n-m)==0: + print(2*a%mod) +elif abs(n-m)>1: + a=0 +print(a%mod) +" +p03695,s170131288,Wrong Answer,"n=int(input()) +A=list(map(int,input().split())) +B=[0,0,0,0,0,0,0,0] +red=int(0) +for i in range(n): + now=int(A[i]/400) + if now<8: + B[now]=1 + else: + red+=1 + +ans=B.count(1) +print(""{} {}"".format(ans,ans+red))" +p03673,s603549704,Wrong Answer,"n = int(input()) +a = input().split() + +print(' '.join(a[-1:0:-2]+a[::2]))" +p03548,s986563715,Accepted,"X,Y,Z=map(int,input().split()) +L=X-Z +ans=0 +for i in range(1000000): + if L >= (Z+Y)*i: + ans=i + else: + break +print(ans)" +p03680,s583992031,Accepted,"n=int(input()) +data=[] +for i in range(n): + data.append(int(input())) +ans=0 +index=1 +for i in range(n): + ans += 1 + index=data[index-1] + if index == 2: + print(ans) + break +else: + print(-1)" +p02811,s900605173,Accepted,"K,X = map(int,input().split()) +if 500*K >= X: + print('Yes') +else: + print('No')" +p03478,s136732028,Wrong Answer,"n, a, b = map(int, input().split()) +answer = 0 +for i in range(1, n + 1): + if a<= sum(list(map(int, list(str(n))))) <= b: + answer += i +print(answer)" +p02787,s418006472,Wrong Answer,"h, n = map(int, input().split()) +inf = 10**12 +data = [] +max_a = 0 +for i in range(n): + data.append(list(map(int, input().split()))) + max_a = max(max_a, data[i][0]) +dp = [[inf for i in range(h+1 + max_a)] for j in range(n+1)] +dp[0][0] = 0 +for i in range(n): + a, b = data[i] + for j in range(h): + if j - a >= 0: + dp[i+1][j] = min(dp[i+1][j-a] + b, dp[i][j]) + else: + dp[i+1][j] = b +print(dp[-1][h-1])" +p03455,s933316850,Wrong Answer,"import math +l=[] +l2=[] + +l=list(map(str,input().split())) +d=int("""".join(l)) +for i in range(1,350): + c=pow(i,2) + l2.append(c) + +if d in l2: + print(""Yes"") +else : + print(""No"")" +p02724,s021365022,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Thu Dec 19 22:37:09 2019 + +@author: lucifer +"""""" +n=int(input()) +if n%500==0: + print(1000*int(n/500)) +else: + s=int(n/500) + x=1000*s+int((n-(s*500))/5)*5 + print(x)" +p03639,s251867105,Accepted,"n=int(input()) +a=list(map(int,input().split())) +c4=0 +c2=0 +for i in range(n): + if a[i]%4==0: + c4+=1 + elif a[i]%2==0: + c2+=1 + +if c2==0: + print(""Yes"" if 2*c4+1>=n else ""No"") +else: + x=c4*2+c2 + if x>=n: + print(""Yes"") + else: + print(""No"")" +p04029,s413246284,Wrong Answer,"n=int() +c=int() +for i in range(0,n): + while n==1: + c+=1 + print(c) + +" +p03779,s824240612,Wrong Answer,"import sys +def input(): return sys.stdin.readline().strip() +def mapint(): return map(int, input().split()) +sys.setrecursionlimit(10**9) + +X = int(input()) +fac = {} +fac[0] = 0 +for i in range(1, 50000): + fac[i] = fac[i-1]+i + if fac[i]>=10**9: + break + +for i in range(1, 50000): + f = fac[i] + if f==X: + print(i) + break + if f>X: + print((X-fac[i-1])+i-1) + break" +p03146,s934730871,Accepted,"n=int(input()) +ans=[] +ans.append(n) +tf=True +while tf: + if n%2==0: + n//=2 + ans.append(n) + else: + n=3*n+1 + ans.append(n) + for i in range(len(ans)-1): + for j in range(i+1,len(ans)): + if ans[i]==ans[j]: + print(len(ans)) + tf=False" +p03698,s363266432,Wrong Answer,"S = input() +M = len(S) +N = set(S) +O = list(N) +P = len(O) +if M == P: + print('Yes') +else: + print('No')" +p03680,s482397899,Accepted,"N = int(input()) +a = [int(input()) for _ in range(N)] +a.insert(0, 0) +next = 1 +ans = 0 +for i in range(N): + next = a[next] + ans += 1 + if next == 2: + print(ans) + break +else: + print(-1) +" +p03815,s638559165,Accepted,"import math +x = int(input()) + +ans = (x//11) * 2 + +x %= 11 + +if x == 0: + print(ans) +elif x <= 6: + print(ans+1) +else: + print(ans+2)" +p03485,s821711587,Accepted,"a,b = map(int,input().split()) + +ans = (a+b)//2 +if (a+b)%2 != 0: ans += 1 +print(ans)" +p02665,s267046637,Accepted,"n = int(input()) +a = list(map(int,input().split())) +dmax = [0]*(n+2) +x = []*(n+1) + +i = n +ne = 0 +while i >= 0: + dmax[i] = a[i] + dmax[i+1] + i -= 1 + +hantei = True +ans = 0 +x.append(1) + +for i in range(n+1): + if x[i] < a[i]: + hantei = False + break + else: + x.append(min((x[i]-a[i]) * 2,dmax[i+1])) + ans += x[i] + +print(ans) if hantei else print(-1) + +" +p03145,s576977933,Accepted,"# -*- coding: utf-8 -*- + +ab, bc, ca = map(int, input().split()) + +print(int((ab * bc) / 2))" +p02813,s556327669,Accepted,"import itertools + +N = int(input()) +P_list = list(map(int, input().split())) +Q_list = list(map(int, input().split())) + + +for i, v in enumerate(itertools.permutations(range(1,N+1))): + if list(v) == P_list: + a = i + 1 + if list(v) == Q_list: + b = i + 1 + +print(abs(a-b))" +p03639,s378027883,Wrong Answer,"import sys + +sys.setrecursionlimit(10 ** 7) +input = sys.stdin.readline +f_inf = float('inf') +mod = 10 ** 9 + 7 + + +def resolve(): + n = int(input()) + A = list(map(int, input().split())) + + cnt_4 = 0 + cnt_2 = 0 + for a in A: + if a % 4 == 0: + cnt_4 += 1 + elif a % 2 == 0: + cnt_2 += 1 + + print(""Yes"" if n - cnt_2 // 2 <= cnt_4 * 2 + 1 else ""No"") + + +if __name__ == '__main__': + resolve() +" +p02707,s640610618,Accepted,"N = int(input()) +A = list(map(int, input().split())) +dic = {i:0 for i in range(1, N+1)} +for i in range(N-1): + dic[A[i]] += 1 + +for v in dic.values(): + print(v)" +p04045,s632994702,Wrong Answer,"n,k = map(int,input().split()) +if k == 0: + print(n) + exit() +dislike = list(map(int,input().split())) +usable = [] +for i in range(10): + if i not in dislike: + usable.append(i) +print(usable) +ans = '' +for i in str(n): + while int(i) not in usable: + i = str((int(i)+1)%10) + ans+=i + + +print(ans)" +p02779,s705336380,Accepted,"N=int(input()) + +A=[int(i) for i in input().split("" "")] +if len(set(A))==N: + print(""YES"") +else: + print(""NO"") +" +p03814,s488721663,Accepted,"S = input() +t = 0 +z = 0 +for i in range(0,len(S)): + if(t == 0)and(S[i] == 'A'): + a = i + t += 1 + if(S[i] == 'Z') and i > z: + z = i +print(z-a+1)" +p02677,s301211261,Wrong Answer,"import math +A,B,H,M = map(int, input().split()) +time = H * 60 + M + +Asita = time / 720 +Bsita = (time % 60) / 60 +sita = abs(Asita - Bsita) * 2 * math.pi + +Ans = ( A**2 + B**2 - 2 * A * B * abs(math.cos(sita)))**0.5 +print(Ans)" +p02601,s435656762,Accepted,"A, B, C = map(int, input().split()) +K = int(input()) + +ans = ""No"" +def f(a, b, c, cnt, k): + global ans + if cnt > k: + return + if b > a and c > b: + ans = ""Yes"" + return + + f(2*a, b, c, cnt+1, k) + f(a, 2*b, c, cnt+1, k) + f(a, b, 2*c, cnt+1, k) + + +f(A, B, C, 0, K) +print(ans)" +p03815,s358259755,Accepted,"x=int(input()) +l=x//11 +cnt=2*l +if x%11==0: + print(cnt) +elif 0= H[i+1]: + tmp += 1 + ans = max(tmp, ans) + else: + tmp = 0 +print(ans)" +p02548,s457803493,Accepted,"ma = lambda :map(int,input().split()) +lma = lambda :list(map(int,input().split())) +tma = lambda :tuple(map(int,input().split())) +ni = lambda:int(input()) +yn = lambda fl:print(""Yes"") if fl else print(""No"") +ips = lambda:input().split() +import collections +import math +import itertools +import heapq as hq +n = ni() +ans = 0 +for a in range(1,n): + ans += (n-1)//a +print(ans) +" +p03241,s688281002,Accepted,"N, M = map(int, input().split()) + + +def make_divisors(n): + lower_divisors, upper_divisors = [], [] + i = 1 + while i * i <= n: + if n % i == 0: + lower_divisors.append(i) + if i != n // i: + upper_divisors.append(n // i) + i += 1 + return lower_divisors + upper_divisors[::-1] + +div_list = make_divisors(M) +div_list = div_list[::-1] +for div in div_list: + if N * div <= M: + print(div) + exit() +" +p02888,s096299922,Wrong Answer,"n = int(input()) +import bisect +a = sorted(list(map(int, input().split("" "")))) +ans = 0 +for i in range(1, n-1): + b = a[:i] + c = a[i + 1:] + #print(b, c) + for j in b: + ans += bisect.bisect(c, a[i]+j-0.1) - bisect.bisect(c, a[i]+0.1) + #print(bisect.bisect(c, a[i]+j-0.1), bisect.bisect(c, a[i]+0.1)) +print(ans)" +p03062,s282458163,Accepted,"n = int(input()) +al = list(map(int, input().split())) + +min_abs = 10**9 +abs_sum = 0 +minus_cnt = 0 +zero_cnt = 0 +for a in al: + if a < 0: minus_cnt+=1 + elif a == 0: zero_cnt+=1 + abs_sum += abs(a) + min_abs = min(min_abs, abs(a)) + +if minus_cnt%2 == 0: + print(abs_sum) +else: + if zero_cnt > 0: + print(abs_sum) + else: + print(abs_sum-min_abs*2) +" +p03448,s273070662,Wrong Answer,"n500 = int(input()) +n100 = int(input()) +n50 = int(input()) +p = int(input()) +ans = 0 + +for i in range(n500): + temp = 0 + temp = i*500 + for j in range(n100): + temp = i*500+j*100 + for k in range(n50): + temp = i*500+j*100+k*50 + if temp == p: + ans+=1 + +print(ans)" +p02627,s310595557,Accepted,"a=input() +l=[chr(i) for i in range(97,97+26)] +if a in l: + print('a') +else: + print('A')" +p02631,s037548920,Accepted,"#E +n = int(input()) +a = list(map(int,input().split())) +result = [] +A = 0 +for i in range(len(a)): + A = A^a[i] + +for i in range(len(a)): + result.append(a[i]^A) + +print(*result)" +p03637,s023143778,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +cnt_0, cnt_2, cnt_4 = 0, 0, 0 +for i in range(N): + if A[i] % 4 == 0: + cnt_4 += 1 + elif A[i] % 2 == 0: + cnt_2 += 1 + else: + cnt_0 += 1 + +if cnt_2 == 0: + if cnt_4 >= cnt_0 - 1: + print(""Yes"") + else: + print(""No"") +else: + if cnt_4 >= cnt_0: + print(""Yes"") + else: + print(""No"")" +p02701,s753705050,Accepted,"N = int(input()) +items = set() +for n in range(0, N): + items.add(input()) +print(len(items))" +p03041,s330932267,Accepted,"from collections import defaultdict, deque +import sys, heapq, bisect, math, itertools, string, queue, copy, time +from fractions import gcd +import numpy as np +sys.setrecursionlimit(10**8) +INF = float('inf') +MOD = 10**9+7 +EPS = 10**-7 + + +n, k = map(int, input().split()) +s = input() + +s = list(s) +s[k-1] = s[k-1].lower() +ans_s = """" +for i in s: + ans_s += i +print(ans_s)" +p03067,s772702064,Wrong Answer,"a,b,c= map(int, input().split()) +if aX: + print(i) + break + cnt = 1 + while cnt*i<=double: + s.add(i*cnt) + cnt += 1" +p02640,s623351630,Accepted,"x, y = map(int, input().split()) +if(y & 1): + print(""No"") +elif(y < (x<<1) or y > (x<<2)): + print(""No"") +else: + print(""Yes"")" +p04045,s225448344,Accepted,"N,K=map(int, input().split()) +D=list(map(int, input().split())) + +for i in range(N,10**9): + S=str(i) + ok=True + for s in S: + if int(s) in D: + ok=False + if ok: + ans=i + break + +print(ans) +" +p03719,s146704143,Accepted,"a, b, c = map(int, input().split()) +print(""Yes"" if b >= c >= a else ""No"")" +p03971,s644600133,Wrong Answer,"N,A,B = map(int,input().split()) +S = list(input()) + +C = A + B +ans = [] +df = 0 +f = 0 + +for i in range(N): + s = S[i] + if s == 'c': + ans.append('No') + continue + elif s == 'a': + df += 1 + if df <= C: + ans.append('Yes') + else: + ans.append('No') + elif s == 'b': + df += 1 + f += 1 + if df <= C and f <= B: + ans.append('Yes') + else: + ans.append('No') + +print('\n'.join(ans)) + +" +p03338,s487678830,Wrong Answer,"N = int(input()) +S = list(input()) + +m = 0 + +l = [max(m, len(set(S[:S.index(s)])&(set(S[S.index(s):])))) for s in S] +print(max(l)) +" +p03042,s041815875,Wrong Answer,"S = input() +f, r = int(S[:2]), int(S[2:]) +#print(f) +#print(r) +if f == 0 or r == 0 or (f > 12 and r > 12): + ans = ""NA"" +elif f > 12 and r <= 12: + ans = ""YYMM"" +elif f <= 12 and r > 12: + ans = ""MMYY"" +elif r <= 12 and f <= 12: + ans = ""AMBIGUOUS"" +print(ans)" +p02624,s311918795,Accepted,"import sys, math +input = sys.stdin.readline +rs = lambda: input().strip() +ri = lambda: int(input()) +rl = lambda: list(map(int, input().split())) +mod = 10**9 + 7 + +N = ri() + +ans = 0 +for i in range(1, N+1): + m = N//i + ans += m*(m+1)*i//2 +print(int(ans)) +" +p03419,s528882666,Accepted,"n, m = map(int, input().split()) +if n == 1 and m == 1: + print(1) +elif n == 1: + print(m - 2) +elif m == 1: + print(n - 2) +else: + print((n - 2) * (m - 2))" +p03371,s837039373,Accepted,"a, b, c, x, y = map(int, input().split()) + +ans = 0 + +if c*2 < a+b: + ans += min(x, y) * c * 2 + if x > y: + ans += min(a, 2*c) * abs(x-y) + elif x < y: + ans += min(b, 2*c) * abs(x-y) +else: + ans += a * x + b * y + +print(ans)" +p03481,s853761314,Wrong Answer,"import math +x, y = map(int, input().split()) + +ans = int(math.log2(y/x)) + +print(ans + 1)" +p03136,s840767241,Wrong Answer,"def resolve(): + n = int(input()) + L = map(int, input().split()) + M = max(L) + R = sum(L) - M + if R > M: + print('Yes') + else: + print('No') +resolve() " +p03208,s674000560,Accepted,"def main(): + N, K = (int(i) for i in input().split()) + H = [int(input()) for i in range(N)] + ans = 10**12 + H.sort() + for i in range(N-K+1): + ans = min(ans, H[i+K-1] - H[i]) + print(ans) + + +if __name__ == '__main__': + main() +" +p02618,s896609593,Accepted,[print(1) for i in range(365)] +p02726,s515844034,Accepted,"n,x,y = map(int,input().split()) + +u = [] +for i in range(1,n): + for j in range(i+1,n+1): + u.append(min(j-i,abs(x-i)+abs(y-j)+1)) + +import collections +u2 = collections.Counter(u) +u2 = list(u2.items()) +for k in range(n): + u2.append((0,0)) + +for i in range(n-1): + if u2[i][0] == i+1: + print(u2[i][1]) + else: + print(0)" +p03377,s632712477,Accepted,"a,b,x = map(int,input().split()) +print('YES' if 0<=x-a<=b else 'NO')" +p02598,s719022528,Wrong Answer,"n,k = map(int,input().split()) +a = list(map(int,input().split())) + +leq,high = 0,1e10 +while high-leq > 1: + l = int((leq+high)/2) + cnt = 0 + for ai in a: + cnt += int((ai-1)/l) + print(l,cnt) + if cnt>k: + leq = l + else: + high = l + +print(high)" +p02631,s371901957,Accepted,"import sys +import math as mt +input=sys.stdin.buffer.readline +#t=int(input()) +t=1 +for __ in range(t): + #n,k=map(int,input().split()) + n=int(input()) + l=list(map(int,input().split())) + xori=0 + for i in l: + xori^=i + for i in l: + print(xori^i,end="" "") + " +p02748,s953916586,Wrong Answer,"A, B, M = map(int, input().split()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +x = [0] * M +y = [0] * M +c = [0] * M + +ans = 10 ** 5 +for i in range(M): + x[i], y[i], c[i] = map(int, input().split()) + p = a[x[i]-1] + b[y[i]-1] - c[i] + if ans > p: + ans = p + +if ans > min(a) + min(b): + ans = min(a) + min(b) +elif ans > min(a): + ans = min(a) +else: + ans = min(b) + +print(ans)" +p02584,s870733064,Accepted,"x,k,d= map(int, input().split()) + +if x-k*d>=0 : + print(str(x-k*d)) +elif x+k*d<=0 : + print(abs(x+k*d)) +else : + a=x//d + b=x%d + if (k-a)%2==0 : + print(str(b)) + else : + print(str(d-b))" +p03485,s955699296,Wrong Answer,"a, b = map(int, input().split()) +print((a + b + 1)/ 2)" +p03475,s034765023,Accepted,"n = int(input()) +inp = [] +for i in range(n-1): + inp.append(list(map(int, input().split()))) + +for i in range(n-1): + total = 0 + for j in range(i, n-1): + if total < inp[j][1]: + total = inp[j][1] + while total % inp[j][2] != 0: + total += 1 + total += inp[j][0] + print(total) +print(0) + + + + +" +p02742,s613279074,Accepted,"h,w = map(int, input().split()) +if h == 1 or w == 1: + print(1) +elif h % 2 == 0 or w % 2 == 0: + print(h*w//2) +else: + print((h*w + 1)//2)" +p02880,s371936694,Wrong Answer,"N = int(input()) +ans = ""No"" +for i in range(1,9): + if N%i == 0: + ans = ""Yes"" +print(ans)" +p03721,s388522347,Wrong Answer,"from collections import defaultdict +n,k=map(int,input().split()) +ab=[input() for i in range(n)] +d = defaultdict(list) +[d[i.split()[0]].append(int(i.split()[1])) for i in ab] +sd=sorted(d.items(), key=lambda x:x[0]) +c=0 +for i,l in sd: + c+=sum(l) + if c>=k: + print(i) + exit()" +p03086,s563862072,Accepted,"s = input() +for i in range(len(s)+1): + for j in range(len(s)-i+1): + if [k for k in s[j:j+i]] == [k for k in s[j:j+i] if k=='A' or k=='G' or k=='C' or k=='T']: + a=i +print(a)" +p02756,s080507894,Accepted,"from collections import deque +def main(): + d=deque(list(input())) + Q=int(input()) + rev=0 + for i in range(Q): + q=list(map(str, input().split())) + if q[0]=='1': + rev+=1 + else: + if (int(q[1])+rev)%2==1: + d.appendleft(q[2]) + else: + d.append(q[2]) + if rev%2==0: + print(''.join(list(d))) + else: + d.reverse() + print(''.join(list(d))) +main()" +p03109,s126642107,Accepted,"a,b,c = map (int, input ().split ('/')) +if a > 2019: + print ('TBD') +else: + if b*100+c > 430: + print ('TBD') + else: + print ('Heisei')" +p02778,s141798787,Accepted,"print(""x""*len(input()))" +p03043,s006954139,Accepted,"def main(): + N,K = [int(x) for x in input().split()] + prob = 0 + for i in range(N): + dice=i+1 + coin = 0 + while dice < K: + dice *= 2 + coin += 1 + prob += float(1/N) * 0.5**coin + print(prob) + +if __name__ == '__main__': + main()" +p03067,s246900837,Accepted,"A,B,C = map(int,input().split()) +if (A < C and C < B) or (A > C and C > B): + print('Yes') +else: + print('No')" +p04011,s651049672,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) + +cost = 0 +if 1 <= n <= 10000 and 1 <= k <= 10000 and 1 <= y < x <= 10000: + if n > k: + cost += x * k + cost += y * (n - k) + elif n <= k: + cost += n * x + +print(cost)" +p02639,s918822996,Wrong Answer,"A = list(map(int,input().split())) +print(A.index(0))" +p02754,s208054133,Accepted,"N,A,B=map(int,input().split()) +K=N//(A+B) +print(K*A+min(A,N%(A+B)))" +p02623,s840782375,Wrong Answer,"n,m,k = map(int,input().split()) +a = [int(i) for i in input().split()][::-1] +b = [int(i) for i in input().split()][::-1] +ans = 0 +cnt = 0 +while True: + if a and b: + if a[-1] < b[-1]: nxt = a.pop() + else: nxt = b.pop() + elif a: nxt = a.pop() + elif b: nxt = b.pop() + else: break + if cnt + nxt > k: break + else: + cnt += nxt + ans += 1 +print(ans)" +p02859,s733781228,Accepted,"# +# +import math +r = int(input()) +print(r*r) +" +p03679,s686667005,Accepted,"X,A,B = map(int,input().split()) + +if B <= A: + print(""delicious"") +elif (B-A) <= X: + print(""safe"") +else: + print(""dangerous"")" +p03493,s774122415,Accepted,"s=list(input()) +print(s.count(""1""))" +p02952,s413673274,Wrong Answer,"n = int(input()) +# 100000 +# 1-9 9 100-999 900 10000-99999 90000 +if n <= 9: + print(n) + exit() +if n > 9 and n <= 999: + print(9 + n-99) + exit() +if n > 999 and n <= 99999: + print(9 + 900 + n-9999) + exit() +if n > 99999 : + print(9 + 900 + 90000) + exit()" +p03804,s246191166,Wrong Answer,"def is_same(si, sj): + for i in range(M): + for j in range(M): + if gridsA[sj + j][si + i] != gridsB[j][i]: + return False + return True + + +N, M = map(int, input().split()) +gridsA = [input() for _ in range(N)] +gridsB = [input() for _ in range(M)] + +for i in range(N - M): + for j in range(N - M): + if is_same(i, j): + print('Yes') + exit() +print('No') +" +p02836,s967460244,Wrong Answer,"S = input() +l = len(S)-1 +if (l % 2 == 0): + ls = l/2 +else: + ls = l//2 + 1 + +n = 0 + +for x in range(int(ls)): + if (S[x] != S[l-x]): + S = S.replace(S[x],S[l-x]) + n +=1 + +print(n)" +p02744,s758446694,Wrong Answer,"import itertools +n = int(input()) +li = list(itertools.product([0,1], repeat=n)) +alp = list('abcdefghijklmnopqrstuvwxyz') + +ans_li = ['0'] +for _ in range(n-1): + tmp = [] + for a in ans_li: + last = int(a[-1])+1 + for i in range(last+1): + tmp.append(a+str(i)) + ans_li = tmp +for bb in ans_li: + ans = '' + for b in bb: + ans += alp[int(b)] + print(ans)" +p03861,s824610016,Accepted,"a, b, x = map(int, input().split()) + +c=b//x +if a%x==0: + d=a//x-1 +else: + d=a//x +print(c-d)" +p03071,s881112203,Wrong Answer,"a, b = map(int, input().split()) +if a == b: + print(a+a-1) +elif b > a: + print(b+b-1) +else: + print(a+a-1)" +p02639,s253972605,Accepted,"x = list(map(int, input().split())) + +for i in range(5): + if x[i]==0: + print(i+1) + exit()" +p03127,s654958182,Accepted,"#!/usr/bin/env python3 +from functools import reduce +from math import gcd + +n, *a = map(int, open(0).read().split()) +print(reduce(gcd, a)) +" +p02996,s162290339,Accepted,"N = int(input()) + +lst = [] +for i in range(N): + N, K = map(int, input().split()) + lst.append((N, K)) + +lst.sort(key=lambda tup: tup[1]) +time = 0 +for x in lst: + time += x[0] + if time > x[1]: + print(""No"") + exit() + +print(""Yes"") +" +p03761,s361232072,Accepted,"import sys +import heapq, math +from itertools import zip_longest, permutations, combinations, combinations_with_replacement +from itertools import accumulate, dropwhile, takewhile, groupby +from functools import lru_cache +from copy import deepcopy + +N = int(input()) +S = [list(input()) for _ in range(N)] + +minimum = [100] * 26 +for i in range(N): + tmp = [0] * 26 + for s in S[i]: + tmp[ord(s) - ord('a')] += 1 + + for j in range(26): + minimum[j] = min(minimum[j], tmp[j]) + +ans = [] + +for i in range(26): + for j in range(minimum[i]): + ans.append(chr(i + ord('a'))) + +print("""".join(ans)) +" +p02924,s099104140,Accepted,"N = int(input()) +print(N*(N-1)//2)" +p02911,s607651590,Accepted,"# from math import factorial,sqrt +# from itertools import permutations as permus +# from fractions import gcd +from collections import deque,Counter +# from decimal import Decimal, getcontext +# # getcontext().prec = 1000 +# # eps = Decimal(10) ** (-100) + +# import numpy as np +# import scipy as scp + +# 入力の受け取り +n,k,q = map(int,input().split()) +correct_member = [int(input())-1 for _ in range(q)] + +ans = [k-q for _ in range(n)] + +cormem_count = Counter(correct_member) + +for k,v in cormem_count.items(): + ans[k] += v + +for i in ans: + YorN = ""Yes"" if i > 0 else ""No"" + print(YorN) +" +p03474,s462851360,Wrong Answer,"A, B = map(int, input().split()) +S = list(input().split('-')) +try: + if len(S[0]) == A and len(S2[1]) == B: + print('Yes') + else: + print('No') +except: + print('No') +" +p03545,s283129534,Accepted,"a = list(map(int, list(input()))) +f = lambda x: '+' if x==1 else '-' +for i in range(-1, 2, 2): + for j in range(-1, 2, 2): + for k in range(-1, 2, 2): + if a[0]+i*a[1]+j*a[2]+k*a[3]==7: + print(str(a[0])+f(i)+str(a[1])+f(j)+str(a[2])+f(k)+str(a[3])+'=7') + exit()" +p02676,s857280918,Wrong Answer,"n = int(input()) +word = input() +ans = """" +if len(word) <= n: + print(word) +else: + for i in range(n): + ans += word[i] + ans +=(""..."") + print(ans)" +p03478,s537915377,Wrong Answer,"n,a,b=map(int,input().split()) +cnt=0 +for i in range(1,n+1): + x=i//1000+(i%1000)//100+(i%100)//10+i%10 + if a<=x and b>=x: + cnt+=1 +print(cnt)" +p02900,s908642670,Accepted,"a,b = map(int,input().split()) +def prime_factorize(n): + a = [] + while n % 2 == 0: + a.append(2) + n //= 2 + f = 3 + while f * f <= n: + if n % f == 0: + a.append(f) + n //= f + else: + f += 2 + if n != 1: + a.append(n) + return a + +A = set(prime_factorize(a)) +B = set(prime_factorize(b)) + +cnt = 0 +for i in A: + if i in B: + cnt += 1 +print(cnt+1)" +p03285,s090312127,Wrong Answer,"s = int(input()) +while s >0: + s = s-4 + if s%7 == 0: + print('Yes') + break + +if s<0: + print('No')" +p02881,s972342611,Wrong Answer,"import sys +import math +N = int(input()) +for i in range(int(math.sqrt(N)),2,-1): + if N % i ==0: + print(N//i+i-2) + sys.exit() +print(N-1)" +p03013,s174496288,Accepted,"import itertools,sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +N,M = LI() +a = set([I() for _ in range(M)]) +dp = [0]*(N+1) #1_indexed +dp[0] = 1 +dp[1] = 0 if 1 in a else 1 +for i,j in itertools.product(range(2,N+1),[1,2]): + if i in a: + dp[i] = 0 + continue + dp[i] += dp[i-j] + dp[i] %= 10**9+7 +print(dp[-1]) +" +p03338,s112749034,Wrong Answer,"import sys + +n=int(input()) +s=str(input()) +list=[] +for i in range(1,n): + a=s[0:i] + b=s[i:] + print(a) + print(b) + count=0 + for j in range(97,97+26): + if (chr(j) in a)and(chr(j) in b): + count+=1 + list.append(count) +print(max(list))" +p03274,s520089877,Accepted,"n, k = map(int, input().split()) +x = list(map(int, input().split())) +ans = 10 ** 9 +for i in range(n-k+1): + t = min(abs(x[i]), abs(x[i+k-1])) + ans = min(ans, t + abs(x[i]-x[i+k-1])) +print(ans)" +p02701,s791305531,Accepted,"import sys + +N = int(input()) +S = set() +for i in range(N): + S.add(str(input())) + + +print(len(S)) + + +" +p03854,s615588003,Accepted,"s = input() +l = len(s) +while len(s)>0: + l=len(s) + if s[l-5:]=='dream' or s[l-5:]=='erase': + s=s[:l-5] + elif s[l-6:]=='eraser': + s=s[:l-6] + elif s[l-7:]=='dreamer': + s=s[:l-7] + else: + print('NO') + exit() +print('YES') +" +p02777,s012121543,Accepted,"def q1(): + S,T = (s for s in input().split()) + A,B = (int(i) for i in input().split()) + U = input() + + if U == S: + A -= 1 + elif U == T: + B -= 1 + print('{} {}'.format(A,B)) + + +if __name__ == '__main__': + q1()" +p03095,s215528213,Accepted,"from collections import Counter +n = int(input()) +s = input() +mod = 10**9 + 7 +ans = 1 +scnt = Counter(s) +for cnt in scnt.values(): + ans = ans*(cnt+1) % mod + +print(ans-1)" +p02633,s351118833,Wrong Answer,"import math +x=int(input()) +if x==60: + print(3) +else: + print(360//math.gcd(x,180))" +p03803,s846347617,Accepted,"a,b = map(int, input().split()) +if a==1: + a+=13 +if b==1: + b+=13 +if a==b: + print(""Draw"") +else: + print(""Alice"" if a>b else ""Bob"")" +p02829,s762456919,Accepted,"a = int(input()) +b = int(input()) +print(6-a-b)" +p02693,s898898707,Wrong Answer,"k = int(input()) +a, b = map(int, input().split()) + +print('OK' if b - a >= k else 'NG')" +p03067,s313466269,Wrong Answer," + +a,b,c=map(int,input().split()) + +if a < c < b: + print('Yes') +else: + print('No')" +p03494,s962957015,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +ans = 99 + +for i in a: + j = i + split_count = 0 + while j % 2 == 0: + j = j / 2 + split_count += 1 + ans = min(ans, split_count) +print(ans)" +p04012,s858613553,Accepted,"# python 3.4.3 +import sys +input = sys.stdin.readline +# import numpy as np +from collections import Counter + +# ------------------------------------------------------------- +# function +# ------------------------------------------------------------- + + +# ------------------------------------------------------------- +# main +# ------------------------------------------------------------- +W = input().rstrip() + +C = Counter(W).most_common() + +ans = ""Yes"" +for _,cnt in C: + if cnt%2 == 1: + ans = ""No"" + break + +print(ans)" +p03681,s850061655,Wrong Answer,"n, m = map(int, input().split()) +MOD = 10**9 + 7 + +if abs(n - m) > 1: + print(0) +if n == m: + ans = 1 + for i in range(2, n + 1): + ans *= i + ans %= MOD + # xoxoxo... とoxoxox... 、どっちを先にするかで2種類 + print(2 * ans * ans % MOD) +else: + ans = 1 + for i in range(2, n + 1): + ans *= i + ans %= MOD + for i in range(2, m + 1): + ans *= i + ans %= MOD + print(ans) +" +p03778,s104470494,Accepted,"#!/usr/bin/env python3 +W, a, b = map(int, input().split()) + +a_l = a +a_r = a + W +b_l = b +b_r = b + W + +if b_r < a_l: + print(abs(b_r - a_l)) +elif a_r < b_l: + print(abs(a_r - b_l)) +else: + print(0) +" +p03073,s815335080,Accepted,"s = input() + +words = [w for w in s] + +cnt = 0 +for r in range(len(words) - 1): + if words[r+1] == words[r]: + if words[r+1] == '0': + words[r+1] = '1' + else: + words[r+1] = '0' + cnt += 1 + +print(cnt)" +p03494,s237995337,Accepted,"n=int(input()) +a=[int(i)for i in input().split()] +d=lambda x:x/2 + +def devide(x,lst): + global d + for i in lst: + if i%2 ==1: + return x + return devide(x+1,list(map(d,lst))) + +print(devide(0,a))" +p03696,s966339974,Accepted,"n=int(input()) +s=input() + +tyo=0 +tmax=0 +for i in range(n): + if s[i]=="")"": + tyo+=1 + tmax=max(tmax,tyo) + else: # ""("" + tyo-=1 + +lastkcnt=tmax+s.count(""("")-s.count("")"") +ans=""(""*tmax+s+"")""*lastkcnt +print(ans)" +p03329,s913837468,Accepted,"N = int(input()) +dp = [i for i in range(N + 1)] + +for i in range(N + 1): + index = 1 + while 6 ** index <= i: + dp[i] = min(dp[i], dp[i - (6 ** index)] + 1) + index += 1 + + index = 1 + while 9 ** index <= i: + dp[i] = min(dp[i], dp[i - (9 ** index)] + 1) + index += 1 + +print(dp[N])" +p03106,s060232685,Accepted,"a,b,k=map(int,input().split()) +wari=[] +for i in range(1,101): + if a%i==0 and b%i==0: + wari.append(i) + +print(wari[-k])" +p02618,s452175907,Accepted,"import numpy as np + +D = int(input()) +c = np.array(list(map(int, input().split()))) +S = np.array([list(map(int, input().split())) for i in range(D)]) + +last_day = np.zeros(26, dtype=int) +score = 0 + +def calc(d, i, last_day): + decrease = c * (d - last_day) + decrease[i] = 0 + return S[d, i] + decrease.sum() + +ans = [] +for d in range(1, D+1): + diff = [calc(d-1, i, last_day) for i in range(26)] + choice = np.argmax(diff) + ans.append(choice+1) + last_day[choice] = d + +print(*ans, sep='\n')" +p02973,s576457235,Accepted,"from collections import deque +from bisect import bisect_left +N = int(input()) +A = [int(input()) for _ in range(N)] +que = deque() +for i in range(N): + k = bisect_left(que, A[i]) + if k == 0: + que.appendleft(A[i]) + else: + que[k - 1] = A[i] + +print(len(que))" +p02861,s885622567,Wrong Answer,"import math +N=int(input()) +x=[0]*N +y=[0]*N +for i in range(N): + x[i],y[i]=map(int,input().split()) +ans_sum=0 +for i in range(N): + for j in range(N): + ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2) +print(ans_sum/math.factorial(N))" +p02553,s576457191,Accepted,"from sys import stdin,stdout +# n=int(stdin.readline()) +a,b,c,d=list(map(int,stdin.readline().split())) +ans=max(a*c,a*d,b*c,b*d) +print(ans)" +p03795,s597690121,Wrong Answer,"n = int(input()) +x = n +y = n//15 +print(x-y)" +p03379,s172686015,Wrong Answer,"n = int(input()) +l = list(map(int,input().split())) +p1 = n//2 +p2 = n//2-1 +l.sort() + +for i in range(n): + if i < p1: + print(l[p1]) + else: + print(l[p2]) +" +p03076,s974473548,Accepted,"from math import * +l = [int(input()) for _ in range(5)] + +ans = 0 +_min = 10 +for i in l: + ans += ceil(i/10) * 10 + if i%10!=0: + _min = min(_min,i%10) + +print(ans-10+_min)" +p03037,s231701016,Accepted,"N, M = map(int, input().split()) +max_L, min_R = 1, N +for i in range(M): + L, R = map(int, input().split()) + if L > max_L: + max_L = L + if R < min_R: + min_R = R +ans = min_R - max_L + 1 +if ans < 0: + ans = 0 +print(ans)" +p02909,s828331068,Accepted,"S = input() + +if S == ""Sunny"": + print(""Cloudy"") +elif S == ""Cloudy"": + print(""Rainy"") +else: + print(""Sunny"") + " +p03545,s304325195,Accepted,"s = input() +n = len(s) + +for bit in range(1 << (n-1)): + f = s[0] + + for i in range(n - 1): + if bit & (1 << i): + f += ""+"" + else: + f += ""-"" + f += s[i + 1] + + ans = eval(f) + if ans == 7: + res = f + ""=7"" + break + +print(res)" +p02823,s883503594,Accepted,"n,a,b = map(int,input().split()) +if (b-a)%2==0: + print((b-a)//2) +else: + ret1 = a+(b-a-1)//2 + ret2 = n-b+1+(b-a-1)//2 + print(min(ret1, ret2))" +p03659,s318197325,Accepted,"n = int(input()) +a = list(map(int, input().split())) +x = a[0] +y = sum(a[i] for i in range(1, n)) +ans = abs(x-y) +for i in range(1, n - 1): + x += a[i] + y -= a[i] + ans = min(ans, abs(x - y)) +print(ans) +" +p02578,s201687085,Accepted,"N = int(input()) +height = [int(i) for i in input().split()] +step = 0 +for i, h in enumerate(height): + if i == 0: + pre = h + else: + if h < pre: + step += (pre - h) + pre = pre + else: + step += 0 + pre = h +print(step)" +p03284,s299802476,Wrong Answer,"N, K = map(int, input().split()) + +print(N%K) +" +p03427,s103465825,Accepted,"n = input() +if n[1:] == '9'*(len(n)-1): + print(int(n[0]) + (len(n)-1)*9) +else: + print(int(n[0])-1 + (len(n)-1)*9) +" +p03659,s927639645,Accepted,"n = int(input()) +a = list(map(int, input().split())) +sub = sum(a) - 2 * a[0] +asub = abs(sub) + +for i in range(1, n - 1): + sub -= 2 * a[i] + if abs(sub) < asub: + asub = abs(sub) +print(asub) +" +p03639,s339682092,Accepted,"#解説AC + +n = int(input()) +A = list(map(int, input().split())) + +b1, b4 = 0, 0 +for a in A: + if a % 2: + b1 += 1 + if a % 4 == 0: + b4 += 1 + +b2 = min(1, n-(b1+b4)) + +if b1+b2-1 <= b4: + print(""Yes"") +else: + print(""No"")" +p03705,s931037539,Wrong Answer,"N,A,B = map(int,input().split()) + +if A > B or A == B: + print(0) +else: + a = (N-2)*(B-A) + 1 + print(a)" +p03637,s786961366,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) + +count = len([a for a in A if a % 4 == 0]) +print(count, n // 2) +print(""Yes"" if count >= n // 2 else ""No"")" +p03417,s367651180,Accepted,"h, w = map(int, input().split()) +h, w = min(h, w), max(h, w) +if h == 1: + if w == 1: + ans = 1 + elif w == 2: + ans = 0 + else: + ans = w - 2 +elif h == 2: + ans = 0 +else: + ans = (h - 2) * (w - 2) +print(ans)" +p03285,s660525007,Accepted,"n = int(input()) + +for i in range(n // 4 + 1): + for j in range(n // 7 + 1): + s = 4*i + 7*j + if s > n: + break + if s == n: + print(""Yes"") + exit() +print(""No"")" +p02820,s376233207,Accepted,"n, k = map(int, input().split()) +r,s,p = map(int, input().split()) +t = input() +z = 0 +kachi = dict({""r"": ""p"", ""s"": ""r"", ""p"": ""s""}) +tt = [] +for i in range(n): + tt.append(kachi[t[i]]) +#print(t) +#print(tt) +for i in range(n - k): + if tt[i] == tt[i + k]: + tt[i+k] = ""z"" +kachi = dict({""r"": r, ""s"": s, ""p"": p, ""z"": 0}) +res = 0 +for i in range(n): + res += kachi[tt[i]] +print(res)" +p02910,s003971263,Accepted,"S = list(input()) +f = True +for i in range(len(S)): + if i % 2 == 0: + if S[i] == ""L"": + f = False + elif i % 2 != 0: + if S[i] == ""R"": + f = False +if f: + print(""Yes"") +else: + print(""No"")" +p02546,s468717902,Accepted,"S = input() +if S[-1] == 's': + print(S + 'es') +else: + print(S + 's')" +p02848,s670303968,Accepted,"N = int(input()) +S = list(input()) +T = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] +t = len(T) +n = len(S) +S2 = [] +for i in range(n): + for j in range(t): + if S[i] == T[j]: + a = T[(j+N)%t] + S2.append(a) + break +k = S2[0] +for i in range(1,n): + k += S2[i] +print(k) +" +p02629,s731812260,Wrong Answer,"import sys +import numpy as np +import math +from collections import deque +from functools import reduce + +n = int(input()) +az = ""abcdefghijklmnopqrstuvwxyz"" +cnt = 12 +ret = [] +ama = n % 26 +na = n +for i in range(12, 0, -1): + if 26**(i-1) > n: + continue + sho = na // (26**i) + if sho > 0: + ret.append(az[sho-1]) + else: + ret.append('z') + na -= sho * (26**i) +if ama > 0: + ret.append(az[ama-1]) +if (ret[0] == 'z'): + del ret[0] +re = """".join(ret) +print(re) + +" +p03556,s197870639,Wrong Answer,"N = int(input()) + +for i in range(N): + if i**2 >= N: + print((i-1)**2) + exit()" +p02726,s938833193,Accepted,"from itertools import combinations + +N, X, Y = map(int, input().split()) +count = [0] * N +for i, j in combinations(range(1, N+1), 2): + k = min(j - i, abs(X - i) + 1 + abs(Y - j)) + count[k] += 1 +print(*count[1:], sep='\n')" +p03017,s764539985,Accepted,"n, a, b, c, d = map(int, input().split()) +a, b, c, d = a-1, b-1, c-1, d-1 +s = input() + +if c < d: + if ""##"" in s[a:d]: + print(""No"") + exit() + + print(""Yes"") + +else: + for i in range(b, d+1): + if s[i] != ""#"" and s[i-1] == ""."" and s[i+1] == ""."": + print(""Yes"") + exit() + + print(""No"")" +p02994,s578650189,Wrong Answer,"N,L=map(int,input().split()) +taste=0 +for i in range(N): + taste += L + i + +diff=10*6 +index=-1 +for i in range(N): + if abs(L+i) < diff: + diff = abs(L+i) + index = i +print(taste - (L+i)) +" +p03433,s377980351,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +Alice = 0 +Bob = 0 +A.sort(reverse=True) +Alice += sum(A[::2]) +Bob += sum(A[1::2]) +print(Alice - Bob)" +p02731,s210390201,Accepted,"import math +from decimal import Decimal + +if __name__ == ""__main__"": + L = int(input()) + hoge = L / 3 + ret = hoge**3 + print(ret) +" +p03419,s134766191,Accepted,"n,m=map(int,input().split()) + +if n>=2 and m>=2: + print((n-2)*(m-2)) +elif n==1 and m==1: + print(1) +else: + print(max(n,m)-2) +" +p03105,s484692628,Wrong Answer,"A, B, C = map(int,input().split()) +C = B//A +print(C)" +p03086,s723830507,Accepted,"S = input() +result = 0 +for i in range(len(S)): + head = S[i:] + for j in range(len(head)): + tail = head[:j + 1] + if len(list(filter(lambda x: x not in ""ACGT"", tail))) == 0: + result = len(tail) if len(tail) > result else result +print(result) +" +p03696,s528197860,Wrong Answer,"from collections import deque + +N=int(input()) +S=input() +stack= deque([]) +ans="""" + +for i in range(N): + if S[i]==""("": + stack.append(S[i]) + #print(ans) + else: + if stack: + ans += stack.pop()+"")"" + #print(ans) + else: + ans = ""("" + ans + "")"" + #print(ans) +nokori=len(stack) +ans += nokori * ""("" + nokori * "")"" + +print(ans)" +p03380,s732658159,Accepted,"import bisect +s = int(input()) +a = list(map(int, input().split())) +aa = sorted(a) +v = 0 +m = aa[-1] +x = bisect.bisect_left(aa,m//2) +if abs(aa[x-1]) > abs(m-aa[x]): + b = aa[x-1] +else: + b = aa[x] +if aa[x] == m: + x -= 1 + b = aa[x] +print (m,b)" +p02646,s917266100,Wrong Answer,"import math +a, v = map(int, input().split()) +b, w = map(int, input().split()) +t = int(input()) + +if w >= v: + print('No') +else: + for i in range(1,t+1): + if abs(a-b) <= (w-v)*i: + print('Yes') + break + print('No') + " +p04012,s592092712,Accepted,"from collections import defaultdict +w=list(input()) + +dic=defaultdict(int) +for c in w: + dic[c]+=1 + +for v in dic.values(): + if v%2==1: + print(""No"") + break +else: + print(""Yes"")" +p02726,s939916112,Accepted,"import collections +n,x,y=map(int,input().split()) +lst=[] +num=[0]*(n+1) +for i in range(1,n): + for j in range(i+1,n+1): + k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x)) + if num[k]==0: + num[k]+=1 + lst.append(k) + +Lst=list(collections.Counter(lst).items()) +key=0 +for i in range(1,n): + if num[i]==0: + print(0) + else: + print(Lst[key][1]) + key+=1" +p03416,s984781217,Wrong Answer,"A, B = map(int,input().split()) + +ans = 0 +def palindrome(string): return 0 if string==string[::-1] else 1 +for i in range(A, B): + if palindrome(str(i)) == 0 : + ans += 1 + +print(ans)" +p03799,s541434564,Accepted,"import sys +input = sys.stdin.readline + + +def readstr(): + return input().strip() + + +def readint(): + return int(input()) + + +def readnums(): + return map(int, input().split()) + + +def readstrs(): + return input().split() + + +N, M = readnums() + +''' +N:M = 1:2が理想 +N + x: M -2x = 1:2 +2N+2x = M-2x +M-2N=4x +''' + +if M >= N * 2: + x = (M - 2 * N) // 4 + print(N + x) +else: + print(M // 2) +" +p03745,s107647613,Accepted,"n = int(input()) +a = list(map(int,input().split())) +sw = 0 +count = 1 +for i in range(n-1): + if sw == 1: + if a[i+1]a[i]: + sw = 0 + count += 1 + else: + if a[i+1]>a[i]: + sw = 1 + elif a[i]>a[i+1]: + sw = -1 +print(count)" +p03126,s690407608,Accepted,"x = list(map(int, input().split())) +k = [list(map(int, input().split())) for i in range(x[0])] +f = 0 +for i in k: + i.pop(0) + if f == 0: + tmp = i + f = 1 + s = i + else: + s = set(tmp) & set(i) + tmp = s +print(len(s))" +p02780,s480914939,Accepted,"N, K = map(int, input().split()) +P = list(map(int, input().split())) + +ans = sum([(p+1)/2 for p in P[:K]]) +tmp = ans +for i in range(N-K): + tmp = tmp - (P[i]+1)/2 + (P[K+i]+1)/2 + ans = max(ans, tmp) + +print(ans)" +p02723,s821271596,Accepted,"s = input() +if s[2] == s[3] and s[4] == s[5]: + print('Yes') +else: + print('No')" +p03487,s567269321,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +dic = dict() + +for a in A: + if str(a) in dic: + dic[str(a)] += 1 + else: + dic[str(a)] = 1 + +res = 0 +for i, cnt in dic.items(): + ii = int(i) + if ii < cnt: + res += cnt - ii + elif ii > cnt: + res += cnt + +print(res) +" +p02583,s184981535,Wrong Answer,"N=int(input()) +count=0 +a=list(map(int,input().split())) +for i in range(N-2): + for j in range(i+1,N-1): + for k in range(j+1,N): + if a[i]!=a[j]&a[j]!=a[k]: + count+=1 +print(count)" +p03387,s619945917,Accepted,"x_list = [int(x) for x in input().split()] +temp_list = [[], []] +for i in range(3): + temp_list[x_list[i] % 2].append(i) +temp = len(temp_list[0]) +ans = 0 +if temp == 1: + x_list[temp_list[1][0]] += 1 + x_list[temp_list[1][1]] += 1 + ans += 1 +elif temp == 2: + x_list[temp_list[0][0]] += 1 + x_list[temp_list[0][1]] += 1 + ans += 1 +x_max = max(x_list) +ans += sum([gap // 2 for gap in [x_max - x for x in x_list]]) +print(ans)" +p03282,s941792323,Wrong Answer,"s = str(input()) +n = int(input()) +for i in s: + if i != ""1"": + print(i) + break" +p02641,s898302717,Accepted,"X,N = [int(_n) for _n in input().split()] +P = [int(_n) for _n in input().split()] +res = 0 +for i in range(102): + if i in P: + continue + if abs(X - i) < abs(X - res): + res = i +print(res)" +p02779,s095237083,Wrong Answer,"def solve(): + N = int(input()) + array = list(map(int, input().split())) + if array == list(set(array)): + print(""YES"") + else: + print(""NO"") + +solve()" +p04030,s256493951,Accepted,"S=str(input()) +T='' +for i in range(len(S)): + if S[i]=='0' or S[i]=='1': + T+=S[i] + else: + T=T[:-1] +print(T)" +p02642,s128827225,Wrong Answer,"x = int(input()) +y = list(map(int, input().split())) + +y.sort() +ans = [] +while len(y) != 0: + judge = y.pop(0) + remove = [] + if len(y) == 0: + ans.append(judge) + break; + if judge != y[0]: + ans.append(judge) + for i in y: + if i % judge == 0: + remove.append(i) + y = list(set(y) - set(remove)) + +print(len(ans)) +" +p03407,s412706087,Accepted,"ABC = input() +ABC = list(ABC.split()) + +A = int(ABC[0]) +B = int(ABC[1]) +C = int(ABC[2]) + +if A+B >= C: + print('Yes') +else: + print(""No"")" +p02621,s414138878,Accepted,"N=int(input()) +print(N+N**2+N**3)" +p03220,s017389814,Accepted,"def ii():return int(input()) +def iim():return map(int,input().split()) +def iil():return list(map(int,input().split())) +def ism():return map(str,input().split()) +def isl():return list(map(str,input().split())) + +n = ii() +t,a = iim() +H = iil() +mdif = 10**9 +ans = 0 +for i,item in enumerate(H): + tem = t - item*0.006 + if abs(tem - a) < mdif: + ans = i+1 + mdif = abs(tem - a) +print(ans)" +p02772,s309161879,Accepted,"N=int(input()) +A = list(map(int,input().split())) +str=""APPROVED"" + +for item in A: + if item%2==0: + if item%3!=0 and item%5 !=0: + str = ""DENIED"" + +print(str)" +p02797,s300208557,Wrong Answer,"n,k,s = map(int,input().split()) + +ans=[] + +cnt=n-k +for i in range(cnt): + ans.append(s) + +for j in range(n-k): + if s==1: + ans.append(2) + elif s==10**9: + ans.append((10**9)-1) + else: + ans.append(s+1) + + +print(*ans)" +p03487,s612985437,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int, input().split())) +counter = Counter(a) +result = 0 +for num, c in counter.items(): + if c > num: + result += c - num + elif c < num: + result += c +print(result)" +p02663,s521531007,Accepted,"import math + +H1,M1,H2,M2,K=map(int,input().split()) +T=(H2*60+M2)-(H1*60+M1) +if T-K<=0: + T=0 +else: + T=T-K +print(T)" +p02748,s518248794,Accepted,"a, b, m = map(int, input().split()) +a_list = list(map(int, input().split())) +b_list = list(map(int, input().split())) +min_cost = min(a_list) + min(b_list) + +for _ in range(m): + x, y, c = map(int, input().split()) + _a = a_list[x-1] + _b = b_list[y-1] + cost = _a + _b - c + min_cost = min(cost, min_cost) +print(min_cost) + +" +p03469,s670754691,Wrong Answer,"s=input() +print(s[:2]+'8'+s[4:]) +" +p03860,s201578638,Accepted,"s = input() + +ss = s.split() + +print(ss[0][0]+ss[1][0]+ss[2][0])" +p02584,s575951007,Wrong Answer,"x,k,d=map(int,input().split()) +while k!=0: + if x-d==0: + if k%2 ==0: + break + else: + x=x-d + break + if x-d < 0 : + if abs(x-d)min(A, B): + break + if A%p==0 and B%p==0: + ans+=1 +print(ans)" +p03241,s855769287,Wrong Answer,"from math import sqrt,floor +N,M =map(int,input().split()) +ans = 1 +for g in range(1,floor(sqrt(M))+1): + if M%g == 0: + x = M//g + if x > floor(sqrt(M)) and g >= N: + ans = x + if x >= N: + ans = g +print(ans)" +p02951,s732961295,Wrong Answer,"A, B, C = map(int,input().split()) +print(C-(A-B))" +p03994,s783310091,Accepted,"S = list(input()) +N = int(input()) + +''' +ordの位置 +#z = 122 +#a = 97 +左の文字からNで'a'に出来るかを確認 +aに出来るならaにして使った分をNから引く +繰り返して行き一番最後にあまりをすべて使う +''' + +for i, s in enumerate(S): + if ord(s) - 97 > 0 and 122 - ord(s) < N: + S[i] = ""a"" + N -= 123 - ord(s) +else: + S[i] = chr(N % 26 + ord(S[i])) # ここのWAは反省する + +print("""".join(S))" +p03281,s148530116,Accepted,"N = int(input()) +if N < 105: + print(0) +elif 105 <= N < 135: + print(1) +elif 135 <= N < 165: + print(2) +elif 165 <= N < 189: + print(3) +elif 189 <= N < 195: + print(4) +else: + print(5) +" +p02601,s555290988,Accepted,"a, b, c = map(int, input().split()) +k = int(input()) + +if b > a: + multiplier = 2 ** k + if c * multiplier > b: + ans = 'Yes' + else: + ans = 'No' +else: + while b <= a: + b *= 2 + k -= 1 + multiplier = 2 ** k + if c * multiplier > b: + ans = 'Yes' + else: + ans = 'No' + +print(ans) +" +p02888,s009099165,Accepted,"# D - Triangles + +from bisect import bisect_left + +N = int(input()) +L = sorted([int(l) for l in input().split()]) + +cnt = 0 +for i in range(N): + for j in range(i + 1, N): + cnt += bisect_left(L, L[i] + L[j]) - (j + 1) + +print(cnt) +" +p03767,s085393229,Wrong Answer,"#!/usr/bin/env python3 +import sys +# input = sys.stdin.r/eadline +def INT(): return int(input()) +def MAP(): return map(int,input().split()) +def LI(): return list(map(int,input().split())) + +def main(): + N = INT() + A = LI() + A.sort() + + print(sum(A[N:2*N])) + +if __name__ == '__main__': + main() +" +p02756,s265537191,Accepted,"from collections import deque +S = deque(input()) +N = int(input()) +is_inversed = False +for i in range(N): + Q = input() + if Q[0] == '1': + is_inversed = not (is_inversed) + else: + if (Q[2] == '1' and is_inversed) or (Q[2] == '2' and not (is_inversed)): + S.append(Q[4]) + else: + S.appendleft(Q[4]) +if is_inversed: + print(''.join(list(S)[::-1])) +else: + print(''.join(S))" +p03274,s682385297,Accepted,"#coding: utf-8 +import math +import heapq +import bisect +import numpy as np +from collections import Counter +#from scipy.misc import comb + +N,K = map(int, input().split()) + +# 複数個の数値を、intの配列として取得 +X = list(map(int, input().split())) + +ans = 10**18 +for i in range(N-K+1): + if X[i]*X[i+K-1] >= 0: + ans = min(ans,max(abs(X[i]),abs(X[i+K-1]))) + else: + ans = min(ans, 2*abs(X[i])+abs(X[i+K-1]), abs(X[i])+2*abs(X[i+K-1])) + +print(ans)" +p03639,s342779572,Accepted,"n = int(input()) +an = list(map(int, input().split())) +classify = [0 for i in range(3)] +#4の倍数、2の倍数、奇数 +for i in range(len(an)): + if an[i] % 4 == 0: + classify[0] += 1 + elif an[i] % 2 == 0: + classify[1] += 1 + else: + classify[2] += 1 +if classify[1]==0: + if(classify[0]+1) < classify[2]: + print(""No"") + else: + print(""Yes"") + +elif (classify[0]) < classify[2]: + print(""No"") +else: + print(""Yes"")" +p03469,s709288383,Accepted,"s = input() +print(s[:3]+""8""+s[4:])" +p03994,s062440118,Accepted,"s=list(map(ord,list(input()))) +k=int(input()) + +for i in range(len(s)): + s[i]-=97 + +c=0 +while k>0: + if c==len(s)-1: + s[c]=(s[c]+k)%26 + k=0 + elif s[c]==0: + c+=1 + elif s[c]+k>=26: + k-=26-s[c] + s[c]=0 + c+=1 + else: + c+=1 + +seq="""" +for i in range(len(s)): + seq+=chr(s[i]+97) + +print(seq) + " +p03785,s759662182,Accepted,"N,C,K = map(int,input().split()) + +T = sorted([int(input()) for _ in range(N)]) +ans = 1 +count = 0 +time = 0 +start = -1 +for i in range(N): + if start == -1: + start = i + if i != N-1: + if T[i+1] > T[start] + K or i+1 -start == C: + ans += 1 + start = -1 + +print(ans)" +p02862,s167097617,Accepted,"X,Y=map(int,input().split()) +if 2*Y1: + ans[-1] = chr(ord(ans[0-1]) +1) +print(''.join(ans))" +p03479,s205397672,Accepted,"X , Y = map(int,input().split()) +cnt = 0 +while True: + if X <= Y: + cnt+=1 + X *= 2 + else: + break +print(cnt)" +p03827,s983056187,Accepted,"n=int(input()) +s=str(input()) +ans=0 +m=0 +for i in range(n): + if s[i]==""I"": + ans+=1 + m=max(m,ans) + else: + ans-=1 + +print(m) +" +p03161,s705866993,Accepted,"def hoge(): + dp = [0] * (n + 5) + for i in range(1, n): + p = [dp[j] + abs(h_list[i] - h_list[j]) for j in range(max(0, i - k), i)] + dp[i] = min(p) + return dp[n - 1] + +def solve(): + global n, k, h_list + n, k = map(int, input().split()) + h_list = list(map(int, input().split())) + ans = hoge() + print(ans) + return 0 + +if __name__ == ""__main__"": + solve()" +p03069,s786624587,Accepted,"import itertools +n = int(input()) +s = [i for i in input()] +cnt_s, cnt_d = [0]*(n+1), [0]*(n+1) +for i in range(n): + if s[i] == ""#"": + cnt_s[i+1] = 1 + else: + cnt_d[i+1] = 1 +cnt_s, cnt_d = list(itertools.accumulate(cnt_s)), list(itertools.accumulate(cnt_d)) +ans = 10**6 +cnt_d_l = cnt_d[-1] +for i in range(n+1): + ans = min(ans, cnt_s[i] - cnt_s[0] + (cnt_d_l - cnt_d[i])) +print(ans)" +p03544,s701202878,Wrong Answer,"#k = int(input()) +#s = input() +#a, b = map(int, input().split()) +#s, t = map(str, input().split()) +#l = list(map(int, input().split())) +#l = [list(map(int,input().split())) for i in range(n)] +#a = [list(input()) for _ in range(n)] +#a = [int(input()) for _ in range(n)] + + +n = int(input()) + +if (n == 1): + print(1) +else: + l1 = 1 + l2 = 3 + ans = 0 + for i in range(n-2): + ans = l2 + l1 + l1 = l2 + l2 = ans + print(ans) + + +" +p03427,s785671934,Wrong Answer,"n = input(); a = 0; b = 0; c = 0 +for i in range(len(n)): + if n[i] != ""9"": + if a == 0: a += 1; b = i; c = int(n[i]) + else: a += 1 +if a == 0: print(9*len(n)) +elif a == 1 and b == 0: print(c+9*(len(n)-1)) +else: print(9*len(n)-1)" +p03293,s586464569,Accepted,"#template +def inputlist(): return [int(k) for k in input().split()] +#template +S = list(input()) +T = list(input()) +for i in range(len(S)): + Sa = S[:] + S = [Sa[-1]] + Sa[:-1] + if S == T: + print(""Yes"") + exit() +print(""No"")" +p03471,s255919943,Accepted,"N, Y = map(int, input().split()) + +for a in range(Y // 10000 + 1): + for b in range((Y - 10000 * a) // 5000 + 1): + if a + b + (Y - 10000 * a - 5000 * b) // 1000 == N: + print(a, b, N - a - b) + exit() +print(-1, -1, -1) +" +p03592,s676506279,Accepted,"import sys +n,m,k=map(int,input().split()) +for i in range(n+1): + for j in range(m+1): + if (i*j)+(n-i)*(m-j)==k: + print('Yes') + sys.exit() +print('No') +" +p03107,s080485684,Accepted,"s=input() +print(min(s.count('1'),s.count('0'))*2)" +p02831,s583050544,Wrong Answer,"A, B = list(map(int, input().split())) + +large = A if A > B else B +small = A if A < B else B + +multi = small + +r = large % small +while r != 0: + multi = r + r = small % r + +print(large*small//multi) +" +p02612,s010934231,Accepted,"n=int(input()) +if n%1000==0: + print(0) +else: + print(1000-(n%1000))" +p02684,s621304751,Accepted,"N, K = map(int, input().split()) +A = list(map(int, input().split())) +passlist = [0]*N +point = 1 +depth = 0 +waylist = [] +while passlist[point-1] == 0: + waylist.append(point) + passlist[point-1] = depth + point = A[point-1] + depth+=1 +roop = waylist[waylist.index(point):len(waylist)] +firstreach = passlist[roop[0]-1] +if K < firstreach: + print(passlist.index(K)+1) +else: + print(roop[(K-firstreach)%len(roop)])" +p02952,s254117879,Accepted,"n = int(input()) + +count = 0 +for i in range(1, n + 1): + keta = len(str(i)) + if keta % 2 == 1: count += 1 + +print(count)" +p03035,s844707241,Accepted,"a, b = map(int, input().split()) +if a <= 5: + print(0) +elif a <= 12: + print(b//2) +else: print(b)" +p02996,s451503789,Accepted,"from operator import itemgetter +import sys +input = sys.stdin.readline + +n = int(input()) +time = [] +flag = True +now = 0 + +for i in range(n): + a, b = map(int, input().split()) + time.append([a, b]) + +time = sorted(time, key = lambda x: x[1]) + +for i in range(n): + now += time[i][0] + if now <= time[i][1]: + pass + else: + flag = False + +if flag: + print(""Yes"") +else: + print(""No"") +" +p03206,s396874835,Accepted,"D=int(input()) +if D==22: + print(""Christmas Eve Eve Eve"") +elif D==23: + print(""Christmas Eve Eve"") +elif D==24: + print(""Christmas Eve"") +elif D==25: + print(""Christmas"")" +p03416,s443690145,Accepted,"A,B=map(int,input().split()) +cnt=0 +def is_pal(s): + s_str=str(s) + s_rev=str() + for i in range(1,len(str(s))+1): + s_rev+=s_str[-i] + + if s_str==s_rev: + return True + else: + return False +for i in range(A,B+1): + if is_pal(i): + cnt+=1 +print(cnt) + " +p02755,s382177371,Accepted,"import math + +a, b = (int(x) for x in input().split()) +ans = 0 +i = 0 +ok = False + +while i < 10000 : + case_a = math.floor(i * 0.08) + # print(case_a) + case_b = math.floor(i * 0.10) + # print(case_b) + + if case_a == a and case_b == b : + + ans = i + ok = True + break + + i = i + 1 + +if ok == False : + ans = -1 + +print(ans)" +p03038,s781014637,Wrong Answer,"n,m=map(int,input().split()) +a=sorted(map(int,input().split())) +c={} +for _ in range(m): + bx, cx =map(int,input().split()) + c[cx]=bx +c_sort=sorted(c.keys(),reverse=1) + +c_list=[] +for j in c_sort: + for _ in range(c[j]): + if len(c_list)>=n: + break + c_list.append(j) + +c_len=len(c_list) +sum=0 +for i in range(n): + if i+1<=c_len: + sum+=max(a[i],c_list[i]) + else: + sum+=a[i] +print(sum) +" +p03042,s704238451,Wrong Answer,"S = int(input()) + +A = S//100 +B = S%100 + +if A >= 13: + if B >= 13: + print('NA') + elif B <13: + if B != 0: + print('YYMM') + else: + print('NA') +elif A < 13: + if B >= 13: + if A != 0: + print('MMYY') + else: + print('NA') + elif B < 13: + print('AMBIGUOUS') +" +p03137,s343239622,Wrong Answer,"n, m = map(int, input().split()) +x = list(map(int, input().split())) +x.sort() + +ans = [] +for i in range(m-1): + ans.append(abs(x[i+1] - x[i])) +ans.sort() +print(sum(ans[:-n+1])) + " +p03814,s475692623,Accepted,"s = input() +start = 0 +end = 0 + +for x in s: + if x == 'A': + break + else: + start += 1 + +for x in reversed(s): + if x == 'Z': + break + else: + end += 1 + +print(len(s) - start - end) +" +p03449,s203046615,Accepted,"import itertools +import sys +import numpy as np +import collections + +n=int(input()) +a1 = list(map(int,input().split())) +a2 = list(map(int,input().split())) +ans =0 +for i in range(n): + can = a1[:i+1]+a2[i:] + ans=max(sum(can),ans) +print(ans) +" +p03160,s482528657,Accepted,"n = int(input()) +h = list(map(int,input().split())) +cost = [0]*n +cost[1] = abs(h[1]-h[0]) +for i in range(2,n): + cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]) , cost[i-2] + abs(h[i]-h[i-2])) +print(cost[n-1])" +p03817,s782158616,Accepted,"x = int(input()) + +num = x // 11 + +x %= 11 +if x == 0: + print(num * 2) +elif x <= 6: + print(num * 2 + 1) +else: + print(num * 2 + 2)" +p03719,s452304884,Wrong Answer,"a, b, c = input().split(' ') + +if c >= a and c <= b: + print ('Yes') +else: + print ('No')" +p02631,s510000073,Accepted,"import sys + +sys.setrecursionlimit(10**6) +input = sys.stdin.readline +#read = sys.stdin.buffer.read + +def main(): + N = int(input()) + A = list(map(int, input().split())) + base = 0 + for a in A: + base ^= a + ans = [] + for i in range(N): + ans.append(base^A[i]) + + print(*ans) + + +if __name__ == ""__main__"": + main() +" +p02699,s643363830,Accepted,"a,b=(int(i)for i in input().split()) +print(""unsafe"" if a<=b else ""safe"") +" +p02720,s520522485,Accepted,"from collections import deque +k = int(input()) +lunlun = deque([i for i in range(9, 0, -1)]) +for i in range(k): + x = lunlun.pop() + if i == k - 1: + print(x) + next_lunlun = 10*x + (x % 10) + if x % 10 != 0: + lunlun.appendleft(next_lunlun - 1) + lunlun.appendleft(next_lunlun) + if x % 10 != 9: + lunlun.appendleft(next_lunlun + 1)" +p03324,s687413522,Wrong Answer,"d, n = list(map(int,input().split())) +print((100**d)*n)" +p02835,s963467099,Accepted,"A=list(map(int,input().split())) +ans=0 +for i in A: + ans+=i +if ans>=22: + print(""bust"") +else: + print(""win"")" +p03433,s080637868,Accepted,"n=int(input()) +a=int(input()) + +if n%500<=a: + print(""Yes"") +else: + print(""No"")" +p02630,s191813996,Wrong Answer,"from collections import Counter +n = int(input()) +a = list(map(int, input().split())) +q = int(input()) +C = Counter(a) +s = sum(a) +for i in range(q): + b, c = map(int, input().split()) + print(s + (c - b) * C[b]) + s += (c - b) * C[b] + C[c] += C[b]" +p03427,s447014663,Accepted,"n = int(input()) +s = str(n) + +a = 0 +for i in range(len(s)): + a += int(s[i]) + +b = int(s[0])-1+(len(s)-1)*9 + +print(max(a, b)) +" +p03077,s075675706,Accepted,"import math +print(math.ceil(int(input())/min([int(input()) for _ in range(5)]))+4)" +p02899,s369314304,Wrong Answer,"N=int(input()) +A=sorted(list(map(int, input().split()))) +arr=[None]*N +for a in range(N): + arr[A[a]-1]=a+1 +print(arr) +" +p03659,s183137696,Accepted,"N = int(input()) +a = list(map(int, input().split())) +s = [0] * (N + 1) +for i in range(N): + s[i + 1] = s[i] + a[i] +ans = float('Inf') +for i in range(1, N): + #print(ans) + kouho = abs(s[i] - ((s[-1]) - s[i])) + if ans > kouho: + ans = kouho + #ans = min(ans, kouho) +print(ans) +" +p02817,s333777913,Accepted,"S,T = map(str,input().split()) +print(T+S)" +p02623,s941278589,Wrong Answer,"import bisect +N,M,K = map(int, input().split()) +A= list(map(int, input().split())) +B = list(map(int, input().split())) +for i in range(1,len(A)): + A[i]+=A[i-1] +for i in range(1,len(B)): + B[i]+=B[i-1] + +honn=bisect.bisect(B,K) +print(honn) +for i in range(len(A)): + s=K-A[i] + if s>=0: + + a=bisect.bisect(B,s) + #print(s) + if i+1+a>honn: + honn=i+1+a +print(honn)" +p02995,s256652835,Wrong Answer,"data = input().split() + +a = int(data[0]) +b = int(data[1]) +c = int(data[2]) +d = int(data[3]) + +multi = c * d + +count = 0 + +for i in range(a, b + 1): + if i % multi != 0: + count += 1 + +print(count) +" +p02571,s336416681,Accepted,"S = input() + +T = input() + +ans = float(""inf"") +for i in range(len(S) - len(T)+1): + tmp = 0 + for j in range(len(T)): + # print(S[i+j], T[j]) + if S[i+j] != T[j]: + tmp += 1 + ans = min(tmp, ans) +print(ans) +" +p03433,s949060837,Accepted,"N_en = int(input()) +A_mai = int(input()) + +mod = N_en - 500 * (N_en // 500) + +if (A_mai >= mod): + print('Yes') +else: + print('No') + " +p03457,s085827739,Wrong Answer,"n=int(input()) +txy=[list(map(int,input().split())) for _ in range(n)] +txy.insert(0,[0,0,0]) +for i in range(n): + d=abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2]) + if ((txy[i+1][0]-txy[i][0])-d)<0: + print(""No"") + exit() + elif d%2==0: + print(""No"") + exit() +print(""Yes"")" +p02618,s763722441,Wrong Answer,"import random +D = int(input()) +c = list(map(int, input().split())) +s = [list(map(int, input().split())) for i in range(D)] + +for i in range(D): + rand = random.randrange(0, 26) + print(rand)" +p03637,s829525057,Accepted,"N = int(input()) +a = list(map(int,input().split())) + +cnt2 = 0 +cnt4 = 0 +cntodd = 0 +for i in a: + if i % 4 == 0: + cnt4 += 1 + elif i % 2 == 0: + cnt2 += 1 + else: + cntodd += 1 + +if cnt2 == 0 and cnt4 + 1 >= cntodd: + ans = 'Yes' +elif cnt4 >= cntodd: + ans = 'Yes' +else: + ans = 'No' +print(ans) " +p02790,s950871727,Accepted,"import sys + +def solve(): + a, b = input().split() + D = [a * int(b), b * int(a)] + D.sort() + print(D[0]) + + return 0 + +if __name__ == ""__main__"": + solve()" +p02683,s633846530,Accepted,"INF = float(""inf"") + +n, m, x = map(int, input().split()) +c, a = [0] * n, [None] * n +for i in range(n): + c[i], *a[i] = map(int, input().split()) +ans = INF + +for bit in range(2 ** n): + s = [0] * m + cost = 0 + for i in range(n): + if bit >> i & 1: + cost += c[i] + for j in range(m): + s[j] += a[i][j] + if min(s) >= x: + ans = min(cost, ans) + +print(-1 if ans == INF else ans) +" +p03679,s890618614,Accepted,"x,a,b=map(int,input().split()) +if b<=a: + print(""delicious"") +elif a 1: + print(0) +elif N == M: + print((math.factorial(N)*math.factorial(M)*2)%mod) +else: + print((math.factorial(N)*math.factorial(M))%mod)" +p02675,s387433041,Accepted,"k = int(input()) + +if k%10 in [2,4,5,7,9]: + print('hon') + +elif k%10 in [0,1,6,8]: + print('pon') + +else: + print('bon') +" +p02642,s339402662,Accepted,"N = int(input()) +A = sorted(list(map(int, input().split()))) + +m_a = max(A)+1 +dp = [0]*m_a + +for i in A: + dp[i] += 1 + if dp[i]==1: + for j in range(i*2, m_a, i): + dp[j] += 2 + # print(dp) +print(dp.count(1))" +p02695,s973211186,Accepted,"n, m, q = map(int, input().split()) +check = [list(map(int, input().split())) for _ in range(q)] + + +def calc(r): + res = 0 + for a, b, c, d in check: + if r[b-1] - r[a-1] == c: + res += d + return res + + +def dfs(t): + if len(t) == n: + return calc(t) + + res = [dfs(t + [i]) for i in range(t[-1], m+1)] + + return max(res) + + +ans = [dfs([i]) for i in range(1, m+1)] + +print(max(ans)) + +" +p03485,s686869433,Accepted,"a,b = map(int,input().split()) + +print(-(-(a+b)//2)) +" +p03493,s438577943,Wrong Answer,"n = input() + +count = 0 +if(n[0]=='1'): + count+=1 +elif(n[1]=='1'): + count+=1 +elif(n[2]=='1'): + count+=1 + +print(count)" +p02772,s515206233,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +l = [i for i in a if i%2 == 0] +tmp = [i for i in a if i%2 == 0] + +while l: + e = l.pop() + if e % 2 == 0: + tmp.append(e) + +while tmp: + l.append(tmp.pop()) + +while tmp: + e = tmp.pop() + if e % 3 == 0: + l.append(e) + +while l: + tmp.append(l.pop()) + +while tmp: + e = tmp.pop() + if e % 5 == 0: + l.append(e) + +while l: + tmp.append(l.pop()) + + +if tmp != l: + print('APPROVED') +else: + print('DENIED')" +p03633,s116752060,Accepted,"import fractions +from functools import reduce +N = int(input()) +T = [int(input()) for _ in range(N)] + +def lcm(a,b): + return (a*b)//fractions.gcd(a,b) + +def lcm_list(lst): + return reduce(lcm,lst) + +print(lcm_list(T))" +p03623,s944251048,Accepted,"n=input().rstrip().split() +n=[int(x) for x in n] + +if abs(n[1]-n[0]) sum: + ans = sum + +print(ans) + +" +p02753,s800352503,Accepted,"str_ = input() +print('Yes') if 'A' in str_ and 'B' in str_ else print('No')" +p03457,s375945044,Accepted,"n = int(input()) +t,x,y = 0,0,0 +for i in range(n): + nt, nx, ny = map(int, input().split()) + if not(abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2): + print(""No"") + exit() + t,x,y = nt,nx,ny +print(""Yes"") + " +p02987,s294642090,Accepted,"S = input() + +temp2 = 0 +for i in ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"": + temp1 = S.count(i) + if temp1 == 2: + temp2 += 1 + +if temp2 == 2: + print(""Yes"") +else : + print(""No"")" +p03087,s411646842,Accepted,"n,q=map(int,input().split()) +s=input() + +lst=[0] +for i in range(1,n): + if s[i-1]==""A"" and s[i]==""C"": + lst.append(lst[i-1]+1) + else: + lst.append(lst[i-1]) + +for i in range(q): + l,r=map(int,input().split()) + print(lst[r-1]-lst[l-1])" +p02596,s946330578,Accepted,"k = int(input()) +seven = 7 +ans = -1 + +for i in range(1,k+1): + seven %= k + if seven == 0: + ans = i + break + else: + seven = seven * 10 + 7 + +print(ans)" +p03633,s110400940,Wrong Answer,"#!/usr/bin/env python3 + +N = int(input()) +# S = input() +# N, K = map(int, input().split()) +# A = list(map(int, input().split())) +mod = 10 ** 9 +from functools import reduce +from fractions import gcd + +def main(): + T = list(set([int(input()) for _ in range(N)])) + if len(T) == 1: + print(T[0]) + exit() + ans = (T[0] * T[1]) // gcd(T[0], T[1]) + for i in range(len(T) - 2): + ans = ans / (gcd(ans, T[i])) * T[i] + print(ans) + +if __name__ == ""__main__"": + main()" +p03042,s459536548,Wrong Answer,"a = input() +frm = int(a[:2]) +lat = int(a[2:]) + + +if frm > 12 and lat > 12: + print('NA') +elif frm <= 12 and lat > 12: + if 0 12 and lat <= 12: + if lat > 0: + print('YYMM') + else: + print('NA') +elif frm <= 12 and lat==0: + print('MMYY') +elif frm == 0 and lat <= 12: + print('YYMM') +else: + print('AMBIGUOUS')" +p03105,s779727748,Accepted,"A,B,C = map(int,input().split()) + +max = B//A +if max>C: + print(C) +else: + print(max)" +p03745,s225542211,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +flag = [] + +for i in range(N-1): + if A[i]<=A[i+1]: + flag.append(1) + elif i>0 and A[i]==A[i+1]: + flag.append(flag[i-1]) + else: + flag.append(-1) + +ans = 1 +c = 1 +for i in range(N-2): + if flag[i]!=flag[i+1] and c!=0: + ans+=1 + c=0 + else: + c+=1 + +print(ans)" +p02996,s531254087,Accepted,"n=int(input()) +li=[] +for i in range(n): + a, b=map(int,input().split()) + li.append([a,b]) +li=sorted(li, key=lambda x: x[0]) +li=sorted(li, key=lambda x: x[1]) +cnt=0 +for i in range(n): + cnt+=li[i][0] + if cnt>li[i][1]: + print(""No"") + exit() +print(""Yes"")" +p03456,s034503563,Wrong Answer,"import numpy as np + +a, b = map(str, input().split()) +c = int(a+b) +d=np.sqrt(c) +if d.is_integer(): + print(""YES"") +else: + print(""NO"") +" +p03779,s253495611,Wrong Answer,"x= int(input()) + + +cnt=1 +iterate=2 +while cnt0 else 0)" +p03565,s726227588,Accepted,"S = input() +T = input() +ss = list() +for n in range(len(S)-len(T)+1): + for m in range(len(T)): + if S[n+m] not in [""?"", T[m]]: + break + else: + ss.append((S[:n]+T+S[n+len(T):]).replace(""?"",""a"")) +if len(ss) == 0: + print(""UNRESTORABLE"") +else: + print(min(ss)) + +" +p02570,s534104447,Wrong Answer,"d, t, s = map(int, input().split()) +time = d // s +if time <= t: + print('Yes') +else: + print('No')" +p02597,s801886983,Wrong Answer,"import sys +import math +import itertools +import collections +import heapq +import re +import numpy as np +from functools import reduce + +rr = lambda: sys.stdin.readline().rstrip() +rs = lambda: sys.stdin.readline().split() +ri = lambda: int(sys.stdin.readline()) +rm = lambda: map(int, sys.stdin.readline().split()) +rl = lambda: list(map(int, sys.stdin.readline().split())) +inf = float('inf') +mod = 10**9 + 7 + +n = ri() +s = rr() +print(s[n//2].count('W'))" +p02743,s073225894,Accepted,"a,b,c = list(map(int, (input().split()))) + +left = 4 * a * b +right = (c-a-b) ** 2 + +if c-a-b < 0: + print(""No"") +elif left < right: + print(""Yes"") +else: + print(""No"") +" +p02767,s472291532,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = sum(A) +x = round(S/N) +ans = 0 +for i in range(N): + ans += (A[i] - x)**2 +print(ans) + +" +p03013,s751202710,Accepted,"n,m=map(int,input().split()) +a=set(int(input()) for _ in range(m)) +dp=[0]*(n+2) +dp[0]=1 +for i in range(n): + if i in a: + continue + dp[i+1]+=dp[i] + dp[i+2]+=dp[i] +print(dp[n]%1000000007)" +p03836,s804846414,Accepted,"a, b, c, d = map(int, input().split()) +x = c - a +y = d - b +print(y*'U'+x*'R'+y*'D'+(x+1)*'L'+(y+1)*'U' + + (x+1)*'R'+""DR""+(y+1)*'D'+(x+1)*'L'+'U')" +p03095,s294700495,Accepted,"import sys +def input(): return sys.stdin.readline().strip() +def mapint(): return map(int, input().split()) +sys.setrecursionlimit(10**9) + +N = int(input()) +S = list(input()) +mod = 10**9+7 +from collections import Counter +c = Counter(S) +lis = [] +ans = 1 +for _, cnt in c.most_common(): + ans *= (cnt+1) + ans %= mod +print((ans-1)%mod)" +p04011,s833190453,Wrong Answer,"n, k, x, y = [int(input()) for _ in range(4)] +if n >= k: + print(x*k + y*(n-k)) +else: + print(x*k)" +p02933,s366170864,Accepted,"a=float(input()) +s=input() +s1=list(s) +length=len(s1) +for x in s1: + if ord(x)<97 or ord(x)>122: + s1.remove(x) +length2=len(s1) +if length==length2 and 1<=length<=10 and 2800<=a<5000: + if a<3200: + print('red') + else: + print(s)" +p03605,s511746682,Wrong Answer,"s = input() +if s[0] == 9 or s[1] == 9: + print('Yes') +else: + print('No')" +p02819,s449178691,Accepted,"X = int(input()) + +if X == 2 or X == 3 or X == 5: + print(X) +else: + find = True + ans = X + 1 if X % 2 == 0 else X + while True: + for i in range(3, int(ans**0.5)+1, 2): + if ans % i == 0: + ans += 2 + find = False + break + if find: + break + find = True + print(ans)" +p03799,s811837785,Wrong Answer,"n,m = tuple(map(int,input().split())) + +if n-m*2<=0: + rest = m-n*2 + print(n+rest//4) +else: + print(m//2) + " +p02691,s034918812,Accepted,"n = int(input()) +A = [int(x) for x in input().split()] + +B = {} +for i, a in enumerate(A): + aa1 = i + 1 - a + if aa1 > 0: + if aa1 not in B: + B[aa1] = [] + B[aa1].append((i + 1, a)) + +count = 0 +for i, a in enumerate(A): + aa1 = i + 1 + a + if aa1 in B: + count += len(B[aa1]) +print(count) +" +p03284,s630393001,Wrong Answer,"n, k = map(int, input().split()) + +print(n-(n//k)*k) +" +p03605,s496501515,Accepted,"n = input() +ans = 0 +for i in n: + if i=='9': + ans += 1 +if ans > 0: + print(""Yes"") +else: + print(""No"")" +p02754,s367252086,Accepted,"n,a,b = map(int,input().split()) +su = 0 +blue = 0 + +mo = n%(a+b) +mu = int(n/(a+b)) + +if mo > a: + ma = mo-a + blue = n-ma-b*mu +elif mo <= a: + blue = n- b*mu + +print(str(blue))" +p02785,s403870197,Wrong Answer,"def main(): + n, k = map(int, input().split()) + inlis = list(map(int, input().split())) + inlis.sort() + + if k >= n: + print(0) + total = sum(inlis[:-k]) + print(total) + + +if __name__ == ""__main__"": + main() +" +p03293,s927099854,Accepted,"import sys +s = list(input()) +t = list(input()) +for i in range(len(s)): + if t == s[i:] + s[:i]: + print(""Yes"") + sys.exit() +print(""No"")" +p03698,s938154096,Wrong Answer,"a= input().strip() +b=set(a) +if len(a)==len(b): + print(""yes"") +else: + print(""no"") +print(len(a),len(b))" +p02697,s000013591,Wrong Answer,"N, M=map(int, input().split()) + +if M*2<=N: + for i in range(1, M+1): + print(i, N-i+1) +else: + for i in range(1, N//2): + print(i, N-i)" +p02836,s574477105,Accepted,"s=input() +cnt=0 +for i in range(len(s)//2): + if s[i]!=s[-(i+1)]: + cnt+=1 +print(cnt) +" +p02546,s347805442,Accepted,"str = input() +if str[-1] == ""s"": + print(str + ""es"") +else: + print(str + ""s"") +" +p03817,s629055484,Accepted,"X = int(input()) +res = X//11*2 +X %= 11 +res += X//6 +X %= 6 +if X: + res += 1 + +print(res)" +p02657,s521211970,Accepted,"a, b = map(int, input().split()) +print(a * b) +" +p02701,s325282637,Accepted,"# -*- coding: utf-8 -*- +import sys +sys.setrecursionlimit(10**9) +INF=10**18 +MOD=10**9+7 +input=lambda: sys.stdin.readline().rstrip() +YesNo=lambda b: bool([print('Yes')] if b else print('No')) +YESNO=lambda b: bool([print('YES')] if b else print('NO')) +int1=lambda x:int(x)-1 + +def main(): + N=int(input()) + S=[input() for i in range(N)] + s=set(S) + print(len(s)) + +if __name__ == '__main__': + main() +" +p02838,s938764803,Wrong Answer,"import numpy as np +N = int(input()) +A = np.array(list(map(int, input().split()))) +K = 60 + +bit_nums = [0 for _ in range(K)] +ans = 0 +mod = 10 ** 9 + 7 + +for i in range(K): + bit_nums[i] = np.sum([A >> i & 1]) + +ans = 0 +for i in range(K): + ans += (2 ** i) * (bit_nums[i] * (N - bit_nums[i])) + ans %= mod + +print(ans)" +p03633,s742137420,Accepted,"import fractions + +n = int(input()) +t = [int(input()) for i in range(n)] +ans = t[0] +for i in range(1, n): + ans = ans * t[i] // fractions.gcd(ans, t[i]) + +print(ans)" +p02577,s411861113,Accepted,"n=input() +s=0 +for i in range(len(n)): + s+=int(n[i]) + s=s%9 +if s==0: + print(""Yes"") +else: + print(""No"")" +p03693,s730837727,Accepted,"a, b, c = map(int, input().replace("" "", """")) +N = int(100*a+10*b+c) +print(""YES"" if N%4==0 else ""NO"")" +p03017,s538624826,Accepted,"n, a, b, c, d = map(int, input().split()) +s = input() +if '##' in s[a:max(c, d)] or (d < c and '...' not in s[b-2:d+1]): + print('No') +else: + print('Yes')" +p02594,s196260189,Accepted,"x = int(input()) + +if x >=30: + print(""Yes"") +else: + print(""No"") + " +p03417,s397263869,Accepted,"def main(): + N, M = map(int, input().split()) + if N > M: + N, M = M, N + + if M == 1: + print(1) + elif N == 1: + print(M-2) + elif N == 2: + print(0) + else: + print((N-2) * (M-2)) + + +if __name__ == '__main__': + main() +" +p03073,s798926007,Accepted,"S=list(input()) +t=S[0] +count=0 +for i in range(1,len(S)): + if t==S[i]: + S[i]=str(1-int(S[i])) + count+=1 + t=S[i] + +print(count)" +p03612,s097178500,Accepted,"N=int(input()) +P=list(map(int,input().split())) +count=0 +flag=0 +for i in range(N): + if flag: + flag=0 + continue + if P[i]==i+1: + count+=1 + if i!=N-1: + if P[i+1]==i+2: + flag=1 +print(count) +" +p02773,s202670820,Accepted,"import sys +N = int(input()) +S = (str(x) for x in sys.stdin.read().split()) +cnt = {} +for s in S: + if cnt.get(s): + cnt[s] = cnt[s] + 1 + else: + cnt[s] = 1 +max_cnt = max(cnt.values()) +keys = [k for k, v in cnt.items() if v == max_cnt] +for k in sorted(keys): + print(k)" +p03250,s975079302,Accepted,"lists = sorted(list(map(int, input().split()))) + +print(10*lists[2] + lists[0] + lists[1])" +p02730,s048244935,Wrong Answer,"s = input() + +def is_kaibun(st): + return st[:len(st) // 2] == st[-(len(st) // 2):][::-1] + +if is_kaibun(s) and is_kaibun(s[:len(s) // 2]) and is_kaibun(s[-(len(s) // 2):][::-1]): + print('Yes') +else: + print('No') +" +p02594,s981910760,Accepted,"X = int(input()) +if X >= 30: + print(""Yes"") +else: + print(""No"")" +p02779,s792171309,Accepted,"n,*a=map(int,open(0).read().split()) +if len(a)==len(set(a)): + print(""YES"") +else: + print(""NO"")" +p02847,s359227275,Wrong Answer,"s=input() +if s == 'SUN': + print('7') +elif s == 'MON': + print('6') +elif s == 'TUE': + print('5') +elif s == 'WED': + print('4') +elif s == 'THU': + print('3') +elif s == 'FRY': + print('2') +else: + print('1') " +p03456,s184206213,Accepted,"import math + +a,b=map(str,input().split()) +c=int(a+b) +print('Yes' if (math.sqrt(c)//1)**2==c else 'No') +" +p02642,s851553702,Accepted,"import numpy as np +n = int(input()) +a = np.sort(np.array(list(map(int, input().split())))) +max_num = a[-1]+1 +dp = np.array([0]*(max_num)) + +if np.count_nonzero(a==1) == 1: + print(1) +else: + for i in a: + for j in np.arange(i, max_num, i): + dp[j] += 1 + print(np.count_nonzero(dp[a] == 1))" +p03543,s582797011,Wrong Answer,"x = input() +print(""Yes"" if x[0] == x[1] == x[2] or x[1] == x[2] == x[3] or int(x)%11 == 0 else ""No"")" +p03475,s714781753,Accepted,"n=int(input()) +time = [0]*n +for i in range(n-1): + c,s,f = map(int,input().split()) + for j in range(i+1): + time[j] = max(s,-(-time[j]//f)*f) + c + +print(""\n"".join(str(t) for t in time))" +p03637,s061027387,Accepted,"N = int(input()) +a = list(map(int, input().split())) +count = 0 +hcount = 0 +for x in a: + if x % 4 == 0: + count += 1 + elif x % 2 == 0: + hcount += 1 + +if (count + (hcount // 2)) >= (N // 2): + print('Yes') +else: + print('No') +" +p04030,s640568838,Wrong Answer,"str_list=[] +tmp=[] +s='' +str_list=list(input()) +for i in str_list: + if i =='0': + tmp.append('0') + elif i == '1': + tmp.append('1') + elif i == 'B' and tmp: + tmp.pop() +for i in range(len(tmp)): + s+=tmp[i] +print(tmp) +print(s) +" +p02946,s200009705,Accepted,"k, x = map(int, input().split()) + +l = k*2 -1 + +m = x - k + 1 + +for i in range(l): + print(i+m, end = "" "") +" +p03456,s556368065,Accepted,"a,b=map(int,input().split()) + +for i in range(int(str(a)+str(b))): + if (i+1)**2==int(str(a)+str(b)): + print(""Yes"") + break +else: + print(""No"")" +p03037,s289953055,Accepted,"N, M = map(int, input().split()) +LR = [list(map(int, input().split())) for _ in range(M)] + +L_max = 0 +R_min = N +for L, R in LR: + L_max = max(L_max, L) + R_min = min(R_min, R) + +ans = 0 +if L_max <= R_min: + ans = R_min - L_max + 1 + +print(ans)" +p02843,s557831361,Accepted,"x = int(input()) +for i in range(1000): + if 100*i <= x <= 105*i: + print(1) + exit() +print(0)" +p02665,s178728432,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +if N == 0 and A[0] == 1: + print(1) + exit(0) +elif A[0] > 0: + print(-1) + exit(0) + +X = [0] * (N+1) +X[-1] = A[-1] +for i in range(N,0,-1): + X[i-1] = X[i] + A[i-1] + +#print(X) + +wk = 2 +ans = 1 +for i in range(1,N+1): + + #print(i,X[i]) + if 0 <= A[i] <= wk: + ans += min(wk,X[i]) + wk -= A[i] + wk *= 2 + else: + print(-1) + exit(0) + +print(ans)" +p04012,s124829305,Accepted,"from collections import Counter + +l=[x for x in input()];n=len(set(l)); +c=Counter(l) +ans=[x for x in c.values() if x%2!=0] +print (""No"" if len(ans)>0 else ""Yes"")" +p02615,s679495433,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +a.sort(reverse=True) +b = [a[0]] +for i in range(1, n): + b.append(a[i]) + b.append(a[i]) +print(sum(b[:n - 1])) +" +p03043,s798593674,Accepted,"n,k = map(int,input().split()) +ans = 0 +for i in range(1, n+1): + tmp = i + cnt = 0 + while tmp < k: + tmp *= 2 + cnt += 1 + ans += 1/n/2**cnt +print(ans)" +p02767,s619771932,Accepted,"n = int(input()) +x = list(map(int,input().split())) +ans = 10**15 + +for i in range(1,101): + r = 0 + for j in range(n): + r += (x[j]-i)**2 + ans = min(ans,r) + +print(ans)" +p03472,s342986994,Accepted,"N,H=map(int,input().split()) +A=[list(map(int,input().split())) for i in range(N)] +B=[] +C=[] +for a,b in A: + B.append(a) + C.append(b) +D=sorted(B)[::-1] +b=D[0] +F=[] +for i in C: + if b=2: + ans+=9 +print(ans)" +p02690,s862987075,Wrong Answer,"def main(): + X = int(input()) # 文字列または整数(一変数) + + for B in range(0, 1000): + for A in range(B, 1000): + if A**5 - B**5 == X: + print(A, B, sep="" "") + return + if A**5 + B**5 == X: + print(A, B, sep="" "") + return + +if __name__ == '__main__': + main() + +" +p04011,s883794519,Accepted,"N,K,X,Y= [int(input()) for i in range (4)] +if N > K: + yen1 = K * X + yen2 = (N - K) * Y + print(yen1 + yen2) +else: + print(N * X)" +p03557,s226036500,Wrong Answer,"import bisect +n = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) + +ans = 0 +for b in B: + a_ind = bisect.bisect(A, b) + + if A[a_ind-1] == b: + a_ind -=1 + c_ind = bisect.bisect(C, b) + + ans += a_ind*(n-c_ind) + +print(ans)" +p02554,s624908289,Wrong Answer,"n = int(input()) + +MOD = 10**9 + 7 + +allp = pow(10,n,MOD) +not09 = 2*pow(9,n,MOD) +closs = pow(8,n,MOD) + +print(allp - not09 + closs) +" +p03086,s793655414,Accepted,"s=str(input()) +s=list(s) +l=len(s) +ans=0 +temp=0 +for i in range(0,l): + if s[i]==""A"" or s[i]==""C"" or s[i]==""G"" or s[i]==""T"": + temp=temp+1 + ans=max(ans,temp) + else: + temp=0 +print(ans) + +" +p03416,s105379368,Wrong Answer,"a, b = map(int, input().split()) +ans = 0 +for i in range(a, b): + i = str(i) + if i == i[::-1]: + ans += 1 +print(ans)" +p02576,s353545867,Wrong Answer,"n,x,t=map(int,input().split()) +s=n//x * t +if n%x!=0: + s+=1 +print(s)" +p02983,s722658376,Wrong Answer,"import math +L, R = map(int, input().split()) +l = L % 2019 +length = R - L +if l + length > 2019: + print(0) +elif length > 2017: + print(0) +else: + print((L * (L+1))%2019) +" +p02994,s442656409,Wrong Answer,"n, l = map(int, input().split()) +a = [l + i for i in range(n)] +if l + n - 2 < 0: + a.pop(n - 1) +elif l > 0: + a.pop(0) + print(a) +print(sum(a))" +p03385,s614030722,Accepted,"s = input() +if ''.join(sorted(s)) == 'abc': + print('Yes') +else: + print('No') +" +p04044,s685123652,Wrong Answer,"val = input() +splited_val = val.split() + +val_list=[] + +for x in range(int(splited_val[0])): + val = input() + val_list.append(val) + +print(sorted(val_list))" +p02729,s991790456,Accepted,"n,m = map(int,input().split()) +print(n*(n-1)//2 + m*(m-1)//2)" +p03327,s730422198,Accepted,"print(""ABC""if int(input())<=999 else ""ABD"")" +p02838,s629485724,Accepted,"n=int(input()) +a=list(map(int,input().split())) +mod=10**9+7 +ans=0 +k=1 +for i in range(61): + count0=0 + count1=0 + for j in a: + if not (j>>i & 1): + count0+=1 + if j>>i & 1: + count1+=1 + ans+=((count0*count1)*(k))%mod + k=(2*k)%mod + + +print(ans%mod)" +p02600,s497753256,Wrong Answer,"X = int(input()) +cnt = 1 + +a = X - 400 // 200 +for i in range(1,9): + if 7 <= a < 8: + print(cnt) + else: + cnt += 1 + a += 400" +p03095,s509463973,Wrong Answer,"N=int(input()) +S=input() + +from collections import defaultdict +d=defaultdict(int) +ans = 0 +for i,s in enumerate(S): + ans += 2 **(i-d[s]) + d[s] += 1 + #print(ans) +print(ans)" +p03565,s334001532,Accepted,"S_ = input() +T = input() + +if len(S_) < len(T): + print('UNRESTORABLE') + exit() + +i_ = -1 + +for i in range(len(S_)-len(T)+1): + for j in range(len(T)): + if S_[i+j] != T[j] and S_[i+j] != '?': + break + if j == len(T) - 1: + i_ = i + +if i_ == -1: + print('UNRESTORABLE') +else: + if i_ + len(T) == len(S_): + print(S_[:i_].replace('?','a')+T) + else: + print(S_[:i_].replace('?','a')+T+S_[i_+len(T):].replace('?','a'))" +p02778,s503399500,Accepted,"s = input() + +l = len(s) + +v = 'x'*l + +print(v)" +p03252,s620409478,Wrong Answer,"import sys + +S = input() +T = input() + +d = {} + +for i in range(len(S)): + if T[i] in d and d[T[i]]!=S[i]: + print(""NO"") + sys.exit() + d[T[i]] = S[i] +print(""YES"")" +p02572,s120669168,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +bs = 10**9 + 7 +s = sum(a) +sm = 0 + +for i, ai in enumerate(a): + s -= ai + sm += (ai * s) % bs + sm = sm % bs + +print(sm)" +p03632,s420294501,Accepted,"A, B, C, D = list(map(int, input().split())) +if A <= C: + x = [A, B] + y = [C, D] +else: + y = [A, B] + x = [C, D] +if x[1] <= y[1]: + d = x[1] - y[0] +else: + d = y[1] - y[0] +if d < 0: + d = 0 +print(d)" +p02854,s478105865,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +a_sum = sum(a) +x = 0 +y = 0 +for i in range(n): + x += a[i] + + if x * 2 >= a_sum: + y = a[i] + break + +ans = min(abs(2 * x - a_sum), abs(a_sum - 2 * (x - y))) +print(ans) +" +p02701,s400323401,Accepted,"n = int(input()) +s = set() +for i in range(n): + s.add(input()) +print(len(s)) +" +p02683,s638993084,Wrong Answer,"import numpy as np + +n, m, x = map(int, input().split(' ')) +a = np.zeros([n, m]) +c = np.zeros(n) + +for i in range(n): + v = list(map(int, input().split(' '))) + a[i, :] = np.array(v[1:]) + c[i] = v[0] + +INF = 10000000000000000 +ans = INF + +for i in range(1<= x): + ans = min(ans, cost) + +print(ans if ans != INF else -1) + " +p04011,s309058136,Accepted,"N = int(input()) +K = int(input()) +X = int(input()) +Y = int(input()) + +print(min(N, K)*X + max(N-K, 0)*Y)" +p02766,s963177032,Wrong Answer,"N,K=map(int,input().split()) +print(N//K+1)" +p03385,s588850591,Wrong Answer,"s=input() +s=set(s) + +if len(s)==3: + print('YES') +else: + print('NO')" +p02777,s783867603,Wrong Answer,"s,t=map(str,input().split()) +a,b=map(int,input().split()) +u=str(input) + +if u==s: + print((a-1),b) +else: + print(a,(b-1))" +p04030,s946328020,Wrong Answer,"s = input() +ans = '' +for i in range(len(s)-1): + if s[i] != 'B' and s[i+1] !='B': + ans += s[i] +if s[-1] != 'B': + ans += s[-1] + +print(ans)" +p02633,s056005235,Accepted,"X=int(input()) +ans=1 +while True: + if ans*X%360==0: + print(ans) + break + ans+=1" +p02659,s182115534,Wrong Answer,"from sys import stdin +A,B = [float(x) for x in stdin.readline().rstrip().split()] +print(int(A*B))" +p03612,s014464555,Accepted,"N = int(input()) +P = list(map(int, input().split())) + +cnt = 0 +skip = False +for i in range(N): + if skip: + skip = False + continue + if i+1 == P[i]: + cnt += 1 + if i+1 < N and i+2 == P[i+1]: + skip = True + +print(cnt) +" +p03107,s648672804,Accepted,"S = input() +z = 0 +o = 0 +for c in S: + if c == '0': + z += 1 + else: + o += 1 +print(min([z,o])*2)" +p02796,s822050757,Wrong Answer,"from operator import itemgetter +N = int(input()) +robot_list = [] + +for i in range(N): + robot_list.append(list(map(int, input().split()))) + robot_list[i] = (robot_list[i][0] - robot_list[i][1] + 1, robot_list[i][0] + robot_list[i][1] - 1, robot_list[i][0], robot_list[i][1]) + +sort_robot_list = sorted(robot_list, key=itemgetter(2)) + +minus_count = 0 +for before_value, after_value in zip(sort_robot_list, sort_robot_list[1:]): + if before_value[1] > after_value[0]: + minus_count += 1 + +print(len(sort_robot_list) - minus_count)" +p03243,s948204415,Wrong Answer,"import sys +N = int(input()) + +for i in range(1,9): + if N <= int(str(i)*3): + print(str(i)*3) + sys.exit()" +p02862,s965422834,Accepted,"X, Y = map(int, input().split()) +a = 2*Y-X +b = 2*X-Y + +def modinv(a, mod=10**9+7): + return pow(a, mod-2, mod) + +def combination(n, r, mod=10**9+7): + r = min(r, n-r) + res = 1 + for i in range(r): + res = res * (n - i) * modinv(i+1, mod) % mod + return res + +if a%3==0 and b%3==0 and a>=0 and b>=0: + a //= 3 + b //= 3 + print(combination(a+b, a)) +else: + print(0)" +p03131,s597670714,Wrong Answer,"k, a, b = map(int, input().split()) + +if k == 1: + print(2) +elif k < a + 2 or a >= b: + print(1 + k) +else: + cnt = (k - (a - 1)) // 2 + mod = (k - (a - 1)) % 2 + ans_1 = (b - a)*cnt + a + mod + ans_2 = 1 + k + print(int(max(ans_1, ans_2)))" +p02594,s956680231,Wrong Answer,"if int(input())>=30: + print(""YES"") +else: + print(""NO"") + " +p02612,s190201943,Accepted,"n=int(input()) +ans=(1000- n%1000)%1000 +print(ans)" +p03331,s122157315,Accepted,"N = int(input()) + +A = str(N//2) +B = str(N-int(A)) + +ans1,ans2 = 0,1 +for i in range(len(A)): + ans1 += int(A[i]) +for i in range(len(B)): + ans1 += int(B[i]) + +B = str(N-1) + +for i in range(len(B)): + ans2 += int(B[i]) + +ans = min(ans1,ans2) + +print(ans)" +p02546,s184613645,Accepted,"s = input().rstrip() + +if s[-1]=='s': + s += 'es' +else: + s += 's' + +print(s) +" +p02612,s094675261,Wrong Answer,print(int(input()) % 1000) +p02555,s571055886,Accepted,"s=int(input()) +dp=[0 for i in range(s+10)] +dp[3]=1 +mod=10**9+7 +for i in range(3,s+3): + dp[i]=1 + for j in range(i-2): dp[i]=(dp[i]+dp[j])%mod +print(dp[s])" +p02583,s968699810,Wrong Answer,"n = int(input()) +L = input().split() +L.sort() +count = 0 +for i in range(n): + for j in range(i + 1,n): + for k in range(j + 1 ,n): + + if ((int(L[k]) < int(L[i]) + int(L[j])) & (L[k] != L[i])& (L[k] != L[j])& (L[j] != L[i])): + count += 1 + +print(count)" +p03605,s776768196,Accepted,"N=input() +if '9' in N: + print('Yes') +else: + print('No') + " +p02706,s077576237,Wrong Answer,"a = list(map(int, input().split())) +b = list(map(int, input().split())) +if a[0] == sum(b): + print(-1) +else: + print(a[0] - sum(b))" +p03323,s674218424,Accepted,"a,b = map(int,input().split()) +if a > 8 or b > 8: print(':(') +else: print('Yay!')" +p03435,s036898246,Wrong Answer,"#!/usr/bin/env python3 +(*c, ) = map(int, open(0).read().split()) +print(""YNeos""[sum(c) % 3 > 0::2]) +" +p02761,s142084592,Wrong Answer,"#!/usr/bin/env python3 +import numpy as np + + +N, M = [int(str) for str in input().strip().split()] +sc = set([tuple([int(str) for str in input().strip().split()]) for _ in range(M)]) + +sc_dict = {} +for key, value in sc: + if key in sc_dict: + sc_dict[key] = min(value, sc_dict[key]) + else: + sc_dict[key] = value + +if N != 1 and sc_dict.get(1, 0) == 0: + print(-1) +else: + num = int(''.join([str(sc_dict.get(d + 1, 0)) for d in range(N)])) + print(num if len(str(num)) == N else -1)" +p03495,s765265072,Accepted,"import collections as c + +n,k = map(int,input().split()) +l = list(map(int,input().split())) +count = c.Counter(l) +ans = 0 +check = 0 +right = len(count)-k +if right <= 0: + print(0) + exit() +for i,j in count.most_common()[::-1]: + ans += j + check += 1 + if check == right: + print(ans) + exit()" +p02789,s493684862,Accepted,"from sys import stdin + +n,m = [int(x) for x in stdin.readline().rstrip().split()] + +if n == m: + print(""Yes"") +else: + print(""No"")" +p02917,s479052729,Accepted,"n=int(input()) +B = list(map(int,input().split())) +A= B[0] +for i in range(1,n-1): + A += min(B[i-1],B[i]) +A+= B[n-2] +print(A)" +p03379,s731677001,Accepted,"import math +n = int(input()) +x = list(map(int,input().split())) +sums = sum(x) +xsort = sorted(x,reverse=True) +temp = math.ceil((n-1)/2) +if n % 2 == 0: + medi = xsort[temp] +else: + medi = xsort[n//2] + +medi2 = xsort[temp-1] + +for i in range(n): + if x[i] <= medi: + print(medi2) + else: + print(medi)" +p02595,s891220953,Accepted,"c = 0 +N, D = list(map(float, input().split())) +for i in range(int(N)): + a, b = map(float, input().split()) + if a ** 2 + b ** 2 <= D**2: + c += 1 +print(c)" +p03475,s210977313,Wrong Answer,"N = int(input()) +ans = [] +for _ in range(N - 1): + C, S, F = map(int, input().split()) + ans.append(S + C) + for i in range(len(ans) - 1): + if ans[i] <= S: + ans[i] = S + C + else: + if (ans[i] - S) % F == 0: + ans[i] += C + else: + ans[i] += F * ((ans[i] - S) // F + 1) + C + +ans.append(0) +for a in ans: + print(a) +" +p03625,s717242751,Wrong Answer,"import collections +n = int(input()) +p = list((map(int,input().split()))) +x = collections.Counter(p) +y = [i[0] for i in x.items() if i[1]>=2] +z = [i[0] for i in x.items() if i[1]>=4] +y.sort(reverse=True) +y.append(0) +y.append(0) +z.append(0) +ans = y[0]*y[1] +ans1 = z[0]*z[0] +if ans1 > ans: + ans =ans1 +print(ans) +" +p02747,s511398937,Accepted,"s = input() + +if s=='hi' or s=='hihi' or s=='hihihi' or s=='hihihihi' or s=='hihihihihi': + print('Yes') +else: + print('No')" +p03075,s865147976,Accepted,"a = [int(input()) for i in range(5)] +k = int(input()) +print('Yay!' if a[-1] - a[0] <= k else ':(') +" +p02689,s985012640,Accepted,"N, M = [int(i) for i in input().split()] +H = [int(i) for i in input().split()] + +good = [True]*N + +for i in range(M): + a, b = [int(i)-1 for i in input().split()] + if H[a] >= H[b]: + good[b] = False + if H[b] >= H[a]: + good[a] = False + +print(sum(good))" +p02683,s366842654,Accepted,"n,m,x=map(int,input().split()) +cx=[list(map(int,input().split())) for i in range(n)] + +ans=10000000000000000000000000000 + +for dummy in range(2**n): + books=format(dummy, 'b') + books='0'*(n-len(books))+books + point=[0]*(m+1) + cost=0 + for i in range(n): + if books[i]=='1': + cost+=cx[i][0] + for j in range(1,m+1): + point[j]+=cx[i][j] + ok=1 + for j in range(1,m+1): + if point[j]=s: + ans=t + tmax=t + t=(tmin+t)/2 + else: + tmin=t + t=(t+tmax)/2 + if tmax-tmin<0.01: + break + print(math.ceil(ans))" +p02983,s547980918,Wrong Answer,"import sys +l,r = map(int,input().split()) +c = 10**9 +if r - l >= 2019: + print(0) + sys.exit() +for i in range(l,r): + for j in range(i+1,r+1): + print(i,j) + x = (i * j) % 2019 + print(x) + if x < c: + c = x + +print(c)" +p03327,s840221737,Wrong Answer,"N=int(input()) + +if N<=999: + print(""ABC""+str(N)) +else: + print(""ABR""+str(N-1000+1)) + + +" +p03827,s207661825,Accepted,"N = int(input()) +S = input() +x = 0 +max_x = 0 +for i in range(N): + if S[i]==""D"": + x -= 1 + else: + x += 1 + if x > max_x: + max_x = x +print(max_x)" +p03998,s574087071,Accepted,"S = {""a"": input(), ""b"": input(), ""c"": input()} + +t = ""a"" +while S[t]: + nt = S[t][0] + S[t] = S[t][1:] + t = nt + +else: + print(t.upper())" +p03338,s672665333,Accepted,"n = int(input()) +s = input() +alph = [""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z""] + +cnt = 0 +for i in range(n): + prev = s[:i] + subseq = s[i:] + inner_cnt = 0 + for j in alph: + if j in prev and j in subseq: + inner_cnt += 1 + if inner_cnt > cnt: + cnt = inner_cnt +print(cnt)" +p03698,s886085975,Accepted,"s = input() +s = list(s) + +s_unique = list(set(s)) +if len(s) == len(s_unique): + print(""yes"") +else : + print(""no"")" +p02552,s523052920,Accepted,"x = int(input()) +if(x == 0): + print(1) +else: + print(0)" +p02742,s890062871,Accepted,"from math import ceil +h, w = map(int, input().split()) +if h == 1 or w == 1: + print(1) +else: + print(ceil(h/2)*ceil(w/2) + int(h/2)*int(w/2))" +p03617,s744804663,Accepted,"*aa,n = map(int, open(0).read().split()) + +n *= 1000 + +bb = [250,500,1000,2000] + +for i in range(1,4): + aa[i] = min(aa[i], aa[i-1]*2) + +ans = 0 +for b,a in zip(bb[::-1], aa[::-1]): + ans += n // b * a + n %= b + +print(ans)" +p02664,s913925543,Wrong Answer,"T = input() + +ans = """" +for i in range(len(T)): + if(T[i] == ""?""): + if(i != len(T)-1 and T[i+1] == ""D""): + ans += ""P"" + continue + elif(i != 0 and T[i-1] == ""?""): + ans += ""P"" + continue + ans += ""D"" + else: + ans += T[i] + +print(ans)" +p02548,s894191156,Wrong Answer,"n = int(input()) +count = ((n-1)*2) +a = [i for i in range(2, n//2)] +i = 2 +while a: + count += len(a)*2 + i += 1 + limit = n//i if n%i==0 else 1+n//i + a = [j for j in range(i, limit)] +print(count-(i-1))" +p03086,s629210034,Accepted,"s = input() +dp = [0]*(len(s) + 1) + +for i, x in enumerate(s): + if x in ""ACGT"": + dp[i+1] = dp[i] + 1 +print(max(dp))" +p03624,s879031709,Accepted,"s=input() +lis=[""q"",""w"",""e"",""r"",""t"",""y"",""u"",""i"",""o"",""p"",""l"",""k"",""j"",""h"",""g"",""f"",""d"",""s"",""a"",""z"",""x"",""c"",""v"",""b"",""n"",""m""] +a=set() +for i in range(len(s)): + a.add(s[i]) +#print(a) +ans=[] +for i in range(len(lis)): + if lis[i] in a: + continue + ans.append(lis[i]) +ans.sort() +if ans: + print(ans[0]) +else: + print(""None"") +" +p02748,s499998330,Accepted,"A,B,M=map(int,input().split()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +vch=[] +ac=10**15 +for i in range(A): + ac=min(ac,a[i]) +bc=10**15 +for i in range(B): + bc=min(bc,b[i]) +ans=ac+bc +for i in range(M): + c=list(map(int,input().split())) + ans=min(ans,a[c[0]-1]+b[c[1]-1]-c[2]) +print(ans)" +p02613,s952267038,Accepted,"import collections +N=int(input()) +S=[str(input()) for _ in range(N)] +C=collections.Counter(S) +print('AC x ' + str(C['AC'])) +print('WA x ' + str(C['WA'])) +print('TLE x ' + str(C['TLE'])) +print('RE x ' + str(C['RE']))" +p03241,s543772694,Accepted,"def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + divisors.sort() + return divisors + + +n,m=map(int,input().split()) +for i in make_divisors(m)[::-1]: + if n*i<=m:print(i);break" +p03061,s712257831,Accepted,"from fractions import gcd +N = int(input()) +A = list(map(int,input().split())) + +B = [A[0]] +for i in range(1,N-1): + B.append(gcd(B[-1], A[i])) + +C = [A[-1]] +for i in range(N-2,0,-1): + C.append(gcd(C[-1], A[i])) + +MAX = 0 +for i in range(N): + if i == 0: + MAX = max(MAX, C[-1]) + elif i == N-1: + MAX = max(MAX, B[-1]) + else: + MAX = max(MAX, gcd(B[i-1], C[N-i-2])) + +print(MAX)" +p02683,s123222791,Wrong Answer,"import sys +N, M, X=map(int, sys.stdin.readline().rstrip().split()) +A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)] +cost=[] +for i in range(1<>j)&1)==1: + l=[l[k]+A[j][k] for k in range(M+1)] + for k in range(M): + if l[k+1] 5: + base+=2 + else: + base+=1 + + print(base) + + +if __name__ == '__main__': + main() +" +p02719,s932468914,Accepted,"n, k = map(int, input().split()) +if n % k == 0: + print(0) +else: + l = [n] + p = n // k + c = n - (p * k) + half = k // 2 + while c > half: + c = abs(c - k) + l.append(c) + print(min(l)) +" +p03359,s104576030,Accepted,"a, b = map(int, input().split()) +if b >= a: + ans = a +else: + ans = a-1 +print(ans)" +p04020,s551763418,Accepted,"n = int(input()) +A = [int(input()) for i in range(n)] + +ans = 0 +for i in range(n): + m = A[i] // 2 + ans += m + A[i] -= 2*m + if i <= n-2 and min(A[i], A[i+1]) == 1: + ans += 1 + A[i] -= 1 + A[i+1] -= 1 +print(ans)" +p02744,s635290601,Accepted,"N = int(input()) + + +def f(L): + l = len(L) + if l == N: + print(''.join(list(map(lambda i: chr(i + 96), L)))) + return + for d in range(1, min(l, max(L)) + 2): + f(L + [d]) + + +f([1]) +" +p03910,s737640147,Accepted,"N=int(input()) + +#bit探索 +start=int((2*N+1)**0.5) + +for i in range(3): + i += start + if i*(i+1) >= 2*N: + ret = i + delete=i*(i+1)/2 - N + break + +for k in range(1,ret+1): + if k != delete: + print(k)" +p03644,s964625932,Accepted,"import sys +sys.setrecursionlimit(4100000) +import math +import itertools +INF = float('inf') +from heapq import heapify, heappop, heappush + +def main(): + n = int(input()) + for i in range(8): + if 2**i > n: + print(2**(i-1)) + return + + +if __name__ == '__main__': + main() +" +p03485,s681700254,Wrong Answer,"a,b = map(int,input().split()) +c = round((a+b)/2) +print(c) +" +p02783,s582333759,Accepted,"H = input() +arr = [int(i) for i in H.split(' ')] +count = 1 +if(arr[0]arr[1]: + arr[0] = arr[0] - arr[1] + count = count + 1 + print(count)" +p02556,s942986563,Accepted,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(10 ** 7) + +n = int(input()) +xy = [0] * n + +xy_plus_max = -10 ** 10 +xy_plus_min = 10 ** 10 +xy_minus_max = -10 ** 10 +xy_minus_min = 10 ** 10 +for i in range(n): + x, y = map(int, input().split()) + xy_plus_max = max(xy_plus_max, x + y) + xy_plus_min = min(xy_plus_min, x + y) + xy_minus_max = max(xy_minus_max, x - y) + xy_minus_min = min(xy_minus_min, x - y) + +print(max(xy_plus_max - xy_plus_min, xy_minus_max - xy_minus_min)) +" +p02603,s704173894,Wrong Answer,"N = int(input()) + +A = list(map(int,input().split())) + +m = 1000 +s = 0 +for i in range(N-1): + if A[i]<=A[i+1]: + s += m//A[i] + m -= (m//A[i])*A[i] + else: + m +=s*A[i+1] + s = 0 +if s>0: + m+=A[-1]*s +print(m) + " +p02768,s759723088,Accepted,"n, a, b = map(int,input().split()) +mod = 10**9+7 +total = pow(2, n, mod) - 1 +def c(n, r): + p, q = 1, 1 + for i in range(r): + p = p*(n-i)%mod + q = q*(i+1)%mod + return p * pow(q, mod-2, mod)%mod + +print((total - c(n, a) - c(n, b))%mod)" +p03759,s273591814,Accepted,"from collections import Counter,defaultdict,deque +from heapq import heappop,heappush,heapify +from bisect import bisect_left,bisect_right +import sys,math,itertools,fractions,pprint +sys.setrecursionlimit(10**8) +mod = 10**9+7 +INF = float('inf') +def inp(): return int(sys.stdin.readline()) +def inpl(): return list(map(int, sys.stdin.readline().split())) + +a,b,c = inpl() +print('YES' if b-a == c-b else 'NO') " +p02689,s837435672,Accepted,"from collections import defaultdict +N,K=map(int,input().split()) +L=list(map(int,input().split())) +Hash=defaultdict(lambda:list()) +for i in range(K): + x,y=map(int,input().split()) + Hash[x-1].append(y-1) + Hash[y-1].append(x-1) +count=0 +for i in range(N): + FLAG=0 + for k in Hash[i]: + if L[k]>=L[i]: + FLAG=1 + break + if FLAG==0: + count+=1 +print(count)" +p03380,s310460400,Accepted,"n = int(input()) +a_list = list(map(int,input().split())) +a_list.sort() +a_max = a_list.pop() +result = [] +import math +for a in a_list: + result.append(abs(math.ceil(a_max /2) - a)) + +print(a_max,a_list[result.index(min(result))]) +" +p02918,s278530712,Accepted,"n,k = list(map(int,input().split())) +s = str(input()) +ans = 0 +for i in range(1,len(s)): + if s[i] == s[i-1]: + ans += 1 + +if (n-1) >= (ans + 2*k): + ans += 2*k +else: + ans = n - 1 + +print(ans)" +p02989,s965481015,Wrong Answer,"n=int(input()) +l=sorted(list(map(int,input().split()))) +print(l[n//2]-l[n//2-1]-int(l[n//2]==l[n//2-1]) )" +p03485,s276083600,Accepted,"import math +a, b = map(int, input().split()) +print(math.ceil((a+b)/2))" +p03309,s382029828,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +A = sorted([i-k-1 for k,i in enumerate(A)]) +b = A[N//2] +print(sum(abs(i-b) for i in A))" +p03720,s636415146,Accepted,"N, M = map(int, input().split()) + +d = {i+1: [] for i in range(N)} +for _ in range(M): + a, b = map(int, input().split()) + d[a].append(b) + d[b].append(a) + +for i in range(N): + print(len(d[i+1]))" +p03592,s770352426,Accepted,"N, M, K = map(int, input().split()) + +for n in range(N+1): + for m in range(M+1): + if K == n*(M-m) + (N-n)*m: + print(""Yes"") + exit() +print(""No"")" +p03324,s631370846,Accepted,"d, n = map(int, input().split()) +if n != 100: + print((100**d)*n) +else: + print((100**d)*101) +" +p02801,s085866598,Accepted,"print(chr(ord(input())+1)) +" +p02784,s024832526,Wrong Answer,"H,N = map(int,input().split()) +a = [int(s) for s in input().split()] +s = H - sum(a) +if s < 0: + print(""No"") +else: + print(""Yes"")" +p03331,s960094227,Accepted,"# 記録 +N = int(input()) +results = [] +for i in range(1,N): + results.append(sum(map(int,str(i))) + sum(map(int,str(N-i)))) +print(min(results))" +p02596,s576837806,Accepted,"K = int(input()) +if K%2==0: + print(""-1"") +elif K%5==0: + print(""-1"") +else: + ans = 0 + temp = 0 + check = 0 + for i in range(K): + ans += 1 + temp *= 10 + temp += 7 + temp %= K + + if temp==0: + check+=1 + + if check==1: + break + print(ans)" +p04034,s571036926,Wrong Answer,"n,m = map(int,input().split("" "")) +ar = [[0,1] for i in range(n)] +ar[0] = [1,1] +r = 0 +for i in range(m): + a,b = map(int,input().split("" "")) + a -= 1 + b -= 1 + if ar[a][0] == 1 and ar[a][1] >= 1: + ar[b][0] = 1 + ar[b][1] += 1 + ar[a][1] -= 1 + if ar[a][1] == 0: + ar[a][0] = 0 +count = 0 +for r in ar: + if r[0] == 1: + count += 1 +print(count)" +p04045,s462267325,Accepted,"N, K=map(int, input().split()) +D=set(map(str, input().split())) +while True: + s=str(N) + for t in s: + if t in D: + N+=1 + break + else: + print(N) + exit()" +p02552,s653049877,Wrong Answer,"x = input() +if x == 0: + print(""1"") +else: + print(""0"")" +p03042,s257346894,Accepted,"s=input() +a=int(s[:2]) +b=int(s[2:]) +if 1<=a<=12 and 1<=b<=12: + print('AMBIGUOUS') +elif 1<=b<=12: + print('YYMM') +elif 1<=a<=12: + print('MMYY') +else: + print('NA') +" +p03795,s612639524,Accepted,"n = int(input()) +a = n * 800 +b = n // 15 * 200 + +print(a - b) +" +p04043,s487708339,Accepted,"a,b,c = sorted(map(int, input().split())) +if (a+b+c==17)&(a==b)&(c==7): + print(""YES"") +else: + print(""NO"") +" +p04019,s119102218,Accepted,"#! /usr/bin/env python3 + +import sys +import numpy as np +from collections import defaultdict +int1 = lambda x: int(x) - 1 +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(500000) + +S = readline().decode().rstrip() +dicts = defaultdict(int) + +for c in S: + dicts[c] += 1 + +for pair in [('N', 'S'), ('W', 'E')]: + if min(dicts[pair[0]], dicts[pair[1]]) == 0: + if max(dicts[pair[0]], dicts[pair[1]]) != 0: + print('No') + sys.exit() +print('Yes') + +" +p03774,s639512338,Wrong Answer,"N,M = [int(i) for i in input().split()] +a = [[int(i) for i in input().split()] for j in range(N)] + +c =[[int(i) for i in input().split()] for j in range(M)] + +n = 10000000 +n1 = 0 +n2 = 0 + +for i in range(N): + for j in range(M): + n1 = abs(c[j][0] - a[i][0]) + abs(c[j][1] - a[i][1]) + if n1 < n: + n = n1 + n2 = j + n = 10000000 + print(n2 + 1) +" +p03351,s433985449,Accepted,"a, b, c, d = map(int,input().split()) + +if ((abs(a-b) <= d) and (abs(b-c) <= d)) or abs(a-c) <= d: + print(""Yes"") + +else: + print(""No"") + + + +" +p02675,s939130299,Accepted,"s = input() +#n = s.length() +if s[-1] in ['2','4','5','7','9']: + print('hon') +elif s[-1] in ['0','1','6','8']: + print('pon') +else: + print('bon')" +p02681,s280674154,Accepted,"import sys +S = sys.stdin.readline().strip() +T = sys.stdin.readline().strip() +if T[:-1] == S: + print(""Yes"") +else: + print(""No"") + " +p03625,s306279609,Accepted,"n = int(input().strip()) +a = list(map(int, input().split())) +reps = [] + +a.sort() +tmp = 0 +for e in a: + if e == tmp: + reps.append(e) + tmp = 0 + else: + tmp = e +if len(reps) < 2: + print(0) +else: + print(reps[-1] * reps[-2]) +" +p02754,s987486639,Accepted,"N, A, B = map(int, input().split()) +a = N//(A+B) +b = N % (A+B) + +if A == 0: + print(0) +elif b <= A: + print(a*A+b) +else: + print(a*A+A)" +p02594,s632607966,Accepted,"n = int(input()) +if n>=30: + print(""Yes"") +else: + print(""No"")" +p03219,s595496662,Accepted,"a, b = map(int, input().split()) +print(a + b//2)" +p02730,s500847024,Accepted,"S = input() +N = len(S) + +end = (N-1)//2 +stt = (N+3)//2 + +S1 = S[:end] +S2 = S[stt-1:] + +if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]: + print('Yes') +else: + print('No')" +p02831,s722271511,Accepted,"#!/usr/bin/python3 + +import sys +#import math +import fractions as math + +def input(): + return sys.stdin.readline().rstrip('\n') + +#N = int(input()) +A,B = list(map(int, input().split())) + +def lcm(x, y): + return (x * y) // math.gcd(x, y) + +print(lcm(A,B)) +" +p02947,s232167071,Accepted,"# coding: utf-8 +n = int(input()) +dic = {} +for i in range(n): + s = """".join(sorted(input())) + dic.setdefault(s, 0) + dic[s] += 1 +ans = 0 +for x in dic.values(): + ans += int(x * (x - 1) / 2) +print(ans)" +p03379,s040017652,Wrong Answer,"N = int(input()) +X = list(map(str,input().split())) +X_ = sorted(X) +for x in X: + if x < X_[(N//2)]: + print(X_[(N)//2]) + elif x == X_[(N//2)]: + print(X_[(N)//2-1]) + else: + print(X_[(N)//2-1])" +p02982,s428064547,Wrong Answer,"from itertools import combinations + + +sq_nums = {i * i for i in range(101)} + +N, D = map(int, input().split()) +coords = [list(map(int, input().split())) for _ in range(N)] +ans = 0 +for Y, Z in combinations(coords, 2): + if sum((y - z) ** 2 for y, z in zip(Y, Z)) in sq_nums: + ans += 1 +print(ans) +" +p02615,s594456221,Wrong Answer,"n = int(input()) +f = list(map(int,input().split())) +f.sort(reverse = True) +ans = 0 +if n%2 == 0: + for i in range(n//2): + ans += f[i] * 2 + ans -= f[0] +else: + for i in range(n//2): + ans += f[i] * 2 + ans += f[n//2+1]-f[0] + +print(ans)" +p03001,s702688593,Accepted,"w,h,x,y = map(int, input().split()) + +t = w * h / 2 + +if x == w/2 and y == h/2: + print(t, 1) +else: + print(t, 0)" +p02777,s016575443,Accepted,"S , T = map(str,input().split()) +A , B = map(int,input().split()) +U =str(input()) + +if U == S: + A -=1 +else: + B -=1 +print(str(A)+"" ""+str(B))" +p02623,s896450551,Wrong Answer,"from queue import deque + +N, M, K = map(int, input().split()) + +A = list(map(int, input().split())) +A = deque(A) +B = list(map(int, input().split())) +B = deque(B) + +count = 0 + +while 1: + a = A.popleft() if A else 10**9+1 + b = B.popleft() if B else 10**9+1 + + if min(a, b) <= K: + count += 1 + K -= min(a, b) + if a <= b: + B.appendleft(b) + else: + A.appendleft(a) + else: + break + +print(count) +" +p03359,s022405793,Wrong Answer,"# ABC 096: A – Day of Takahashi +a, b = [int(s) for s in input().split()] +print(a if a <= b else b)" +p03351,s825676984,Accepted,"def main(): + a,b,c,d = map(int,input().split()) + if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d): + print('Yes') + else: + print('No') +main()" +p02761,s033889523,Accepted,"n, m = map(int, input().split()) +s=[] +c=[] +for i in range(m): + _s, _c = map(int, input().split()) + s.append(_s-1) + c.append(_c) + +for i in range(1000): + *t, = map(int, list(str(i))) + + if len(t) != n: + continue + + ok = True + for j in range(m): + if t[s[j]]!=c[j]: + ok = False + break + + if ok: + print(i) + quit() + +print(-1)" +p02778,s314283837,Accepted,"s = open(0).read().rstrip() +print(""x"" * len(s))" +p02953,s763548232,Accepted,"n= int(input()) +if n==1: + print('Yes') + exit() +h=list(map(int,input().split())) +ans='Yes' +for i in range(n-1): + if h[i+1]>h[i]: + h[i+1]-=1 + elif h[i+1]=n or s[i][1]<=List[j]: + break + while j0 and s[i][1]> List[j]: + ans+=s[i][1] + s[i][0]-=1 + j+=1 +if j>=n: + print(ans) +else: + print(ans+sum(List[j:])) +" +p02899,s365658632,Accepted,"n = int(input()) +a = list(map(int, input().split())) +lists = [i for i in range(1, n + 1)] +dicts = {j:i for i, j in zip(lists, a)} +for i in range(1, n + 1): + print(dicts[i], end=' ') +print() +" +p02660,s200173428,Accepted,"import collections + +N = int(input()) + +A = list() +if N == 1: + A.append(1) +else: + while N%2 == 0: + A.append(2) + N = N//2 + f = 3 + while f*f <= N: + if N % f == 0: + A.append(f) + N = N//f + else: + f += 2 + if N != 1: + A.append(N) + +A = collections.Counter(A) +del A[1] +count = 0 + +for a in A.values(): + n = 1 + th = n*(n+1)/2 + while a >= th: + n += 1 + th = n*(n+1)/2 + count += n-1 + +print(count)" +p02775,s276210751,Accepted,"# E - Payment + +S = input() +N = len(S) + +# 先頭からi桁目までの金額のやり取りに必要な紙幣の枚数 +dp = [0] +dp_plus1 = [1] + +for i in range(N): + x = int(S[i]) + dp.append(min(dp[i] + x, dp_plus1[i] + (10 - x))) + dp_plus1.append(min(dp[i] + (x + 1), dp_plus1[i] + (10 - (x + 1)))) + +print(dp[-1])" +p04012,s184427857,Accepted,"s = input() +dic = {} +for i in s: + if i in dic: + dic[i] += 1 + else: + dic[i] = 1 + +for i in dic: + if dic[i]%2 != 0: + print('No') + break +else: + print('Yes') + " +p03042,s222347681,Accepted,"S = input() +YY = int(S[0:2]) +MM = int(S[2: ]) + +if YY <= 12 and YY > 0 and MM <= 12 and MM > 0: + print(""AMBIGUOUS"") +elif YY <= 12 and YY > 0 and (MM >= 13 or MM == 0): + print(""MMYY"") +elif (YY == 0 or YY >= 13) and MM <= 12 and MM > 0: + print(""YYMM"") +else: + print(""NA"")" +p04045,s340061597,Accepted,"import sys +import numpy as np +read = sys.stdin.readline + + +def main(n, k, a): + for i in np.arange(n, 100000): + ok = True + j = i + while j: + ok &= j % 10 not in a + j //= 10 + if ok: + print(i) + break + + +if __name__ == '__main__': + n, k = np.fromstring(read(), dtype=np.int32, sep=' ') + a = np.fromstring(read(), dtype=np.int32, sep=' ') + main(n, k, a) +" +p03544,s148252293,Accepted,"n=int(input()) +l=[0]*(n+1) +l[0]=2 +l[1]=1 +for i in range(n+1): + if i==0 or i==1: + continue + else: + l[i]=l[i-1]+l[i-2] +print(l[n]) +" +p02606,s143350031,Accepted,"import bisect, collections, copy, heapq, itertools, math, string, sys +input = lambda: sys.stdin.readline().rstrip() +sys.setrecursionlimit(10**7) +INF = float('inf') +def I(): return int(input()) +def F(): return float(input()) +def SS(): return input() +def LI(): return [int(x) for x in input().split()] +def LI_(): return [int(x)-1 for x in input().split()] +def LF(): return [float(x) for x in input().split()] +def LSS(): return input().split() + +def resolve(): + L, R, d = LI() + + ans = R // d - (L - 1) // d + print(ans) + +if __name__ == '__main__': + resolve() +" +p03386,s909977546,Accepted,"a, b, k = map(int, input().split()) + +for i in range(a, a + k): + if i <= b: + print(i) + +for j in range(b - k + 1, b + 1): + if i < j: + print(j)" +p02742,s499222272,Wrong Answer,"H,W = map(int, input().split()) + + +print(int((H*W)/2+0.5))" +p03545,s898797780,Accepted,"#!/usr/bin/env python3 +s = input() +a = [int(c) for c in s] + +for i in range(2 ** 3): + ptn = [] + num = a[0] + + for j in range(3): + if (i >> j) & 1: + ptn.append(""+"") + num += a[j + 1] + + else: + ptn.append(""-"") + num -= a[j + 1] + + if num == 7: + print(""{}{}{}{}{}{}{}=7"".format(a[0], ptn[0], a[1], ptn[1], a[2], ptn[2], a[3])) + break +" +p02687,s724156808,Wrong Answer,"def main(): + s = input() + if s == 'ABC': + print('ARC') + else: + print(s) +if __name__ == '__main__': + main()" +p02773,s404438742,Wrong Answer,"n = int(input()) +info = [] +for i in range(n): + info.append(input()) + +info.sort() + +ans = [] +record = 1 +tem_record = 1 +for i in range(n-1): + if info[i] == info[i+1]: + tem_record += 1 + if tem_record == record: + ans.append(info[i]) + else: + if tem_record > record: + record = tem_record + ans = [info[i]] + tem_record = 1 + +if record == 1 and info[n-1] != info[n-2]: + ans.append(info[n-1]) + + +ans.sort() +for i in ans: + print(i)" +p02615,s983918654,Accepted,"n = int(input()) +a = list(map(int, input().split())) + +a1 = sorted(a, reverse=True) +com = 0 + +if n == 2: + com = a1[0] +elif n%2 ==0: + c = int(n/2) + com = sum(a1[0:c]) + com += sum(a1[1:c]) +else: + c = int(n//2) + com += sum(a1[0:c+1]) + com += sum(a1[1:c]) + +print(com)" +p03146,s085026325,Accepted,"s=int(input()) +a=[] +ans=1 +while True: + a.append(s) + if s%2==0: + s//=2 + else: + s=s*3+1 + ans+=1 + if s in a: + print(ans) + break" +p02946,s088580336,Accepted,"K, X = map(int, input().split()) + +stone = [str(i) for i in range(X - (K - 1), X + K)] +print(' '.join(stone))" +p02664,s575793960,Accepted,"import sys +input = sys.stdin.readline + +t=input() + + +ans=[] +for i in range(len(t)): + if t[i]== ""?"": + ans.append(""D"") + else: + ans.append(t[i]) + +for i in range(len(ans)): + print(ans[i], end="""")" +p02802,s746841275,Accepted,"N, M = map(int,input().split()) + +WA = [0] * N +AC = [0] * N +ac = 0 +wa = 0 + +for i in range(M): + pi, S = map(str,input().split()) + p = int(pi) + + if S == ""AC"": + if AC[p-1] != 1: + AC[p-1] = 1 + ac += 1 + wa += WA[p-1] + elif S == ""WA"": + if AC[p-1] == 1: + pass + else: + WA[p-1] += 1 +else: + print(ac, wa)" +p03013,s103612464,Wrong Answer,"N,M=map(int,input().split()) +if N==1: + print(N) + exit() +dp=[-1]*N +dp[-1]=1 +dp+=[1] +mod=10**9+7 +for i in range(M): + a=int(input()) + dp[a]=0 +i=N-2 +while i>=0: + if dp[i]==-1: + dp[i]=dp[i+1]+dp[i+2] + i-=1 +print(dp[0])" +p02797,s364832449,Accepted,"import sys + +readline = sys.stdin.readline +readlines = sys.stdin.readlines +ns = lambda: readline().rstrip() # input string +ni = lambda: int(readline().rstrip()) # input int +nm = lambda: map(int, readline().split()) # input multiple int +nl = lambda: list(map(int, readline().split())) # input multiple int to list + +n, k, s = nm() +ans_h = [str(s) for _ in range(k)] +if s==10**9 : + ans_t = ['1' for _ in range(n-k)] +else: + ans_t = [str(s+1) for _ in range(n-k)] +print(' '.join(ans_h + ans_t))" +p02618,s114092069,Wrong Answer,"D=int(input()) +c=list(map(int,input().split())) +s=[] +t=[] +v=0 +lastday=[0 for i in range(26)] + +for i in range(D): + tmp=list(map(int,input().split())) + s.append(tmp) + +for i in range(26): + print(26-i)" +p02727,s523679932,Accepted,"# coding: utf-8 +x, y, a, b, c = map(int, input().split()) +p = list(map(int, input().split())) +q = list(map(int, input().split())) +r = list(map(int, input().split())) +p.sort(reverse=True) +q.sort(reverse=True) +r.sort(reverse=True) +p = p[:x] +q = q[:y] +all = p + q + r +all.sort(reverse=True) +print(sum(all[:x+y]))" +p02783,s071677718,Wrong Answer,"H, A = map(int, input().split()) +cnt = 0 +while H<=0: + H //= A + cnt += 1 + +print(cnt+1)" +p02947,s306879330,Wrong Answer,"from collections import Counter + +# input +N = int(input()) +S = [] +s_append = S.append +for n in range(N): + s = input() + counter = Counter(s) + s_append(counter) + +matched = [] +cnt = 0 +m_append = matched.append +for i, s in enumerate(S): + if s in matched: + continue + add = len( + [ + 1 + for j, c in enumerate(S) + if i != j + and s == c + ] + ) + if add > 0: + m_append(s) + cnt += add + +print(cnt)" +p02744,s638980412,Accepted,"import sys +sys.setrecursionlimit(10 ** 8) +n = int(input()) +alp = ""abcdefghijklmnopqrstuvwxyz"" +permutations = [] + +def dfs(a, size): + if len(a) == size: + global permutations + permutations.append(a) + return + for i in range(1, max(a) + 2): + dfs(a + [i], size) + +dfs([1], n) +for i in permutations: + print(''.join([alp[j-1] for j in i]))" +p02748,s388309467,Accepted,"import sys + +def I(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LMI(): return list(map(int, sys.stdin.readline().split())) +MOD = 10 ** 9 + 7 + + +A, B, M = MI() +A = LMI() +B = LMI() + +minA = min(A) +minB = min(B) +ans = minA + minB +for _ in range(M): + x, y, c = MI() + ans = min(ans, A[x - 1] + B[y - 1] - c) +print(ans)" +p02677,s318522721,Accepted,"a,b,h,m=map(int,input().split()) +# Pythonで三角関数は単位をradiansにしてから +from math import cos,radians +# 時針Aの角度は1時間で30°、分数を加味してh*30°+30°*m/60 +# 分針Bの角度は1分で6°、m*6° +theta = abs(m*6 - (h*30 + m / 2)) +# 余弦定理 c**2 = a**2 + b**2 - 2abcosθ +print((a**2 + b**2 - 2*a*b*cos(radians(theta)))**0.5)" +p03994,s020006964,Wrong Answer,"s = list(input()) +k = int(input()) +n = len(s) +for i in range(n): + d = ord('z')-ord(s[i])+1 + if d<=k: + s[i] = 'a' + k -= d + +x = (ord(s[i])-ord('a')+k)%26 +s[-1] = chr(ord('a')+x) + +print(''.join(s)) +" +p02624,s716188229,Wrong Answer,"import math +N = int(input()) +Array = [1]*(N+1) +for i in range(1,int(math.sqrt(N))+1): + for j in range(i+i,N+1,i): + Array[j]+=1 +ans = 0 +for i in range(1,N+1): + ans+=i*Array[i] +print(ans)" +p03623,s414829006,Accepted,"x, a, b = (int(i) for i in input().split()) +da = abs(x-a) +db = abs(x-b) +if da < db: + print('A') +else: + print('B')" +p02725,s311243672,Accepted,"import sys + +K,N = map(int, sys.stdin.readline().strip().split()) +A = list(map(int, sys.stdin.readline().strip().split())) +# K = 20 +# N = 3 +# A =[0, 5, 15] +# A =[5, 10, 15] + +distance = [] +# 家間距離 +for i,a in enumerate(A): + if i == len(A) - 1: + distance.append(K - A[i] + A[0]) + else: + distance.append(A[i+1] - A[i]) + +# print(distance) +print(sum(distance) - max(distance)) +" +p03408,s863682438,Wrong Answer,"from collections import defaultdict as ddf +n=int(input()) +s=[input() for _ in range(n)] +m=int(input()) +t=[input() for _ in range(m)] + +dd=ddf(lambda:0) +for e in s: dd[e]+=1 +for e in t: dd[e]-=1 +print(max(dd.values()))" +p02760,s899733591,Accepted,"a,b,c=map(int,input().split()) +d,e,f=map(int,input().split()) +g,h,i=map(int,input().split()) +N=int(input()) +L=[int(input()) for i in range(N)] +if a in L and b in L and c in L: + print('Yes') +elif d in L and e in L and f in L: + print('Yes') +elif g in L and h in L and i in L: + print('Yes') +elif a in L and d in L and g in L: + print('Yes') +elif b in L and e in L and h in L: + print('Yes') +elif c in L and f in L and i in L: + print('Yes') +elif a in L and e in L and i in L: + print('Yes') +elif c in L and e in L and g in L: + print('Yes') +else: + print('No') + " +p02547,s903951839,Wrong Answer,"N = int(input("""")) +count = 0 +for i in range(N): + D = (input("""")) + l = D.split() + l_i = [int(s) for s in l] + if l_i[0] == l_i[1]: + count += 1 +if count > 2: + print(""Yes"") +else: + print(""No"")" +p03037,s104210072,Wrong Answer,"N, M = map(int, input().split()) +LR = [list(map(int, input().split())) for i in range(M)] + +ListL = [] +ListR = [] + +for i in range(M): + ListL.append(LR[i][0]) + +for i in range(M): + ListR.append(LR[i][1]) + +print(min(ListR)-max(ListL)+1) +" +p03852,s112870488,Accepted,"c = input() +if c in ""aiueo"": + print(""vowel"") +else: + print(""consonant"")" +p03351,s552267215,Wrong Answer,"data = input() + +dataa,datab,datac,datad = data.split(' ') + +dataa = int(dataa) +datab = int(datab) +datac = int(datac) +datad = int(datad) + +length = dataa -datab + datab - datac + +if length < datad: + print('Yes') +else: + print('No')" +p02760,s315441810,Wrong Answer,"f=lambda a:any(all(b)for b in a)or all(a[i][i]for i in(0,1,2)) +a=eval('list(map(int,input().split())),'*3) +exec('b=int(input());a=[[u*(u!=b)for u in t]for t in a];'*int(input())) +a=[[not u for u in t]for t in a] +r=0 +exec('r|=f(a)|f(a[::-1]);a=[t[::-1]for t in a];'*2) +print('NYoe s'[r::2])" +p03475,s963077112,Accepted," +n=int(input()) +c=[0]*(n-1) +s=[0]*(n-1) +f=[0]*(n-1) +for i in range(n-1): + c[i],s[i],f[i]=map(int,input().split()) + +for i in range(n): + t=0 + for j in range(i,n-1): + if t c: + ans = c + +print(ans)" +p03416,s093629126,Wrong Answer,"a,b=map(int,input().split()) +count = 0 +for i in range(a,b): + if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]: + count+=1 +print(count)" +p03285,s185209596,Wrong Answer,"n = int(input()) + +a = n % 4 +b = n % 7 +c = n % 11 +if a == 0 or b == 0 or c == 0: + print('Yes') +else: + print('No') +" +p03817,s353383880,Wrong Answer,"x = int(input()) +s, r = divmod(x, 11) +s *= 2 +s += 2 if r > 6 else 1 +print(s) + +" +p03657,s755277447,Accepted,"a,b=map(int,input().split()) +if a*b*(a+b)%3==0: + print(""Possible"") +else: + print(""Impossible"")" +p02705,s528373836,Wrong Answer,"import math +radius = float(input(""Enter the radius of the circle : "")) +circumference = 2 * math.pi * radius +print(""Circumference of the circle is : %.2f"" % circumference) +" +p02881,s427015715,Accepted,"N = int(input()) +import math + +n = math.sqrt(N) +if n.is_integer(): + x = round(n) - 1 + print(2 * x) +else: + def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n // i) + divisors.sort() + return divisors + l = make_divisors(N) + if len(l) % 2 == 0: + x = l[len(l) // 2 - 1] + y = l[len(l) // 2] + print(x + y - 2)" +p02916,s969925207,Accepted,"L = [int(input()), list(map(int, input().split(' '))), list(map(int, input().split(' '))), list(map(int, input().split(' ')))] +print(sum([L[2][L[1][i]-1]+L[3][L[1][i]-2] if i>0 and L[1][i]-L[1][i-1]==1 else L[2][L[1][i]-1] for i in range(L[0])]))" +p03385,s512069891,Accepted,"s=str(input()) +s=list(s) +s=list(set(s)) +s.sort() +if len(s)>=3: + if s[0]==""a"" and s[1]==""b"" and s[2]==""c"": + print(""Yes"") + else: + print(""No"") +else: + print(""No"")" +p02859,s116200535,Accepted,"n = int(input()) +print(n * n)" +p03324,s159436118,Accepted,"d, n = map(int, input().split()) +cnt = 0 +i = 0 +while cnt < n: + i += 1 + if i % 100**d == 0 and i % 100**(d+1) != 0: + cnt += 1 +print(i) +" +p02600,s088968748,Wrong Answer,"n=int(input()) +if(n<599): + print('8') +elif n<799: + print('7') +elif n<999: + print('6') +elif n<1199: + print('5') +elif n<1399: + print('4') +elif n<1599: + print('3') +elif n<1799: + print('2') +else: + print('1')" +p02854,s377558970,Wrong Answer,"import sys +import math +import itertools +import bisect +from copy import copy +from collections import deque,Counter +from decimal import Decimal +def s(): return input() +def i(): return int(input()) +def S(): return input().split() +def I(): return map(int,input().split()) +def L(): return list(input().split()) +def l(): return list(map(int,input().split())) +def lcm(a,b): return a*b//math.gcd(a,b) +sys.setrecursionlimit(10 ** 9) +mod = 10**9+7 + +N = i() +A = l() +ruiseki = [0]+list(itertools.accumulate(A)) +i = bisect.bisect_left(ruiseki,sum(A)/2) +print(abs(sum(A[:i])-sum(A[i:])))" +p03146,s365054688,Accepted,"s=int(input()) +A=set() +A.add(s) +count=1 +while count==len(A): + if s%2==0: + A.add(s/2) + count+=1 + s=s/2 + else: + A.add(3*s+1) + count+=1 + s=3*s+1 +print(count)" +p02701,s666752108,Accepted,"N = int(input()) +S = set() +for _ in range(N): + S.add(input()) +print(len(S))" +p03001,s206017724,Accepted,"W,H,x,y = map(int,input().split()) +if W/2 == x and H/2 == y: + ans = 1 +else: + ans = 0 +print(H*W/2, ans)" +p02835,s537858910,Accepted,"a,b,c = map(int, input().split()) +print('win' if a+b+c<22 else 'bust')" +p03284,s420139526,Accepted,"#!/usr/local/bin python +# -*- coding: utf-8 -*- +# +# ~/PycharmProjects/atcoder/A-AtCoderCrackers.py +# +n, k = map(int, input().split()) +if n % k == 0: + print(0) +else: + print(1) +" +p02720,s558511451,Wrong Answer,"k = int(input()) +x = 0 + +if k <= 12: + print(k) +else: + x = ((11 * (int((k-12)/3)) + 12)) + if (k-12) % 3 == 0: + print(x) + elif (k-12) % 3 == 1: + print(x+9) + else: + print(x+10)" +p03408,s745195501,Accepted,"n = int(input()) +d = {} +for _ in range(n): + s = input() + if s in d: + d[s] += 1 + else: + d[s] = 1 +m = int(input()) +for _ in range(m): + t = input() + if t in d and d[s] > 0: + d[t] -= 1 +print(max(d[s] for s in d))" +p03264,s022070854,Accepted,"num = int(input()) + +even_count = num // 2 + +if num % 2 == 0: + odd_count = even_count +else: + odd_count = even_count + 1 + +print(odd_count * even_count) +" +p03416,s452223165,Accepted,"A, B = map(int, input().split()) +cnt = 0 +for i in range(A, B+1): + if str(i) == str(i)[::-1]: + cnt += 1 +print(cnt)" +p02622,s409954174,Accepted,"s = input() +t = input() + +res = 0 +for i in range(len(s)): + if s[i] != t[i]: + res += 1 + +print(res)" +p03160,s493997593,Accepted,"n = int(input()) +h = list(map(int, input().split())) +dp = [float(""inf"") for i in range(n)] +dp[0] = 0 +dp[1] = dp[0] + (h[1] - h[0]) +for i in range(1, n): + dp[i] = min(dp[i - 2] + (abs(h[i] - h[i - 2])), dp[i - 1] + (abs(h[i] - h[i - 1]))) +print(dp[n - 1])" +p02633,s284917907,Accepted,"n=int(input()) +for i in range(1, n+1): + x=360*i%n + if x==0: + print(360*i//n) + break; + else: + continue;" +p03827,s604096292,Accepted,"n = int(input()) +s = input() +x = 0 +ans = 0 +for c in s: + if c == 'I': + x += 1 + else: + x -= 1 + ans = max(ans, x) +print(ans) +" +p03095,s833207892,Accepted,"from collections import Counter + +N = int(input()) +S = list(input()) + +ac = Counter(S) +ans = 0 +for value in ac.values(): + if ans == 0: + ans = value+1 + else: + ans = ans*(value+1) + +MOD = 10**9+7 +print((ans-1) % MOD) +" +p02571,s703471786,Wrong Answer,"s = input() +t = input() + +ls = len(s) +lt = len(t) + +ans = 1000000 +for i in range(ls - lt): + tmp = s[i:i+lt] + score = 0 + for j in range(lt): + if tmp[j] != t[j]: + score += 1 + ans = min(ans, score) + +print(ans)" +p02882,s419780744,Accepted,"a,b,x = map(int,input().split()) +import math + +if( x*2 < a*a*b): + tan_y = 2*x/(b*b*a) + ans = 90 - math.degrees(math.atan(tan_y)) + +else: + tan_x = 2*(a*a*b - x)/(a*a*a) + ans = math.degrees(math.atan(tan_x)) + +print(ans)" +p03607,s944326122,Accepted,"from collections import defaultdict +n=int(input()) +d=defaultdict(int) +for i in range(n): + a=int(input()) + d[a]+=1 + +sm=0 +for i,j in d.items(): + sm+=j%2 + +print(sm)" +p03455,s345026995,Accepted,"# -*- coding: utf-8 -*- + +a, b = map(int, input().split()) + +if (a * b) % 2 != 0: + print('Odd') +else: + print('Even')" +p02702,s608719329,Accepted,"s = input() +modl = [0]*2019 +modl[0] = 1 +mstack = 0 +digit = 1 +ans = 0 + +for i in s[::-1]: + mstack += int(i) * digit + mstack %= 2019 + modl[mstack] += 1 + digit = digit*10%2019 + +for i in modl: + ans += i*(i - 1)//2 + +print(ans)" +p02596,s529244012,Wrong Answer,"k=int(input()) +c=0 +x=0 +for c in range(7): + x=x+7*10**c + if x%k==0: + print(c+1) + break + elif c==6: + print(-1) + break" +p02645,s780268617,Accepted,"S = input() + +print(S[0:3])" +p03455,s856316712,Accepted,"a,b = map(int, input().split()) + +if a*b % 2 == 0: + print(""Even"") +else: + print(""Odd"")" +p02916,s067347171,Accepted,"N = int(input().rstrip()) +A = list(map(int,input().rstrip().split())) +B = list(map(int,input().rstrip().split())) +C = list(map(int,input().rstrip().split())) +ans = sum(B) +for i in range(N-1): + if A[i]+1 == A[i+1]: + ans += C[A[i]-1] +print(ans)" +p03657,s758116950,Wrong Answer,"A, B = map(int, input().split()) + +if A % 3 == 0 or B % 3 == 0 or A + B % 3 == 0: + print(""Possible"") +else: + print(""Impossible"")" +p02922,s938027046,Accepted,"a,b=map(int, input().split()) + +n=int((b-1)/(a-1)) +if (b-1)%(a-1)==0: + print(n) +else: + print(n+1)" +p02621,s661371390,Accepted,"a = int(input()) + +print(a**3+a**2+a)" +p02833,s992133260,Accepted,"def fx(X, n): + if (X//n): + #print(X//5) + return fx(X//n, n)+X//n + return 0 + +N=int(input()) +if N%2==1: + print(0) +else: + print(fx(N//2,5))" +p03827,s295866852,Wrong Answer,"s = input() +x = 0 +l_x = [] +for c in s: + x += 1 if c == 'I' else -1 + l_x.append(x) + +print(max(l_x))" +p02689,s220521785,Accepted,"N, M = list(map(int, input().split())) + +H = list(map(int, input().split())) + +notgoods = [False for _ in range(N)] + +for m in range(M): + a, b = list(map(int, input().split())) + if H[a - 1] <= H[b - 1]: + notgoods[a - 1] = True + if H[b - 1] <= H[a - 1]: + notgoods[b - 1] = True + +print(N - sum(notgoods)) +" +p02627,s453482600,Wrong Answer,"a=input() +if a.islower(): + print(""a"") +else: + print(""b"")" +p03494,s942428179,Accepted,"num = int(input()) +vals = list(input().split()) + +ivals = [] +for i in range(num): + ival = int(vals[i]) + ivals.append(ival) + +count = 0 +check_flag=0 + +def is_odd(n): + """""" 奇数判定関数 """""" + return (n%2) == 1 + +while check_flag==0: + for i in range(num): + if (ivals[i])%2 != 0: + check_flag=1 + break + else: + ivals[i]=ivals[i]/2 + + if check_flag==0: + count+=1 + +print(count)" +p02916,s895920692,Accepted,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) +b_dic = {} +for i in range(1, N + 1): + b_dic[i] = B[i - 1] +c_dic = {} +for i in range(1, N): + c_dic[i] = C[i - 1] +count=0 +br = -1 +for a in A: + count += b_dic[a] + if br == a - 1: + count += c_dic[br] + br = a +print(count) +" +p03565,s571857916,Wrong Answer,"S = list(input()) +T = input() +ls = [] + +for i in range(len(S)-len(T)): + for j in range(len(T)): + if S[i+j] != T[j] and S[i+j] != ""?"": + break + else: + ls.append(i) + +if ls: + for j in range(len(T)): + S[ls[-1]+j] = T[j] + print("""".join(S).replace(""?"", ""a"")) +else: + print(""UNRESTORABLE"") " +p02571,s256533697,Accepted,"S=input() +T=input() +LS=len(S) +LT=len(T) +ans=0 + +for i in range(LS-LT+1): + cnt=0 + kari=S[i:i+LT] + for j in range(LT): + if kari[j]==T[j]: + cnt+=1 + #print(kari,cnt,ans) + ans=max(cnt,ans) + +print(LT-ans)" +p03481,s371291649,Accepted,"def resolve(): + X, Y = [int(i) for i in input().split()] + cnt = 0 + while X <= Y: + cnt += 1 + X *= 2 + print(cnt) + + +resolve() +" +p03592,s622290554,Wrong Answer,"n, m, k = map(int, input().split()) + +for i in range(n): + for j in range(m): + if i * (m - j) + j * (n - i) == k: + print(""Yes"") + exit() + +print(""No"") " +p03359,s560930098,Accepted,"a,b = map(int,input().split()) +if a <= b: + print(a) +else: + print(a - 1)" +p02705,s260944249,Accepted,"import math + + +def main(): + r = int(input()) + print(2 * math.pi * r) + + +if __name__ == '__main__': + main() +" +p03612,s835543603,Wrong Answer,"N = int(input()) +p = list(map(int,input().split())) +ans = 0 +c = 0 +for i in range(N-1): + if p[i] == i+1: + c += 1 + else: + ans += (c+1)//2 + c = 0 +print(ans)" +p02792,s854907430,Wrong Answer,"n = int(input()) +d = [[0] * 10 for _ in range(10)] + +for i in range(1, n + 1): + s = str(i) + if s[-1] == '0': + continue + d[int(s[0])][int(s[-1])] += 1 + +result = 0 +for i in range(1, 10): + for j in range(1, 10): + result = d[i][j] * d[j][i] +print(result) +" +p03838,s624062156,Accepted,"x, y = map(int, input().split()) +print(min(y+~x+1, abs(y+x)+1) if x= x: + c -= 1 +print(c) +" +p02719,s670209010,Accepted,"N,K = map(int, input().split()) + +a = N%K +b = abs(a - K) + +lst = [] +lst.append(a) +lst.append(b) +print(min(lst)) +" +p03815,s384878744,Accepted,"def resolve(): + x = int(input()) + r = 0 + if x % 11 > 6: + r = 2 + elif x % 11: + r = 1 + + print((x // 11 * 2) + r) +resolve()" +p02897,s722099401,Accepted,"n=int(input()) +li=[i for i in range(1,n+1) if i%2==1] +s=len(li) +print(s/n)" +p02724,s174956034,Wrong Answer,"x = int(input()) +print((x//500*1000) + (x%1000//5*5))" +p03387,s312621785,Accepted,"a = list(map(int,input().split())) +a = sorted(a) +i = (a[1] - a[0])//2 +a[0] += i*2 +i += a[2] - a[1] +if a[0] != a[1]: + i += 2 + +print(i) + + +" +p02595,s190830724,Accepted,"n,d = map(int,input().split()) +l = [] +for i in range(n): + x,y = map(int,input().split()) + g = ((x**2)+(y**2))**0.5 + l.append(g) + +l.sort() +cnt = 0 +for i in l: + if i > d: + break + + cnt = cnt+1 + +print(cnt) +" +p04020,s513470216,Accepted,"n,*a=map(int,open(0).read().split()) +ans=0 +if n==1: + print(a[0]//2) + exit() +for i in range(n-1): + if (a[i]+a[i+1])%2==0: + ans+=(a[i]+a[i+1])//2 + a[i+1]=0 + else: + ans+=(a[i]+a[i+1])//2 + a[i+1]=(0 if a[i+1]==0 else 1) +print(ans)" +p02854,s567829231,Accepted,"from numpy import* +input();a=array(list(map(int,input().split()))) +print(int(min(abs(cumsum(a)-(sum(a)/2)))*2))" +p02707,s676099845,Accepted,"N=int(input()) +A_lis=list(map(int,input().split())) +p={i:0 for i in range(1,N+1)} +for j in A_lis: + p[j]+=1 + +for i in range(1,N+1): + print(p[i])" +p02780,s278008426,Wrong Answer,"import numpy as np +N,K = (int(x) for x in input().split()) +p1 = np.array(list(map(int, input().split()))) +p2 = (p1+1) / 2 +p3 = np.array([np.sum(p2[i:i+K],dtype=np.float32) for i in range(N-K+1)]) +print(np.amax(p3))" +p02814,s452855728,Wrong Answer,"def main(): + import sys + input = sys.stdin.readline + from fractions import gcd + + N, M = map(int, input().split()) + A = list(map(lambda x: int(x)//2, input().split())) + + l = 1 + for a in A: + l = l*a // gcd(l, a) + + # l の奇数倍がM*max(A)以下にいくつあるか + + if l < max(A): + ref = 1 + else: + ref = 0 + print((M//l + 1)//2-ref) + # print(ans) + + +if __name__ == ""__main__"": + main() +" +p03495,s608078388,Wrong Answer,"n,k = map(int,input().split()) +l = list(map(int, input().split())) +def counter(l): + count = {} + for i in l: + count[i] = l.count(i) + return sorted(count.values()) + +freq = counter(l) +print(len(freq) - k if len(freq)> k else 0)" +p02713,s825778245,Accepted,"n=int(input()) +import math +ans=0 +for i in range(1,n+1): + for j in range(1,n+1): + for k in range(1,n+1): + ans+=math.gcd(math.gcd(i,k),j) +print(ans)" +p02577,s644646911,Accepted,"N = int(input()) +N_str=str(N) +K=(len(str(N))) +S=0 +for i in range(K): + S += int(N_str[i]) + +if S%9==0: + print('Yes') +else: + print(""No"") " +p03075,s280387114,Accepted,"l = [int(input()) for i in range(6)] +print(['Yay!',':('][l[4]-l[0]>l[5]])" +p02664,s090556565,Accepted,"def resolve(): + T = input() + print(T.replace('?', 'D')) + +if __name__ == ""__main__"": + resolve()" +p02693,s592912224,Accepted,"K=int(input()) +A,B=map(int,input().split()) +flag=0 +for i in range(A,B+1): + if i%K==0: + flag=1 + + +if flag==1: + print('OK') + +else: + print('NG')" +p02754,s828829398,Wrong Answer,"# -*- coding: utf-8 -*- + +N, A, B = map(int, input().split()) + +q, mod = divmod(N, A + B) + +print((A * q) + max((mod - B), mod)) +" +p02702,s059298608,Accepted,"s=input()[::-1] +ans=0 +u=0 +d=1 +l=[0]*2019 +l[0]=1 +for i in map(int,s): + u=(u+i*d)%2019 + l[u]+=1 + d=d*10%2019 +for i in l: + ans+=i*(i-1)//2 +print(ans)" +p03131,s938020262,Accepted,"K, A, B = map(int, input().split()) +K += 1 + +if B-A <= 2: + print(K) +else: + num = max(0, (K-A)//2) + print(num*B+K-(A+2)*num) + +" +p02817,s118106753,Accepted,"s,t = input().split() +print(t+s)" +p03456,s614049105,Accepted,"import math +a,b = input().split() +number = int(a+b) +root = math.sqrt(number)//1 +if root**2 == number: + print(""Yes"") +else: + print(""No"")" +p02639,s533190458,Wrong Answer,"x = list(map(int, input().split())) + +for i in x: + if i == 0: + print(i+1) + break +" +p03861,s631212197,Wrong Answer,"a, b, x = map(int, input().split()) + +ans = (b // x) - (a // x) + +if a == 0: + ans += 1 + +print(ans)" +p02790,s316115260,Wrong Answer,"a, b = map(int, input().split()) +if a >= b: + print(b) +else: + print(a) +" +p02993,s553209333,Accepted,"from collections import Counter + +def main(): + s = input() + src = """" + for dst in s: + if dst == src: + print(""Bad"") + break + src = dst + else: + print(""Good"") + +if __name__ == ""__main__"": + main()" +p02660,s224432523,Wrong Answer,"import math +N = int(input()) +if N <= 1: + print(0) + exit() + +L = math.ceil(math.sqrt(N)) + 1 +isPrime = [True] * L +isPrime[0] = isPrime[1] = False +primes = [] +for n in range(2, L): + if isPrime[n]: + primes.append(n) + isPrime[2*n::n] = [False] * ((L-n-1) // n) + +ans = 0 +for p in primes: + d = p + while N % d == 0: + ans += 1 + N //= d + d *= p + +print(max(1, ans)) +" +p03854,s113525391,Accepted,"S = input() +Mozi = [""resare"",""esare"",""remaerd"",""maerd""] + +S = S[::-1] +for i in Mozi: + S = S.replace(i,"""") +if not S: + print(""YES"") +else: + print(""NO"")" +p02694,s354197255,Accepted,"n = int(input()) +now = 100 +ans = 0 +while now < n: + now = int(now * 1.01) + ans += 1 +print(ans)" +p02702,s416295852,Wrong Answer,"S = input() + +n = len(S) +ans = 0 +for i in range(n-1): + for j in range(i+1, n): + if int(S[i:j]) % 2019 == 0: + ans += 1 + +print(ans)" +p02572,s481231293,Accepted,"N = int(input()) +A = [int(v) for v in input().split()] +MOD = int(1e9 + 7) + +S = sum(A) +SQ = S * S +IS = sum(a*a for a in A) + +print(((SQ - IS) // 2) % MOD)" +p03469,s235924508,Accepted,"s = input() +s = s.replace('2017','2018') +print(s)" +p02909,s984474187,Accepted,"S = input() + +if S == 'Sunny': + print('Cloudy') +elif S == 'Cloudy': + print('Rainy') +else: + print('Sunny') +" +p02881,s378596388,Wrong Answer,"import math + +n = int(input()) +for i in range(1, math.ceil(n**0.5)): + if n % i == 0: + ans = n//i + i - 2 + +print(ans)" +p02793,s277404571,Accepted,"def gcd(a,b): + while b!=0: + a,b=b,a%b + return a + +def lcm(a,b): + return a*b//gcd(a,b) + +N = int(input()) +A = list(map(int, input().split())) + +lcm_A = 1 +for i in range(N): + lcm_A = lcm(lcm_A, A[i]) + +ans = 0 +for i in range(N): + ans += lcm_A // A[i] + +mod = 10**9+7 +print(ans % mod) +" +p03386,s499767089,Accepted,"n,m,k=map(int,input().split()) +if(k>=m-n): + for i in range(n,m+1): + print(i) +else: + l=list(range(n,n+k)) + d=list(range(m-k+1,m+1)) + s=l+d + s=list(set(s)) + s.sort() + for i in s: + print(i) +" +p02732,s014475199,Accepted,"n = int(input()) +A = list(map(int, input().split())) +cnt = [0]*n +for a in A: + cnt[a-1] += 1 +ans = 0 +for i in range(n): + ans += cnt[i] * (cnt[i]-1) // 2 +for a in A: + print(ans-cnt[a-1]+1)" +p03495,s011893461,Accepted,"import collections + +N,K=map(int,input().split()) +A=list(map(int,input().split())) + +check=collections.Counter(A).most_common() +ans=0 +for i in range(K,len(check)): + ans+=check[i][1] +print(ans) +" +p03285,s495770465,Wrong Answer,"a = int(input()) +b = a%7 +b = a%4 + +c = a%4 +c = c%7 +if b == 0: + print('Yes') +elif c ==0: + print('Yes') +else: + print('No')" +p03416,s333786892,Accepted,"N = {} #10000以上key以下の回文数の個数 +cnt = 0 +for i in range(10000, 100000): + L = list(str(i)) + if L == list(reversed(L)): + cnt += 1 + N[i] = cnt +A, B = map(int, input().split()) +print(N[B]-N[A-1] if A > 10000 else N[B])" +p02911,s226828080,Accepted,"import sys +n,k,q = map(int,input().split()) +if k > q: + for _ in range(n): + print(""Yes"") + sys.exit() +p = [0 for i in range(n)] + +for __ in range(q): + number = int(input()) + p[number - 1] += 1 + +for x in range(n): + if k - q + p[x] >= 1: + print(""Yes"") + else: + print(""No"") +" +p02791,s202126728,Accepted,"n = int(input()) +li = [int(x) for x in input().split()] +ans = 1 +m = li[0] +for i in range(1,n): + if m>li[i]: + m = li[i] + if m==li[i]: + ans += 1 +print(ans)" +p02917,s808352652,Wrong Answer,print(input().split()) +p02797,s969281143,Accepted,"n, k, s = map(int, input().split()) +print(*[s] * k + [s % 10**9 + 1] * (n - k)) + +" +p02618,s570426680,Accepted,"d = int(input()) +c = list(map(int, input().split())) +prev = [0] * 26 +# 毎日コストの最小化を試みてみる +for i in range(d): + s = list(map(int, input().split())) + cost = 10 ** 10 + ans = -1 + for j in range(26): + tmp = 0 + for k in range(26): + if j == k: + continue + tmp += c[k] * (i - prev[k]) + if tmp < cost: + cost = tmp + ans = j + prev[ans] = i + print(ans+1) +" +p03131,s546923999,Wrong Answer,"K,A,B = map(int,input().split()) + +if K < (A+B+2) or B <= A+2: + print(K+1) + exit(0) + +K -= A - 1 +p,q = divmod(K,2) +ans = B * p + q +print(ans)" +p03419,s867390294,Accepted,"a,b=map(int,input().split()) +if min(a,b)>=3: + print( (a-2)*(b-2)) + exit() +if a>b: a,b=b,a +if a==1 and b>=3: + print(b-2) +if a==2 and b>=3: + print(0) + + +if [a,b]==[1,1]: + print(1) +if [a,b]==[1,2]: + print(0) +if [a,b]==[2,2]: + print(0)" +p02615,s335210102,Accepted,"n = int(input()) +a = list(map(int, input().split())) +a.sort(reverse=True) +ans = 0 +for i in range(n): + ans += a[i//2] + +ans -= a[0] +print(ans)" +p03474,s012914788,Accepted,"a, b = map(int, input().split()) +s = input() +y = s.split(""-"") + +if len(y[0]) == a and len(y[1]) == b and s[a] == ""-"": + print(""Yes"") +else: + print(""No"")" +p03485,s796992062,Accepted,"a,b = map(int, input().split()) +print((a+b)//2 + (a+b)%2)" +p03471,s326816098,Wrong Answer,"billNum, Declation = map(int, input().split()) +bill10000 = -1 +bill5000 = -1 +bill1000 = -1 + +for x in range(billNum + 1): + for y in range(billNum + 1): + z = billNum - x - y + sumOfMoney = x * 10000 + y * 5000 + z * 1000 + if Declation == sumOfMoney: + bill10000 = x + bill5000 = y + bill1000 = z + break + +print(bill10000, bill5000, bill1000)" +p03836,s780875350,Wrong Answer,"sx, sy, tx, ty = map(int, input().split()) +route = """" +dx, dy = tx - sx, ty - sy +path1 = ""R"" * dx + ""U"" * dy +path2 = ""L"" * dx + ""D"" * dy +dx, dy = dx + 1, dy + 1 +path3 = ""D"" + ""R"" * dx + ""U"" * dy + ""L"" +path4 = ""U"" + ""L"" * dx + ""D"" * dy + ""R"" +ans =path1 + path2 + path3 + path4 +if ans.count(""R"")+ans.count(""U"") == ans.count(""L"") + ans.count(""D""): + print(""Yes,"", ans) +else: + print(""No,"", ans)" +p02880,s047773393,Accepted,"n = int(input()) +cnt = 0 + +for i in range(1, 10): + if len(str(n//i)) == 1 and n%i == 0: + cnt +=1 + +if cnt >= 1: + print('Yes') +else : + print('No') +" +p04011,s324242809,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) +if n - k > 0: + print(x * k + y * (n - k)) +else: + print(x * n)" +p03419,s745490080,Wrong Answer,"n,m = map(int,input().split()) +if n == 1 and m == 1: + print (1) +elif n == 1 and m != 1: + print (m-2) +else: + print ((n-2)*(m-2)) +" +p03680,s744816015,Accepted,"N=int(input()) +a=[int(input()) for i in range(N)] +count=0 +tmp=1 +while count<=N: + if a[tmp-1] ==2: + print(count+1) + break + else: + count+=1 + tmp = a[tmp-1] +if count > N: + print(-1)" +p03160,s336297219,Accepted,"n = int(input()) +h = list(map(int, input().split())) +dp = [float(""Inf"")] * (n + 1) + +dp[0] = 0 +for i in range(1, n): + dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i - 1])) + if i > 1: + dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i - 2])) + +print(dp[n - 1])" +p02661,s919223838,Accepted,"N = int(input()) +A = [] +B = [] + +for _ in range(N): + a, b = list(map(int, input().split())) + A.append(a) + B.append(b) + +A.sort() +B.sort() + +if N % 2 == 1: + print(B[N//2] - A[N//2] + 1) +else: + a0 = A[N//2 - 1] + b0 = B[N//2 - 1] + a1 = A[N//2] + b1 = B[N//2] + + print((b1 + b0) - (a1 + a0) + 1) +" +p02639,s853261702,Wrong Answer,"xs = map(int, input().split()) + +for x, i in enumerate(xs): + if x == 0: + ans = i + 1 + +print(ans) +" +p02642,s170677126,Wrong Answer,"import copy + +N=int(input()) +A=list(map(int,(input().split()))) +new_A=list(set(A)) +new_A.sort() +tmp_A = copy.copy(new_A) +count=0 +try: + for i in new_A[:]: + tmp_A.remove(i) + for j in tmp_A[:]: + + if(i%j==0): + new_A.remove(i) + tmp_A=copy.copy(new_A) + + if(len(new_A)==1): + print(0) + else: + print(len(new_A)) +except: + print(len(new_A))" +p02683,s446940925,Accepted,"n,m,x = map(int, input().split()) +a = [list(map(int, input().split())) for i in range(n)] +ans = 10**9 +for i in range(2 ** n): + skill = [0] * m + overTen = False + money = 0 + for j in range(n): + if ((int(bin(i)[2:]) >> j) & 1): + money += a[j][0] + for h in range(m): + skill[h] += a[j][h+1] + for k in skill: + if k >= x: + overTen = True + else: + overTen = False + break + if overTen == True: + if money < ans: + ans = money + +if ans == 10**9: + print(-1) +else: + print(ans)" +p02842,s392297711,Accepted,"import math + +N = int(input()) + +n = N / (1.08) + +n0 = math.floor(n) - 1 +n1 = math.floor(n) +n2 = math.ceil(n) + +if int(n0 * 1.08) == N: + print(n0) +elif int(n1 * 1.08) == N: + print(n1) +elif int(n2 * 1.08) == N: + print(n2) +else: + print("":("")" +p03803,s606357123,Wrong Answer,"a, b = map(int, input().split()) +if a == 1: + a = 14 +elif b == 1: + b = 14 +if a > b: + print('Alice') +elif b > a: + print('Bob') +else: + print('Draw') +" +p03592,s501469756,Wrong Answer,"n,m,k = map(int, input().split()) +for i in range(n): + for j in range(m): + if i*(m-j)+j*(n-i)==k: + print('Yes') + exit() +print('No')" +p02612,s086666795,Wrong Answer,"n = int(input()) +if n%1000 <= 500: + print(n%1000) +else: + print(1000-n%1000)" +p03127,s592313012,Accepted,"def gcd(a, b): + while b: + a, b = b, a % b + return a + +N = int(input()) +l = list(map(int, input().split())) +ans = l[0] +for i in range(1, N): + ans = gcd(ans, l[i]) +print(ans)" +p02861,s345817545,Accepted,"from itertools import permutations + +n = int(input()) +towns = [tuple(map(int, input().split())) for _ in range(n)] + + +def dist(i, j): + return ((towns[i][0] - towns[j][0])**2 + + (towns[i][1] - towns[j][1])**2)**0.5 + + +ans = cnt = 0 +for perm in permutations(range(n)): + cand = 0 + for i in range(n - 1): + cand += dist(perm[i], perm[i + 1]) + ans += cand + cnt += 1 + +ans /= cnt +print(ans) +" +p03250,s405629126,Accepted,"a=list(map(int,input().split())) +a.sort() +print(a[2]*10+a[1]+a[0])" +p03284,s340008530,Wrong Answer,"a,b = map(int,input().split()) +print(a%b) +" +p03854,s680907282,Accepted,"s=input().strip() +s=s.replace(""eraser"",""A"") +s=s.replace(""erase"",""A"") +s=s.replace(""dreamer"",""A"") +s=s.replace(""dream"",""A"") +print(""YES"" if not s.replace(""A"","""") else ""NO"")" +p03611,s105962517,Accepted,"def resolve(): + n = int(input()) + a = list(map(int, input().split())) + t = [0]*(10**5+2) + for i in a: + t[i] += 1 + t[i+1] += 1 + if i-1 >= 0: + t[i-1] += 1 + print(max(t)) +resolve()" +p03407,s455698575,Accepted,"A, B, C = map(int, input().split()) +if A+B-C >= 0: + print(""Yes"") +else: + print(""No"")" +p03693,s241798381,Accepted,"r, g, b = map(int, input().split()) + +answer = r * 100 + g * 10 + b + +if answer % 4 == 0: + print(""YES"") +else: + print(""NO"")" +p02707,s044463979,Accepted,"def main(): + + num = int(input()) + boss = input().split() + + ans_list = [0] * num + + for i_boss in boss: + #print(f'start for {i_boss}') + ans_list[int(i_boss)-1] += 1 + a = list(map(lambda x: str(x), ans_list)) + print('\n'.join(a)) + + +if __name__ == '__main__': + main()" +p03210,s844459874,Wrong Answer,"# input +X = int(input()) + +# check +if X in [7, 5, 3]: + print(""Yes"") +else: + print(""No"")" +p03555,s782139965,Wrong Answer,"import sys + +a = input() +b = input() + +for i in range(2): + if a[i] != b[2 - i]: + print(""NO"") + sys.exit() +print(""YES"")" +p03486,s364061612,Wrong Answer,"s = sorted(input()) +t = sorted(input()) +print(""Yes"" if s= K: + print(K) +elif A + B >= K: + print(A) +else: + print(A + (A+B-K)) +" +p02720,s534990827,Accepted,"K=int(input()) +queue=[1,2,3,4,5,6,7,8,9] +i=0 +flag=1 +while(flag==1): + if K<=len(queue): + flag=0 + break + else: + + x=queue[i] + if x % 10!=0: + queue.append(x*10+(x%10)-1) + queue.append(10*x+(x%10)) + + if x%10!=9: + queue.append(10*x+(x%10)+1) + + + i+=1 + + + +print(queue[K-1]) + +" +p02602,s467545486,Accepted,"n,k=map(int,input().split()) +A=list(map(int,input().split())) +for i in range(n-k): + print('Yes' if A[i]'2019/04/30' else 'Heisei') +" +p03285,s593516920,Accepted,"n = int(input()) +f = True + +if n%7 == 0: + print(""Yes"") + f = False + +while(n > 0)and(f): + if(n%4 == 0): + print(""Yes"") + f = False + n -= 7 +if(f): + print(""No"")" +p02676,s743962625,Wrong Answer,"K = int(input()) +S = input() +print(len(S)) +if len(S) <= K: + print(S) +else: + print(f""{S[:K]}..."")" +p02786,s775592700,Accepted,"ni = lambda: int(input()) +nm = lambda: map(int, input().split()) +nl = lambda: list(map(int, input().split())) + +h = ni() + + + +def atk(n): + if n==0: + return 1 + + n //=2 + return atk(n)*2 + +print(atk(h)-1) + +" +p03012,s058262205,Accepted,"N = int(input()) +W = list(map(int, input().split())) +R = [0]*N +R[0] = W[0] + +for i in range(1, N): + R[i] = R[i-1] + W[i] + +#print(R) +m = sum(W) / 2 +#print(m) +e = 10000 + +for i in range(N): + e_new = abs(R[i] - m) + if e >= e_new: + e = e_new + #print(e) + else: + ans_index = i - 1 + #print(ans_index, e) + break + +print(int(2 * abs(R[ans_index] - m)))" +p03665,s821409303,Accepted,"import numpy as np +n,p = map(int,input().split()) +A = np.array(list(map(int,input().split()))) +flg = np.all(A%2==0) +print( 2**n if flg and p==0 else 0 if flg else 2**(n-1))" +p03696,s453249391,Accepted,"n = int(input()) +s = input() + +tmp = 0 +a = 0 +for i in s: + if i == ""("": + tmp -= 1 + else: + tmp += 1 + a = max(a, tmp) +ans = a * ""("" + s +print(ans + "")"" * (ans.count(""("") - ans.count("")"")))" +p02615,s310363511,Accepted,"import sys +input = sys.stdin.readline + +#n = int(input()) +#l = list(map(int, input().split())) + +''' +a=[] +b=[] +for i in range(): + A, B = map(int, input().split()) + a.append(A) + b.append(B)''' + + +n=int(input()) +a=list(map(int,input().split())) +a.sort() +#print(a) +ans=0 +from math import floor +for i in range(1,n): + ans+=a[n-1-floor(i/2)] + #print(ans) +print(ans) +" +p02697,s096865275,Accepted,"n,m=map(int,input().split()) +for i in range(m//2): + print(1+i,m//1-i) +for i in range((m+1)//2): + print(m//1+1+i,m*2+1-i)" +p02607,s863703733,Accepted,"N = input() +del N +I1 = input().split(); i = 0 +for a in range(len(I1)): + if (int(I1[a]) * (a+1))%2 == 1: + i += 1 +print(i)" +p03127,s345164305,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +def uclid(x, y): + if(y == 0): + return x + tmp = y + y = x % y + x = tmp + return uclid(x, y) + +ans = A[0] +for i in range(1, N): + ans = uclid(ans, A[i]) +print(ans)" +p02642,s342718194,Accepted,"import sys + +n = int(input()) +A = list(map(int, input().split())) +A.sort() + +if len(A) == 1: + print(1) + sys.exit(0) + +box = [False] * (A[-1] + 1) +for a in A: + box[a] = True + +for idx, a in enumerate(A): + if A[idx] == A[idx - 1]: + box[a] = False + for j in range(2, A[-1]//a + 1): + box[a * j] = False + +count = 0 +for d in box: + if d: + count += 1 +print(count) +" +p02772,s538273256,Accepted,"n = int(input()) +data = input().split() + +ans = ""APPROVED"" + +for i in range(n): + num = int(data[i]) + if num % 2 == 0: + if num % 3 != 0 and num % 5 != 0: + ans = ""DENIED"" + break + +print(ans) +" +p03408,s175987292,Accepted,"N=int(input()) +m = {} +for i in range(N): + s = input() + if s in m: + m[s] += 1 + else: + m[s] = 1 +M=int(input()) +for i in range(M): + t = input() + if t in m: + m[t] -= 1 + else: + m[t] = -1 +ans = 0 +for k,v in m.items(): + ans = max( ans, v ) +print(ans)" +p02918,s755056929,Wrong Answer,"N, K = map(int, input().split()) +S = input() +X = S.count(""RL"") +Y = 0 +if S[0] == ""L"": + Y += 1 +if S[-1] == ""R"": + Y += 1 + +ans = 0 +for a, b in zip(S, S[1:]): + if a == b: + ans += 1 +ans += 2*min(K, X) +if K > X: + ans += min(Y, K-X) +print(ans) +" +p03239,s580997335,Accepted,"n,t = map(int, input().split()) +ans = 1001 +for _ in range(n): + a,b = map(int, input().split()) + if (b <= t): ans = min(ans,a) +print(ans if ans <= 1000 else ""TLE"")" +p02948,s433504554,Accepted,"import heapq + +N, M = map(int, input().split()) +AB = [list(map(int, input().split())) for i in range(N)] +AB.sort() + +ans = 0 +candidates = [] +now = 0 +for i in range(M+1): + for j in range(now, N): + if AB[j][0] <= i: + heapq.heappush(candidates, -AB[j][1]) + now = j + 1 + + else: + now = j + break + + if candidates: + ans -= heapq.heappop(candidates) + +print(ans)" +p03243,s750927753,Wrong Answer,"n = input() +maximum = 0 +for c in n: + maximum = max(maximum, int(c)) + +ans = [str(maximum)] * 3 +print(''.join(ans)) +" +p02681,s458822698,Wrong Answer,"S = input() +T = input() +if S in T: + print('Yes') +else: + print('No')" +p03284,s885261191,Accepted,"#k = int(input()) +#s = input() +#a, b = map(int, input().split()) +#s, t = map(str, input().split()) +#l = list(map(int, input().split())) +#l = [list(map(int,input().split())) for i in range(n)] +#a = [list(input()) for _ in range(n)] +#a = [int(input()) for _ in range(n)] + +n,k = map(int, input().split()) + +if (n%k==0): + print(0) +else: + print(1) + +" +p03160,s855591084,Accepted,"n = int(input()) +h = list(map(int, input().split())) +p0, p1 = 0, abs(h[1] - h[0]) +for i in range(2, n): + p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2])) + p0, p1 = p1, p2 +print(p1) +" +p03475,s766271291,Accepted,"N = int(input()) +a = N*[0] + +for i in range(1,N): + C,S,F = map(int,input().split()) + for j in range(i): + a[j] = max(S,((F+a[j]-1)//F)*F)+C + +print(*a,sep=""\n"")" +p02606,s381002736,Wrong Answer,"l,r,n = map(int, input().split()) +L = l//n +R = r//n +print(R-L)" +p02859,s265252281,Accepted,"N = int(input()) +print(N*N)" +p03759,s951857489,Accepted,"a, b, c = map(int, input().split()) +if a + c == 2 * b: + print(""YES"") +else: + print(""NO"") + " +p03611,s914705469,Accepted,"N = int(input()) +a = sorted([int(c) for c in input().split()]) +#2回の変わり目を記憶 +c1,c2,c3 = [0,0,0] +ma = 1 +for i in range(N): + if i > 0: + if a[i]==a[i-1]+1: + c1 = c2 + c2 = c3 + c3 = i + elif a[i]!=a[i-1]: + c1,c2,c3=[i,i,i] + if ma < i - c1+1: + ma = i - c1+1 + +print(ma)" +p03804,s273888981,Accepted,"n,m = map(int,input().split()) +a = [list(input()) for i in range(n)] +b = [list(input()) for i in range(m)] +ans = 'No' +for i in range(n-m+1): + for j in range(n-m+1): + ok = True + for k in range(m): + for l in range(m): + if a[i+k][j+l]!=b[k][l]: + ok = False + if ok: ans = 'Yes' +print(ans)" +p04044,s471940528,Accepted,"N,L=map(int,input().split()) +S=[] +for i in range(N): + S.append(input()) + +S=sorted(S) +for i in range(N): + print(S[i],end="""")" +p03624,s378433879,Accepted,"S = input() +alphabet = set([chr(i) for i in range(97, 97+26)]) +ans = alphabet - set(list(S)) +print(sorted(ans)[0]) if len(ans) > 0 else print('None')" +p03419,s204371442,Accepted,"n,m=map(int,input().split()) +if n==1 and m==1: + print(1) +elif n==1 or m==1: + print(max(0,max(n,m)-2)) +else: + print((n-2)*(m-2))" +p03161,s152586500,Accepted,"from sys import stdin,stdout + +st=lambda:list(stdin.readline().strip()) +li=lambda:list(map(int,stdin.readline().split())) +mp=lambda:map(int,stdin.readline().split()) +inp=lambda:int(stdin.readline()) +pr=lambda n: stdout.write(str(n)+""\n"") + +mod=1000000007 +INF=float('inf') + +n,k=mp() +l=li() +dp=[INF for i in range(n)] +dp[0]=0 + +for i in range(n): + + for j in range(i+1,min(i+k+1,n)): + + dp[j]=min(abs(l[i]-l[j])+dp[i],dp[j]) + +print(dp[-1]) + + +" +p03262,s582264370,Accepted,"import fractions +a = list(map(int,input().split())) +N = a[0] +b = [] +x = list(map(int,input().split())) +x.append(a[1]) +x.sort() +flag = 0 +for i in range(N): + c = x[i+1] - x[i] + if flag == 1: + ans = fractions.gcd(c, ans) # 最大公約数を求める + else: + ans = c # 数列が一つの場合は差が答え + b.append(c) + flag = 1 +print(ans)" +p02831,s767058696,Accepted,"def gcd(x, y): + if x == 0: + return y + else: + return gcd(y % x, x) + + +def lcm(x, y): + return x * y // gcd(x, y) + + +a, b = map(int, input().split()) + +print(lcm(a, b)) + +" +p02714,s871242436,Wrong Answer,"n = int(input()) +s = str(input()) + +count = 0 +for i in range(0,n-3): + for j in (i+1,n-2): + for k in (j+1,n-1): + if s[i]!=s[j] and s[j]!=s[k] and s[j]!=s[k] and j-i != k-j: + count += 1 + +print(count) +" +p03767,s567134402,Accepted,"N = int(input()) +a_list = [int(e) for e in input().split()] +a_list.sort(reverse=True) +a_list = [0] + a_list +ans_list= list() + +for i in range(1,len(a_list)): + if i%2 == 0: + ans_list.append(a_list[i]) + if len(ans_list) == N: + print(sum(ans_list)) + break" +p03379,s812373169,Accepted,"n = int(input()) +X = list(map(int,input().split())) +Xs = sorted(X) +bottom = Xs[n//2-1] +top = Xs[n//2] +for i in X: + if i <= bottom: + print(top) + else: + print(bottom) +" +p03338,s856013813,Accepted,"N = int(input()) +S = input() + +lans = list() +for i in range(1, N): + sa = S[:i] + sb = S[i:] + l = list() + cnt = 0 + for j in range(i): + if S[j] in sb and S[j] not in l: + l.append(S[j]) + cnt += 1 + lans.append(cnt) + +print(max(lans))" +p03241,s394680208,Accepted,"n,m = map(int,input().split()) +ans = 1 +for i in range(1,int(m**0.5)+1): + if m%i!=0:continue + if m//i>=n: + ans = max(i,ans) + if i>=n: + ans = max(m//i,ans) + +print(ans)" +p02820,s748983937,Wrong Answer,"N, K = map(int, input().split()) +R, S, P = map(int, input().split()) +T = input() + +res = [0]*N +hands = [""r"", ""s"", ""p""] + +for i in range(N): + res[i] = hands[hands.index(T[i])-1] + +for i in range(N): + if i >= K and res[i-K] == res[i]: + res[i] = 0 + +score = R*res.count(""r"") + S*res.count(""s"") + P*res.count(""p"") +print(res) +print(R*res.count(""r""), S*res.count(""s""), P*res.count(""p"")) +print(score) +" +p02553,s057598213,Accepted,"a = list(map(int,input().split())) + +result =[] +result.append(a[0] * a[2]) +result.append(a[0] * a[3]) +result.append(a[1] * a[2]) +result.append(a[1] * a[3]) +print(max(result)) + +" +p03017,s788216293,Accepted,"N, A, B, C, D = map(int, input().split()) +S = '.' + input() + + +def solve(): + if '##' in S[A:C + 1] or '##' in S[B:D + 1]: + return 'No' + + if C > D: + if '...' not in S[B - 1:D + 2]: + return 'No' + + return 'Yes' + + +print(solve()) +" +p02688,s103911921,Accepted,"N, K = map(int, input().split()) +sunuke = set([x for x in range(1,N+1)]) +for k in range(K): + d = int(input()) + A = list(map(int, input().split())) + sunuke.difference_update(A) + +print(len(sunuke))" +p03803,s210183302,Accepted,"A, B = [int(_) for _ in input().split()] +if A == B: + print('Draw') +else: + if A == 1: + print('Alice') + elif B == 1: + print('Bob') + elif A > B: + print('Alice') + elif B > A: + print('Bob') +" +p02628,s934418653,Accepted,"N, K = map(int, input().split()) +PS = list(map(int, input().split())) +PS.sort() +print(sum(PS[:K])) +" +p02689,s902939735,Accepted," +N,M = map(int,input().split()) +H = list(map(int,input().split())) +ans = [0]*N + + +visited = [0]*N +for i in range(M): + a,b = map(int,input().split()) + visited[a-1] = 1 + visited[b-1] = 1 + if H[a-1] b: + if (a-1) > (n-b): + ans = (n-a) + (a-b-1)//2 + 1 + else: + ans = (b-1) + (a-b-1)//2 + 1 + if b > a: + if (b-1) > (n-a): + ans = (n-b) + (b-a-1)//2 + 1 + else: + ans = (a-1) + (b-a-1)//2 + 1 + +print(ans)" +p02766,s696227835,Accepted,"def main(): + n,m = map(int,input().split()) + ans = 1 + while n >= m: + n = (n-n%m) // m + ans += 1 + print(ans) + +if __name__ == '__main__': + main()" +p03284,s770991712,Wrong Answer,"a,b=map(int,input().split()) +if a%b==0: + print(0) +else: + print(a//b-a%b)" +p03723,s479070897,Accepted,"a,b,c = map(int,input().split()) + +count=0 +while a%2==0 and b%2==0 and c%2==0: + if (b/2+c/2)==(a/2+c/2)==(a/2+b/2): + count=-1 + break + a,b,c = b/2+c/2,a/2+c/2,a/2+b/2 + count+=1 +print(count) +" +p03095,s478450416,Accepted,"a=int(input()) +b=input() +b=list(b) +c=[0]*26 +ans=0 +t=0 +for i in range(a): + c[ord(b[i])-97]=c[ord(b[i])-97]+1 + +for j in range(26): + t=c[j] + for k in range(j+1,26): + t=t*(c[k]+1) + ans=ans+t +print(ans%(10**9+7))" +p02819,s578219091,Accepted,"X = int(input()) + +while True: + + flag = 0 + + for i in range(2, X): #2からX-1までのループ + if X % i == 0: #対象はXという数 + flag = 1 + break + if flag == 1: + X += 1 + continue + break + +print(X)" +p03639,s243550758,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +d4=len([i for i in A if i%4==0]) +d2=len([i for i in A if i%2==0 and i%4!=0]) + +N=N-(d4*2+1) +if N==1 and d2>=2: + N=0 +elif N>=2 and N-d2<=0: + N=0 + +print(""Yes"" if N<=0 else ""No"") +" +p03456,s920277120,Wrong Answer,"if __name__ == '__main__': + b, c = map(int, input().split()) + a = int(str(b)+str(c)) + + for i in range(1,101): + if a % (i*i) == 0: + print(""Yes"") + break + elif a < i* i: + print(""No"") + break +" +p02676,s135632643,Wrong Answer,"a = int(input()) +b = input() +print(b[:a]+'...')" +p02771,s886767827,Wrong Answer,"a, b, c = map(int, input().split()) +if(a==b or b==c or c==a and not (a==b and b==c)):print(""Yes"") +else:print(""No"")" +p02571,s417379614,Wrong Answer,"S = str(input()) +T = str(input()) +ans = 1000 +for i in range(len(S) - len(T)): + c = 0 + for j in range(len(T)): + if S[i] != T[j]: + c += 1 + i += 1 + ans = min(ans, c) +print(ans)" +p03323,s314292703,Accepted,"A, B = map(int, input().split()) +cake = [0]*16 +for i in range(A): + try: + cake[i*2] = 1 + except: + print(':(') + exit() +for i in range(B): + try: + cake[(i*2)+1] = 1 + except: + print(':(') + exit() +print('Yay!')" +p02688,s668365790,Wrong Answer,"n, k = map(int, input().split()) +a = [] +d = [] +for i in range(k): + d.append(int(input())) + a.extend(list(map(int, input().split()))) + +n_set = {i for i in range(1, n)} + +a_set = set(a) + +difference = n_set - a_set + +print(len(difference))" +p03387,s560734376,Accepted,"l=list(map(int,input().split())) +a=max(l)*3-sum(l)+1 +print(a//2 if a%2 else a//2+1)" +p03997,s895947448,Accepted,"def I(): return int(input()) +print((I()+I())*I()//2)" +p02785,s666773263,Wrong Answer,"n, k = map(int, input().split()) +data = list(map(int, input().split())) + +max = max(data) +sum = sum(data) + +print(sum - max) +" +p03544,s220059185,Accepted,"#!/usr/bin/env python +# coding: utf-8 + +# In[2]: + + +N = int(input()) + + +# In[12]: + + +def lucas(n): + mylist = [2,1] + for i in range(2,n+1): + mylist.append(mylist[i-1]+mylist[i-2]) + return mylist[n] + + +# In[14]: + + +print(lucas(N)) + + +# In[ ]: + + + + +" +p02818,s862771583,Wrong Answer,"a,b,k=map(int,input().split()) +if a>k:a=a-k +if a<=k: + b=b+(a-k) + a=0 +elif a==0 and b==0: + a=0 + b=0 +print(a,b)" +p03645,s199929007,Accepted,"N,M=map(int,input().split()) +S=[] +G=[] +for i in range(M): + x,y=map(int,input().split()) + if x==1: + S.append(y) + if y==N: + G.append(x) +if S==[] or G==[]: + print(""IMPOSSIBLE"") + exit() +S=set(S) +G=set(G) +T=len(S)+len(G) +k=len(G) +S=list(S) +G=list(G) +for i in range(k): + S.append(G[i]) +U=len(set(S)) +if T!=U: + print(""POSSIBLE"") +else: + print(""IMPOSSIBLE"")" +p02595,s668369318,Accepted,"import math + +N, M = map(int, input().split()) +P = [tuple(map(int, input().split())) for i in range(N)] + +ans = 0 + +for i in range(N): + d = math.sqrt(P[i][0]**2 + P[i][1]**2) + if d <= M: + ans += 1 + +print(ans) +" +p02755,s732456906,Wrong Answer,"A, B = map(int, input().split()) + +x1 = 25*A//2 +x2 = 25*(A+1)//2 +x3 = 10*B +x4 = 10*(B+1) + +if x1 <= x3 and x3 < x2: + print(x3) +elif x3 <= x1 and x1 < x4: + print(x1) +else: + print(-1) + " +p03380,s197877086,Accepted,"import sys +from bisect import bisect_left +def input(): return sys.stdin.readline().strip() + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + A.sort() + if N == 2: + print(A[1], A[0]) + return + idx = bisect_left(A, A[-1] // 2) + a = A[idx] + if idx > 0 and (A[idx] - A[-1] / 2) > (A[-1] // 2 - A[idx - 1]): + a = A[idx - 1] + print(A[-1], a) + + +if __name__ == ""__main__"": + main() +" +p03327,s267588832,Accepted,"n = int(input()) +print('ABC' if n<1000 else 'ABD') +" +p03437,s375817037,Accepted,"x, y = map(int, input().split()) +i = 1 +if x % y == 0: + print(-1) +else: + print(x * y - x)" +p04034,s744121583,Accepted,"n, m = map(int, input().split()) +l = [1 for i in range(n+1)] +b = [False for i in range(n+1)] +l[1] = 1 +b[1] = True +for i in range(m): + x, y = map(int, input().split()) + if b[x] == True: + if l[x] == 1: + b[x] = False + b[y] = True + l[x] -= 1 + l[y] += 1 +cnt = 0 +for i in range(1, n+1): + if b[i] == True: + cnt += 1 +print(cnt)" +p03695,s414618345,Accepted,"n = int(input()) +a = list(map(int, input().split())) +color = [0] * 8 +cnt = 0 +for i in a: + if i < 400: + color[0] = 1 + elif i < 800: + color[1] = 1 + elif i < 1200: + color[2] = 1 + elif i < 1600: + color[3] = 1 + elif i < 2000: + color[4] = 1 + elif i < 2400: + color[5] = 1 + elif i < 2800: + color[6] = 1 + elif i < 3200: + color[7] = 1 + else: + cnt += 1 +if color.count(1) == 0: + print(1, cnt) +else: + print(color.count(1), color.count(1) + cnt)" +p03163,s702518757,Wrong Answer,"import numpy as np + +N, W = map(int, input().split()) +wv = np.array([[int(i) for i in input().split()] for j in range(N)]) + +max_v = 10**3*(N+1) +dp = np.full([N+1,max_v], np.inf) +dp[0,0] = 0 + +for i in range(N): + # 遷移元なし + dp[i+1,:wv[i,1]] = dp[i,:wv[i,1]] + # 遷移元あり + dp[i+1,wv[i,1]:] = np.minimum(dp[i,wv[i,1]:], dp[i,:max_v-wv[i,1]]+wv[i,0]) + +print(np.max(np.where(dp <= W)))" +p02613,s514071225,Accepted,"n=int(input()) +d=dict() +a=[""AC"",""WA"",""TLE"",""RE""] +for x in a: + d[x]=0 +for _ in range(n): + d[input()]+=1 +for x in a: + print(x + "" x "" + str(d[x]))" +p03803,s407801531,Accepted,"a,b=map(int,input().split()) +if a==b: + print(""Draw"") +elif a==1: + print(""Alice"") +elif b==1: + print(""Bob"") +elif a>b: + print(""Alice"") +else: + print(""Bob"")" +p03042,s366259675,Accepted,"S = input() +left = int(S[:2]) +right = int(S[2:]) +year_flag = [0, 0] + +if left > 12 or left == 0: + year_flag[0] += 1 +if right > 12 or right == 0: + year_flag[1] += 1 + +if sum(year_flag) == 2: + print('NA') +elif sum(year_flag) == 0: + print('AMBIGUOUS') +elif year_flag[0] == 1: + print('YYMM') +else: + print('MMYY') +" +p03211,s693621348,Accepted,"s = input() +l = [] +for i in range(len(s)-2): + a = abs(753 - int(s[i:i+3])) + l.append(a) +print(min(l))" +p03285,s333048624,Accepted,"n=int(input()) + +s=""No"" +for i in range(26): + for j in range(15): + if 4*i+7*j==n: + s=""Yes"" +print(s) +" +p03105,s562647938,Accepted,"a, b, c = map(int, input().split()) +d = 0 +for i in range(1,c+1): + if i*a <=b: + d += 1 + continue + else: + break +print(d)" +p02814,s531789950,Wrong Answer,"import fractions +N, M = map(int, input().split()) +A = [int(x) for x in input().split()] +ans = 0 +lcm_half = 1 +flag = 0 +for i in range(N): + gcd = fractions.gcd(A[i]//2, lcm_half) + lcm_half = (lcm_half * (A[i]) // 2) // gcd + if lcm_half > M: + flag = 1 + break +if flag == 1: + ans = 0 +else: + ans = 1+M//(lcm_half*2) + +print(ans) +" +p02731,s547515279,Accepted,"#!/usr/bin/ python3.8 +import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +L = int(read()) +print(L**3 / 27) +" +p02553,s526488359,Accepted,"x = list(map(int, input().split())) +print(max(x[0]*x[2], x[0]*x[3], x[1]*x[2], x[1]*x[3]))" +p03254,s032493933,Wrong Answer,"N,X=map(int,input().split()) +ai=list(map(int,input().split())) +ai.sort() +sum_of_the_candy=0 +ans=0 +if sum(ai)==X: + ans=N +elif sum(ai)= a: + print((tmp1*a)+a) +else: + print((tmp1*a)+tmp2)" +p03448,s560162784,Accepted,"A = int(input()) +B = int(input()) +C = int(input()) +X = int(input()) + +a_max = X // 500 +b_max = X // 100 +c_max = X // 50 + +a_range = A +if A > a_max: + a_range = a_max +b_range = B +if B > b_max: + b_range = b_max +c_range = C +if C > c_max: + c_range = c_max + +count = 0 + +for i in range(c_range+1): + for j in range(b_range+1): + for k in range(a_range+1): + if k * 500 + j * 100 + i * 50 == X: + count += 1 + +print(count)" +p03211,s845407276,Accepted,"#import sys +#import numpy as np +import math +#from fractions import Fraction +import itertools +from collections import deque +from collections import Counter +#import heapq +#from fractions import gcd +#input=sys.stdin.readline +#import bisect +s=input() +n=len(s) +res=900 +for i in range(n-2): + if abs(753-int(s[i:i+3])) B[i]: + A[i] = B[i] +A.append(B[N-1]) +print(B[1:]) +print(A[1:]) +print(sum(A)) +" +p02597,s836852673,Accepted,"N = int(input()) +string = input() +r2w = string.count(""R"") +w2r = 0 +ans_list = [max(r2w, w2r)] +for c in string: + if c == ""W"": + w2r += 1 + else: + r2w -= 1 + ans_list.append(max(r2w, w2r)) +print(min(ans_list))" +p04033,s344094286,Accepted,"a, b = map(int, input().split()) +if a <= 0 <= b: + print(""Zero"") +elif 1 <= a or (b-(a-1))%2 == 0: + print(""Positive"") +else: + print(""Negative"")" +p02646,s556994395,Wrong Answer,"A, V = map(int, input().split()) +B, W = map(int, input().split()) +T = int(input()) + +A_ = A + V * T +B_ = B + W * T + +if A == B: + print('YES') +elif A > B: + print('NO') +elif A < B and A_ >= B_: + print('YES') +else: + print('NO')" +p02831,s086208931,Accepted,"from fractions import gcd +a,b=map(int,input().split()) +l=a*b//(gcd(a,b)) +print(l)" +p02742,s686829765,Accepted,"h, w = [int(x) for x in input().split()] +if h == 1 or w == 1: + res = 1 +else: + if w%2 == 0: + res = h * w // 2 + else: + res = h * (w//2) + (h + 2 - 1)//2 +print(res) +" +p03417,s737015221,Accepted,"n, m = map(int, input().split()) + +if n == 1: + if m == 1: + print(1) + else: + print(m-2) + +elif m == 1: + print(n-2) + +else: + print((n-2) * (m-2))" +p02705,s540716108,Accepted,"import math +R = int(input()) + +print(2*R*math.pi) +" +p02882,s947408516,Accepted,"import math +a,b,x=map(int,input().split()) + +if x/(a**2)>=b: + print(0) +elif x/(a**2)>=b*0.5: + print(90-math.degrees(math.atan((a*0.5)/(b-x/a**2)))) +else: + print(math.degrees(math.atan(b/(2*x/(a*b)))))" +p02756,s031633292,Accepted,"S = input() +Q = int(input()) +cond = 1 +pre = '' +epi = '' +for i in range(Q): + q = list(map(str, input().split())) + if q[0] == ""1"": + cond *= -1 + else: + if q[1] == ""1"": + if cond == 1: + pre += q[2] + else: + epi += q[2] + else: + if cond == 1: + epi += q[2] + else: + pre += q[2] + +if cond == 1: + print(pre[::-1]+S+epi) +else: + print(epi[::-1]+S[::-1]+pre)" +p03061,s002374278,Accepted,"from math import gcd + +N = int(input()) +A = list(map(int, input().split())) + +L = [0] * N +R = [0] * N +L[0] = A[0] +R[N-1] = A[N-1] +for i in range(1, N): + L[i] = gcd(L[i-1], A[i]) + R[N-i-1] = gcd(R[N-i], A[N-i-1]) + +ans = -1 +for i in range(N): + if i == 0: + ans = max(ans, R[1]) + elif i == N-1: + ans = max(ans, L[N-2]) + else: + ans = max(ans, gcd(L[i-1], R[i+1])) + +print(ans)" +p02657,s756975562,Wrong Answer,"a, b = input().split() +a = int(a) +b = b.replace(""."", """") +b = int(b) +print(a * b // 100)" +p03387,s470730593,Wrong Answer,"import numpy as np + +def multi_input(): + return map(int, input().split()) + +l = np.array(list(multi_input())) +l = np.abs(l - max(l)) +l.sort() + +ans = 0 +if (l[2] - l[1]) % 2 == 0: + ans += l[1] + (l[2] - l[1]) // 2 +else: + ans += (l[2] - l[1]) // 2 + (l[2] - l[1]) +print(ans)" +p02657,s339009733,Accepted,"a,b=map(int, input().split()) #a1 a2 a3 +print(a*b)" +p03803,s504668433,Wrong Answer,"A,B=input().split() +if (int(A)>int(B) and A!=""13"") or (int(A) 2*c and b > 2*c: + ans = 2*c*max(x, y) +elif a < c and b < c: + ans = a*x + b*y +else: + ans = float('inf') + for i in range(min(x, y)+1): + p = 2*c*i + (x-i)*a + (y-i)*b #; print(i, p) + ans = min(p, ans) +print(ans)" +p02823,s568636168,Accepted,"N, A, B = map(int, input().split()) + +dist = abs(A - B) +if dist % 2 == 0: + print(dist//2) +else: + print(min(A - 1, N - B) + 1 + (dist - 1)//2)" +p02578,s853970661,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +sum=0 +for i in range(N-1): + if A[i+1]>A[i]: + sum+=A[i+1]-A[i] +print(sum)" +p04031,s154917769,Wrong Answer,"# C +import math +n = int(input()) +a = list(map(int, input().split())) +ave = math.ceil(sum(a)/n) + +ans = 0 +for i in range(n): + ans += (a[i] - ave)**2 + +print(ans)" +p03105,s179203905,Accepted,"a,b,c = map(int,input().split()) +print(int(b/a) if int(b/a) abs(e[0]-p[k][0]) + abs(e[1]-p[k][1]): + temp = abs(e[0]-p[k][0]) + abs(e[1]-p[k][1]) + u = k+1 + ans.append(u) +print(*ans,sep=""\n"") +" +p03285,s040722059,Wrong Answer,"n=int(input()) +a=4 +b=7 +for i in range(26): + for j in range(15): + if a*i+b*j==n: + print('Yes') + else: + print('No') +" +p03262,s285081200,Wrong Answer,"import fractions +import sys + +N, X = map(int, input().split()) +li = list(map(int, input().split())) + +if len(li) == 1: + print(li[0] - X) + sys.exit() + +li.append(X) +li.sort(reverse=True) + +ans = li[0] - li[1] + +for index, i in enumerate(li): + if index == 0: + continue + + if index == len(li) - 1: + break + + ans = fractions.gcd(ans, i - li[index+1]) + +print(ans)" +p04019,s697472906,Accepted,"s=set(input()) + +flg=0 +if ""N"" in s: + flg+=1 +if ""S"" in s: + flg-=1 +if ""W"" in s: + flg+=10 +if ""E"" in s: + flg-=10 + +if flg==0: + print(""Yes"") +else: + print(""No"") + " +p02792,s376438645,Accepted,"N = int(input()) +mem=[[0] * 10 for _ in range(10)] + +for i in range(1, N+1): + s = str(i) + mem[int(s[0])][int(s[-1])] += 1 + +ans = 0 +for i in range(1, 10): + for j in range(1, 10): + ans += mem[i][j] * mem[j][i] +print(ans)" +p03951,s502985640,Accepted,"N = int(input()) +s = input() +t = input() +ans = 2*N +for i in range(N): + if s[-(i+1):] == t[:i+1]: + ans = 2*N-(i+1) +print(ans)" +p03041,s588801002,Accepted,"n,k=map(int,input().split()) +s=input() +if s[k-1]=='A': + x='a' +elif s[k-1]=='B': + x='b' +elif s[k-1]=='C': + x='c' +print(s[:k-1]+x+s[k:])" +p02912,s219135753,Accepted,"import heapq +n, m = map(int, input().split()) +a = list(map(int, input().split())) +a = list(map(lambda x: x*(-1), a)) +heapq.heapify(a) + +count_use = 0 +while count_use < m: + max_a = heapq.heappop(a) + max_a = -1*((-1*max_a)//2) + #print(max_a) + heapq.heappush(a, max_a) + count_use += 1 + +print((-1)*sum(a))" +p04030,s511441859,Accepted,"li = list(input()) +ans = """" +for i in li: + if i == ""0"": + ans = ans + ""0"" + elif i == ""1"": + ans = ans + ""1"" + elif i == ""B"": + ans = ans[:len(ans)-1] +print(ans)" +p03105,s640698131,Accepted,"a,b,c=map(int,input().split()) +if a*c<=b: + print(c) +else: + print(b//a)" +p02705,s502272511,Accepted,"import math +r = int(input()) +print(r*2*math.pi)" +p02939,s835161526,Accepted,"s = input() +ans = 0 +pre = """" +now = """" +for ss in s: + now += ss + if pre != now: + ans += 1 + pre = now + now = """" +print(ans)" +p02675,s925121978,Accepted,"n=input() + +if n[-1]==""2"" or n[-1]==""4"" or n[-1]==""5"" or n[-1]==""7"" or n[-1]==""9"": + print('hon') +elif n[-1]==""3"": + print('bon') +else: + print('pon')" +p04019,s617010011,Accepted,"S=input() + +n,w,s,e='N' in S,'W' in S,'S' in S,'E' in S + +cand1=not n^s +cand2=not w^e + +ans=""Yes"" if cand1 and cand2 else ""No"" +print(ans) +" +p04005,s995527756,Accepted,"A, B, C = map(int,input().split()) + +if (A * B * C) % 2 == 0: + ans = 0 +else: + ans = min(A*B,B*C,C*A) +print(ans)" +p02576,s561860677,Wrong Answer,"n,x,t = map(int, input().split()) + +ans = n / x +ans = round(ans) +ans = ans * t +if ans == 0: + ans = t +if n == 0: + ans = 0 +print(ans)" +p03319,s248499611,Wrong Answer,"import math +N,K=map(int,input().split()) +A=list(map(int,input().split())) +saishou=A.index(1) +if saishou==0: + answer=math.ceil((N-1)/(K-1)) + print(answer) +else: + print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1))) + " +p02640,s273868530,Accepted,"from sys import stdin + +A = list(map(int,stdin.readline().split())) + +if A[1]-2*A[0]<0: + print('No') +else: + if (A[1]-2*A[0])%2==0: + if (A[1]-2*A[0])/2>A[0]: + print('No') + else: + print('Yes') + else: + print('No')" +p03951,s326711397,Accepted,"#code +n=int(input()) +s=input() +t=input() +ans=2*n +for i in range(0,len(s)): + if(s[i:]==t[:n-i]): ans=min(ans,i+n-i+i) + + +print(ans)" +p03254,s875704605,Accepted,"def resolve(): + import sys + n,x=map(int, input().split()) + l=list(map(int, input().split())) + l.sort() + cnt=0 + for i in range(n): + if l[i]<=x: + x-=l[i] + cnt+=1 + else: + break + if cnt==n and x>0: + cnt-=1 + print(cnt) +resolve() +" +p02777,s768226882,Accepted,"s=list(input().split()) +a,b=map(int,input().split()) +print(a,b-1) if s.index(input())==1 else print(a-1,b)" +p02572,s637217781,Wrong Answer,"N = int(input()) +a = list(map(int, input().split("" ""))) +s = 0 +for i in range(0,N): + s += a[i] + +s = s*s + +for i in range(0,N): + s -= a[i]*a[i] + +while s >= 2*(10**9 +7): + s = s % (10**9 +7) +if s >= 10**9 + 7: + s = s % (10**9) +s = s/2 + +print(int(s))" +p03852,s884648612,Accepted,"import sys + +sys.setrecursionlimit(10 ** 6) +int1 = lambda x: int(x) - 1 +p2D = lambda x: print(*x, sep=""\n"") +def II(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LI(): return list(map(int, sys.stdin.readline().split())) +def LLI(rows_number): return [LI() for _ in range(rows_number)] +def SI(): return sys.stdin.readline()[:-1] + +def main(): + c=SI() + if c in ""aiueo"":print(""vowel"") + else:print(""consonant"") + +main()" +p02732,s711686785,Wrong Answer,"def n0():return int(input()) +def n1():return [int(x) for x in input().split()] +def n2(n):return [int(input()) for _ in range(n)] +def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] + +n=n0() +a=n1() + +from scipy.misc import comb +def combi(n): + if n<=1: + return 0 + if n==2: + return 1 + return comb(n,2) + +c=[a.count(i) for i in range(1,n+1)] +d=[combi(m) for m in c] +s=sum(d) + +for i in range(n): + print(s-d[a[i]-1]+combi(c[a[i]-1]-1))" +p03077,s917962092,Wrong Answer,"import math +n=int(input()) +a=int(input()) +b=int(input()) +c=int(input()) +d=int(input()) +e=int(input()) +ans=5 +x=[a,b,c,d,e] +s=0 +if n>a: + s=math.ceil(n/a) +for i in range(4): + if x[i]>x[i+1]: + t=x[i]//x[i+1] + if x[i]%x[i+1]!=0: + t+=1 + s=max(s,t) +print(ans+s) +" +p02796,s379356057,Accepted,"N = int(input()) +r = [list(map(int, input().split())) for _ in range(N)] +a = [] +for i in r: + a.append((i[0]+i[1],i[0]-i[1])) +a.sort() +ans = 0 +cur = a[0][1] +for i in a: + if i[1] < cur: + continue + ans += 1 + cur = i[0] +print(ans)" +p03745,s142181668,Accepted,"def main(): + N = int(input()) + A = list(map(int, input().split())) + + is_increasing = True + is_first = True + ans = 1 + + for i in range(1, N): + if is_first == True: + if A[i - 1] < A[i]: + is_increasing = True + is_first = False + elif A[i - 1] > A[i]: + is_increasing = False + is_first = False + else: + if is_increasing == True and A[i - 1] > A[i]: + ans += 1 + is_first = True + elif is_increasing == False and A[i - 1] < A[i]: + ans += 1 + is_first = True + + print(ans) + + + + +if __name__ == ""__main__"": + main()" +p03487,s504483829,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) +a.sort() +array = list(set(a)) +sum = 0 +n = 0 +for i in range(len(array)): + cnt = 0 + for j in range(n,len(a)): + if array[i] == a[j]: + cnt += 1 + else: + break + n += cnt + if cnt >= array[i]: + sum += cnt - array[i] + else: + sum += cnt +print(sum)" +p02700,s412818495,Accepted,"A,B,C,D = map(int,input().split()) + +from math import ceil +if ceil(A/D) >= ceil(C/B): + print(""Yes"") + exit() + +print(""No"") +" +p03043,s898213263,Wrong Answer,"from math import ceil +N, K = map(int, input().split()) +n = 1 +while K > 2**n: + n += 1 +ans = (1 / N) * (0.5**n) +pre = 1 +for i in range(n - 1, -1, -1): + k = ceil(K / (2**i)) + if N >= k: + ans += (1 / N) * (k - pre) * (0.5 ** i) + if N == k: + break + else: + ans += (1 / N) * (N - pre) * (0.5 ** i) + break + pre = k +if N > K: + ans += (1 / N) * (N - K) +print(ans)" +p03086,s466811250,Accepted,"pat = [""A"", ""C"", ""G"", ""T""] + +s = input() + +left = right = 0 +ans = 0 + +while left < len(s): + right = left + while right < len(s) and s[right] in pat: + right += 1 + + ans = max(ans, right - left) + + left = right + 1 + +print(ans) +" +p02802,s125942683,Accepted,"n,m=map(int,input().split()) +p=[True]*n +y=[0]*n +i=0 +l=0 +for _ in range(m): + k,o=input().split() + k=int(k)-1 + if p[k]==True: + if o==""AC"": + i+=1 + p[k]=False + else: + y[k]+=1 +for e in range(n): + if p[e]==False: + l+=y[e] +print(i,l) +" +p02772,s151985184,Accepted,"N = input() +As = input().split() +e = [int(i) for i in As if int(i)%2 == 0] +c = 0 +for i in e: + if i%3==0 or i%5==0: + c += 1 +if c == len(e): + print(""APPROVED"") +else: + print(""DENIED"")" +p03475,s969074872,Accepted,"n = int(input()) +csf = [list(map(int,input().split())) for _ in range(n-1)] +ans = [] +for i in range(n-1): + time = csf[i][1]+csf[i][0] + for j in range(i+1,n-1): + if time < csf[j][1]: + time = csf[j][1] + elif (time-csf[j][1]) % csf[j][2] != 0: + time = csf[j][1]+((time-csf[j][1])//csf[j][2]+1)*csf[j][2] + time += csf[j][0] + ans.append(time) +ans.append(0) +for k in range(n): + print(ans[k])" +p03309,s342573314,Accepted," +def solve(): + B = [0]*N + for i in range(N): + B[i] = a[i] - (i+1) + B.sort() + b = B[N//2] +# print(b) + scr = 0 + for l in range(N): + scr += abs(B[l] - b) + print(scr) + +if __name__ == ""__main__"": + N = int(input()) + a = list(map(int, input().split())) + solve() +" +p02811,s339650219,Accepted,"K,X = map(int, input().split()) + +if 500*K >= X: + print('Yes') +else: + print('No')" +p03836,s287917500,Accepted,"sx, sy, tx, ty = list(map(int, input().split())) + +sol = """" +sol += ""R""*(tx-sx) + ""U""*(ty-sy) + ""L""*(tx-sx) + ""D""*(ty-sy) +sol += ""D""+ ""R""*(tx-sx + 1) + ""U""*(ty-sy + 1) + ""LU"" + ""L""*(tx-sx + 1) + ""D""*(ty-sy+1) + ""R"" + +print(sol)" +p03774,s345269108,Wrong Answer,"n,m=map(int,input().split()) +a=[[int(i) for i in input().split()] for l in range(n)] +b=[[int(i) for i in input().split()] for l in range(m)] +for A in a: + c=1 + r=0 + m=100000000 + for B in b: + k=abs(A[0]-B[0])+abs(A[1]-B[1]) + if m>k: + m=k + r=c + c+=1 + print(r) +" +p02993,s673052499,Accepted,"s = input() +print('Bad' if any(s[i]==s[i+1] for i in range(3)) else 'Good')" +p02661,s422767474,Accepted,"n = int(input()) +a = [] +b = [] +for i in range(n): + x,y = map(int,input().split()) + a.append(x) + b.append(y) +a.sort() +b.sort() +if n % 2 == 1: + print(b[n//2] - a[n//2] + 1) +else: + print(b[n//2]+b[n//2-1]-a[n//2]-a[n//2-1]+1)" +p03417,s485899071,Accepted,"N, M = map(int, input().split()) +if N == 1: + if M == 1: + print(1) + elif M == 2: + print(0) + else: + print(M - 2) +elif N == 2: + print(0) +else: + if M == 1: + print(N - 2) + elif M == 2: + print(0) + else: + print((N - 2) * (M - 2))" +p02548,s930872771,Wrong Answer,"N = int(input("""")) +d = 0 +for a in range(N): + for b in range(N): + for c in range(N): + if a*b+c == N: + d += 1 +print(d)" +p02631,s312035430,Accepted,"n = int(input()) +l = list(map(int,input().split())) +x = l[0] +for i in range(1,n): + x = x^l[i] + + +ans = [] +for i in range(n): + ans.append(str(x^l[i])) + +print(' '.join(ans)) + " +p02953,s098570897,Wrong Answer,"n = int(input()) +h = list(map(int, input().split())) +for i in range(1,n): + if h[i-1] > h[i]: + h[i-1] -= 1 +print(""Yes"") if h == sorted(h) else print(""No"")" +p02897,s605993605,Accepted,"n = int(input()) +if n % 2 == 0: + print(0.5) +else: + print((n//2+1)/n) + " +p02701,s838547517,Accepted,"n = int(input()) + +l= [] +for i in range(n): + a = input() + l.append(a) +s = set(l) +print(len(s)) +" +p02691,s132313202,Accepted,"n = int(input()) +x = [int(i) for i in input().split()] +y = [] +z =[] +for i in range(len(x)): + y.append(x[i]+i) + z.append(i-x[i]) +count = 0 +dic = {} +for i in range(len(z)): + if z[i] in dic : + dic[z[i]]+= 1 + else : + dic[z[i]] = 1 +for i in range(len(y)) : + dic[z[i]]-= 1 + if y[i] in dic : + count += dic[y[i]] +print(count) +" +p02657,s266475803,Accepted,"a, b = map(int, input().split()) +print(a*b)" +p03206,s220264369,Accepted,"D = int(input()) + +if D == 25: + print('Christmas') +elif D == 24: + print('Christmas Eve') +elif D == 23: + print('Christmas Eve Eve') +else: + print('Christmas Eve Eve Eve')" +p02554,s941530604,Accepted,"N = int(input()) + +A = 10**N + 8**N - 2*9**N +B = A%(10**9 + 7) +print(B) +" +p02584,s452322691,Wrong Answer,"x, k, d = map(int, input().split()) +x = abs(x) + +k_ = x // d +k = k - k_ +x = x-k*d + +while k > 0: + x = min(abs(x + d), abs(x - d)) + k -= 1 +print(x) +" +p02988,s210218088,Accepted,"n = int(input()) +p = list(map(int,input().split())) +c = 0 +for i in range(n-2): + if p[i] < p[i+1] and p[i+1] < p[i+2]: + c += 1 + elif p[i] > p[i+1] and p[i+1] > p[i+2]: + c += 1 +print(c)" +p03210,s551890585,Accepted,"a = int(input()) +if a in [3,5,7]: + print('YES') +else: + print('NO')" +p03103,s416799756,Accepted,"N,M=map(int,input().split()) +AB=list() +for i in range(N): + AB.append(list(map(int,input().split()))) +AB.sort() +ans=0 +for i in range(N): + if M>=AB[i][1]: + M-=AB[i][1] + ans+=AB[i][0]*AB[i][1] + else: + ans+=M*AB[i][0] + M=0 +print(ans)" +p02675,s715311771,Wrong Answer,"# -*- coding:utf-8 -*- + +N = int(input()) + +if N % 10 == (2 or 4 or 5 or 7 or 9): + print(""hon"") +elif N % 10 == 3: + print(""bon"") +else: + print(""pon"") +" +p03385,s245903973,Accepted,"S = input() +if 'a' in S and'b' in S and 'c' in S: + print(""Yes"") +else: + print(""No"")" +p03219,s866366609,Accepted,"x,y = map(int, input().split()) +print(x+y//2)" +p03543,s054952027,Accepted,"a = input() +print('Yes' if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] else 'No')" +p04043,s509199604,Accepted,"length = list(map(int, input().split())) + +length.sort() + +if length == [5,5,7]: + print('YES') +else: + print('NO') +" +p03160,s547727170,Accepted,"import numpy as np +n=int(input()) +h=np.array(list(map(int,input().split()))+[0]*2) +dp = np.full(n+2, 10 ** 10, dtype=np.int64) +dp[0] = 0 +for i in range(1,n): + dp[i:i+2]=np.minimum(dp[i:i+2],np.abs(h[i:i+2]-h[i-1])+dp[i-1]) +print(dp[n-1])" +p02994,s752795452,Accepted,"n,l=map(int,input().split()) +taste=[] +for i in range(n): + taste.append(i+l) +taste.sort(key=abs) + +print(sum(taste)-taste[0]) +" +p02860,s768249035,Accepted,"def judge(S, N): + if N % 2 != 0: + return 'No' + if S[:N//2] == S[N//2:]: + return 'Yes' + else: + return 'No' + + +N = int(input()) +S = input() +print(judge(S, N)) +" +p02719,s799350887,Accepted,"import sys +def input(): return sys.stdin.readline().rstrip() + + +def main(): + N, K = map(int, input().split()) + + a = N%K + if a > abs(a-K): + print(abs(a-K)) + else: + print(a) + +if __name__ == '__main__': + main()" +p03062,s026476655,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +B = [abs(i) for i in A] +minus = [int(i<0) for i in A] +if sum(minus)%2 == 0: + print(sum(B)) +else: + print(sum(B)-2*min(B))" +p02801,s050693824,Accepted,"C = input() +n = chr(ord(C)+1) +print(n)" +p02640,s781044088,Accepted,"from collections import defaultdict +it = lambda: list(map(int, input().strip().split())) +INF = float('inf') + +def solve(): + X, Y = it() + if Y % 2: + return False + return 4 * X >= Y >= 2 * X + +if __name__ == '__main__': + if not solve(): + print('No') + else: + print('Yes')" +p03860,s352946157,Accepted,"sArray = list(input().split()) + +result = '' +for i in sArray: + result += ''.join(i[0]) + +print(result) +" +p03699,s852962959,Accepted,"#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +def main(): + N = int(input()) + S = [int(input()) for _ in range(N)] + + S.sort() + result = sum(S) + + if result % 10 == 0: + for s in S: + if s % 10: + print(result - s) + exit() + else: + print(result) + exit() + + print(0) + + +if __name__ == ""__main__"": + main() +" +p03317,s982431565,Wrong Answer,"n,k=map(int,input().split()) +a=[int(x) for x in input().split()] +ans=1 +n-=k +ans+=(n+k-1)//k +print(ans)" +p03437,s521553031,Wrong Answer,"x,y=map(int,input().split()) +if (x*10)%y != 0: + print(x*10)" +p03854,s016960669,Accepted,"s = input() +n = len(s) + +s = """".join(reversed(list(s))) +while n: + if s.startswith(""maerd""): + n -= 5 + s = s[5:] + elif s.startswith(""remaerd""): + n -= 7 + s = s[7:] + elif s.startswith(""esare""): + n -= 5 + s = s[5:] + elif s.startswith(""resare""): + n -= 6 + s = s[6:] + else: + break +print(""YES"" if n == 0 else ""NO"")" +p04005,s296493036,Accepted,"# coding: utf-8 + +def main(): + N = sorted(list(map(int, input().split()))) + ans = N[0] * N[1] * (N[2] % 2) + print(ans) + +if __name__ == ""__main__"": + main() +" +p03605,s566095819,Accepted,"N = int(input()) +s = str(N) +for i in range(len(s)): + if s[i]==""9"": + print(""Yes"") + exit() + +print(""No"")" +p03815,s775843436,Wrong Answer,"x=int(input()) +y=19 + +ans=0 +ans+=(x//11)*2 +cnt=x%11 +if cnt>=6: + ans+=2 +elif cnt>=1: + ans+=1 + +print(ans)" +p02786,s786075070,Accepted,"H = int(input()) + +def calc(X): + if X==1: + return 1 + else: + return 1+2*calc(X//2) + +print(calc(H))" +p03309,s119609198,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +A = [A[i - 1] - i for i in range(1, N + 1)] + +A.sort() +med = A[N // 2 - 1] +A = [abs(A[i - 1] - med) for i in range(1, N + 1)] + +print(sum(A))" +p02797,s042576615,Accepted,"n, k, s = map(int, input().split()) +if s == 1: + ans = [s+1] * n +else: + ans = [s-1] * n + +for i in range(k): + ans[i] = s +print(' '.join(map(lambda x: str(x), ans))) +" +p03778,s735495654,Accepted,"w, a, b = map(int, input().split()) +print(abs(b - a) - w if abs(b - a) > w >= 0 else 0)" +p02854,s597453947,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +ans = 10**8 +sum_A = sum(A) +hoge = 0 + + +for i in range(N-1): + hoge = hoge + A[i] + ans = min(ans,(abs((sum_A - hoge)-(hoge)))) + +print(ans)" +p02726,s330869561,Accepted,"def main(): + N,X,Y = [int(n) for n in input().split()] + X -= 1 + Y -= 1 + res = [0] * N + for i in range(N): + for j in range(i,N): + dis = min([j - i, abs(i - X) + 1 + abs(j-Y), abs(i - Y) + 1 + abs(j-Y)]) + # print(i,j,X,Y) + # print(dis) + res[dis]+=1 + for i in range(1,N): + print(res[i]) +main()" +p02642,s179424217,Accepted,"import sys +input = sys.stdin.readline + +''' + +''' + +n = int(input()) +a = sorted(map(int, input().split())) +largest = a[-1] +#largest = arr[-1] +div = [1] * (largest+1) +count = 0 +arr = [] +# remove duplicates +for i, v in enumerate(a): + if i < (n-1) and a[i+1] == v: + div[v] = 0 + else: + arr.append(v) + +for num in arr: + if div[num]: + count += 1 + + for d in range(num, largest+1, num): + div[d] = 0 + +print(count) + +" +p02971,s545864300,Wrong Answer,"N = int(input()) +A = [int(input()) for i in range(N)] + + +sorted_A = list(reversed(sorted(A))) + +maxiuam = sorted_A[0] + +is_there_tow_maximum = A.count(maxiuam) >= 2 +if is_there_tow_maximum: + answer = str(maxiuam) * (N - 1) + print(answer) + +second = None +for Ai in sorted_A: + if Ai < maxiuam: + second = Ai + break + +answer = [] +for Ai in A: + if Ai == maxiuam: + answer.append(second) + else: + answer.append(maxiuam) +answer = ""\n"".join(map(str, answer)) + +print(answer) +" +p02743,s930782922,Wrong Answer,"import math +a,b,c=map(int,input().split()) +if math.sqrt(a)+math.sqrt(b)0: + for i in range(1,n): + if a[i-1] + a[i]>x: + + temp+= (a[i-1] + a[i]) - x + a[i]=0 + else: + continue + print(temp) +else: + print(a[0]+a[1]) + +" +p03774,s662264661,Accepted,"def func(x1,y1,x2,y2): + return abs(x1-x2)+abs(y1-y2) +n,m = map(int,input().split()) +g = [list(map(int,input().split())) for _ in range(n)] +c = [list(map(int,input().split())) for _ in range(m)] +index = 0 +for k in g: + num = 10**9 + for i,d in enumerate(c): + tmp = func(k[0],k[1],d[0],d[1]) + if tmp < num: + num = tmp + index = i + print(index+1)" +p02732,s381025388,Wrong Answer,"import collections as cl +N = int(input()) +A = list(map(int,input().split())) +cn = cl.Counter(A) +sumC = sum([N*(N-1)//2 for N in cn.values()]) +for k in range(N): + sum = sumC - cn[A[k]] +1 +print(sum)" +p02730,s685902526,Wrong Answer," +#ライブラリインポート +from collections import defaultdict + +con = 10 ** 9 + 7 +#入力受け取り +def getlist(): + return list(map(int, input().split())) + +#処理内容 +def main(): + S = input() + N = len(S) + judge = ""Yes"" + s = int((N - 3) // 2) + t = int((N + 1) // 2) + for i in range(int((N - 1) // 2)): + if S[i] != S[s - i]: + judge = ""No"" + if S[t + i] != S[N - 1 - i]: + judge = ""No"" + + print(judge) + +if __name__ == '__main__': + main()" +p03495,s036320920,Wrong Answer,"n,k = map(int,input().split()) +a = list(map(int,input().split())) + +if(len(set(a)) <= k): + print(0) +else: + dic_a = {x:0 for x in set(a)} + for i in a: + dic_a[i] += 1 + sum = 0 + a = sorted(dic_a.items(), key=lambda x: x[0]) + for i in range(k,len(a)): + sum += a[i][1] + print(sum)" +p03719,s243852164,Accepted,"A,B,C=map(int,input().split()) +if (A<=C<=B): + print(""Yes"") +else: + print(""No"")" +p03339,s856393843,Accepted,"n=int(input()) +s=str(input()) +ans=0 + +for i in range(n-1): + n=i+1 + if s[n]=='E': + ans=ans+1 + +cnt=ans + +for i in range(n): + if s[i:i+2]=='WW': + cnt=cnt+1 + elif s[i:i+2]=='EE': + cnt=cnt-1 + else: + 0 + + #print('i,s[i:i+2],ans,cnt',i,s[i:i+2],ans,cnt) + ans=min(ans,cnt) +print(ans) +" +p02988,s603020177,Accepted,"n=int(input()) +p=[int(i) for i in input().split()] + +count=0 +for i in range(1,n-1): + if (p[i-1]mid: + ans-=i//mid + return ans>=0 + + +l=0 +r=10**9 +while(l0 and b>0: + print(""Positive"") + else : + print(""Zero"") + return + +main() +" +p03679,s058794979,Accepted,"import sys +import os + +MOD = 10 ** 9 + 7 + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + X, A, B = list(map(int, sys.stdin.buffer.readline().decode().split())) + if B - A > X: + print('dangerous') + elif A >= B: + print('delicious') + else: + print('safe') + + +if __name__ == '__main__': + main() +" +p03761,s445420965,Accepted,"N = int(input()) +S = [input() for _ in range(N)] + +alp = [chr(i) for i in range(97,123)] + +ans = """" +for al in alp : + count = 10**10 + for sen in S : + count = min(count, sen.count(al)) + ans += al * count + +print(ans) +" +p03607,s238506696,Wrong Answer,"n = int(input()) +na = [] +cou = [] +count = 0 +for i in range(n): + a = int(input()) + na.append(a) +for j in range(n): + if na[j] in cou: + count -= 1 + else: + count += 1 + cou.append(na[j]) +print(count)" +p03338,s802285797,Accepted,"N=int(input()) +S=input() +s="""" +m="""" +ss=[] +mm=[] +s1=set() +m1=set() +res = 0 +for i in range(N): + s=S[0:i+1] + m=S[i+1:N] + ss=list(s) + mm=list(m) + s1=set(ss) + m1=set(mm) + s_intersection = s1 & m1 + res= max(res,len(s_intersection)) +print(res)" +p03817,s776092728,Wrong Answer,"# -*- coding: utf-8 -*- +import sys +from collections import deque, defaultdict +from math import sqrt, factorial, gcd +# def input(): return sys.stdin.readline()[:-1] # warning not \n +# def input(): return sys.stdin.buffer.readline().strip() # warning bytes +# def input(): return sys.stdin.buffer.readline().decode('utf-8') + + +def solve(): + # n, m = [int(x) for x in input().split()] + n = int(input()) * 10 + if n == 60: + print(1) + else: + print((n + 54) // 55) + + +t = 1 +# t = int(input()) +for case in range(1,t+1): + ans = solve() + + +"""""" + +R s +S p +P r + +"""""" +" +p02689,s279039173,Accepted,"N, M = map(int, input().split()) +H = list(map(int, input().split())) + +A = [0]*M +B = [0]*M +for i in range(M): + ta, tb = map(int, input().split()) + A[i] = ta - 1 + B[i] = tb - 1 + +ans = [True]*N +# v: Trueならいい展望台、Falseなら良くない展望台 +for i in range(M): + ans[A[i]] = H[A[i]] > H[B[i]] and ans[A[i]] + ans[B[i]] = H[B[i]] > H[A[i]] and ans[B[i]] + +print(ans.count(True))" +p02711,s134352943,Accepted,"n = input() +if '7' in n: + print('Yes') +else: + print('No')" +p02639,s094238433,Accepted,"*X, = map(int, input().split()) +print(X.index(0) + 1) +" +p02959,s367539385,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = list(map(int,input().split())) + +cnt = 0 +for i in range(N-1,-1,-1): + t = min(A[i+1],B[i]) + A[i+1] -= t + B[i] -= t + cnt += t + t = min(A[i],B[i]) + A[i] -= t + B[i] -= t + cnt += t + +print(cnt) +" +p03137,s386982885,Wrong Answer,"N,M,*X = map(int, open(0).read().split()) +X.sort() +D = [abs(X[i+1] - X[i]) for i in range(M-1)] +if N >= M: + print(X[-1] - X[0] - sum(sorted(D)[-(N-1):][::-1])) +else: + print(0)" +p02639,s576870773,Accepted,"import sys + +sys.setrecursionlimit(10 ** 8) +ini = lambda: int(sys.stdin.readline()) +inm = lambda: map(int, sys.stdin.readline().split()) +inl = lambda: list(inm()) +ins = lambda: sys.stdin.readline().rstrip() +# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr) + +x = inl() + + +def solve(): + for i, y in enumerate(x): + if y != i + 1: + return i + 1 + return None + + +print(solve()) +" +p03319,s333315222,Wrong Answer,"n,k = list(map(int, input().split())) +a = list(map(int, input().split())) + +# 最小値付近から攻める +idx = a.index(min(a)) +right = n - idx - 1 +left = idx + +q1,r1 = divmod(left, k-1) +q2,r2 = divmod(right, k-1) +print(q1, q2, r1, r2) +print(q1 + q2 + min(r1,1) + min(r2,1))" +p03797,s496855776,Wrong Answer,"n, m = map(int, input().split()) +print( (n * 2 + m) // 4)" +p02713,s371272144,Accepted,"import math +N, = (int(x) for x in input().split()) + +sol = 0 +for i in range(1, N+1): + for j in range(1, N + 1): + G = math.gcd(i, j) + if G == 1: + sol += N + continue + for k in range(1, N + 1): + g = math.gcd(G, k) + sol += g +print(sol)" +p02712,s110115985,Accepted,"n = int(input()) +m = n + 1 +sum = 0 +if m <= 3: + for x in range(m): + sum = sum + x +else: + for x in range(m): + if x%3 == 0 or x%5 == 0: + pass + else: + sum = sum + x +print(sum)" +p02753,s587894440,Accepted,"S = input() +if S == ""AAA"" or S == ""BBB"": + print(""No"") +else: + print(""Yes"")" +p02723,s116700426,Wrong Answer,"s = input() + +if s[2]==s[3] and s[4]==s[5]: + print(""yes"") +else: + print(""no"")" +p02860,s283203132,Wrong Answer,"n=int(input()) +s=input() +if n>1: + a=s[0:int(n/2)] + b=s[int(n/2):] + c=0 + for i in range(int(len(s)/2)): + if a[i]==b[i]: + c=c+1 + else: + pass + if c==int(n/2): + print('Yes') + else: + print('No') +else: + print('No') +" +p02811,s550097084,Accepted,"K, X = map(int, input().split()) + +def check(): + if 500*K>=X: + return 'Yes' + return 'No' +print(check())" +p03997,s696653449,Wrong Answer,"a = int(input()) +b = int(input()) +h = int(input()) + +print((a+b)*h/2)" +p02691,s549462287,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +L={} +R={} +for i in range(1,len(A)+1): + L[str(i+A[i-1])] = L.get(str(i+A[i-1]),0)+1 + R[str(i-A[i-1])] = R.get(str(i-A[i-1]),0)+1 + +ans = 0 +for i in range(1,N+1): + if str(i) in L and str(i) in R: + ans += L[str(i)] * R[str(i)] + +print(ans) +" +p02718,s015848018,Accepted," +n,m = map(int,input().split()) +a = list(map(int,input().split())) + +voder = sum(a)/(4*m) +count = 0 +for i in range(n): + if a[i] >= voder: + count += 1 + +if count < m: + print(""No"") +else: + print(""Yes"")" +p03695,s817999770,Accepted,"n = int(input()) +A = list(map(int,input().split())) + +ans = [0]*8 +free = 0 +for a in A: + for i in range(8): + if a < (i+1)*400: + ans[i]=1 + break + if 3200 <= a: + free += 1 +ans_max = sum(ans)+free +ans_min = max(1, sum(ans)) +print(ans_min, ans_max, sep=' ')" +p02642,s192284159,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +MAX = 1000005 +cnt = [0] * MAX +for x in a: + if cnt[x] != 0: + continue + #cnt配列の各倍数のところに+1 + for i in range(x, MAX, x): + cnt[i] += 1 +ans = 0 +for x in a: + if cnt[x] == 1: + ans += 1 + +print(ans)" +p03998,s005836476,Accepted,"S={c:list(input()) for c in ""abc""} +s=""a"" +while S[s]: + s=S[s].pop(0) +print(s.upper())" +p03994,s736638278,Accepted,"s = [ord(x) - ord(""a"") for x in input()] +k = int(input()) + +for i, r in enumerate(s): + if r == 0: + pass + elif 26 - r <= k: + k -= 26-r + s[i] = 0 + +if k > 0: + k %= 26 + s[-1] += k + +ans = """" +for r in s: + ans += chr(ord(""a"") + r) + +print(ans) + +" +p03997,s836018316,Wrong Answer,"#上底の長さ +a = input() +#下底の長さ +b = input() +#高さ +h = input() +#答え +ans = 0 +#文字列を数値化しつつ +#(上底+下低)*高さ/2で台形の面積を求める +ans = (int(a) + int(b)) * int(h) / 2 +#答えを出力 +print(ans)" +p03103,s721416124,Accepted,"n,m=map(int,input().split()) +l=[] + +for i in range(n): + a,b=map(int,input().split()) + l.append([a,b]) + +l.sort() +c=0 +for a,b in l: + c+=min(b,m)*a + m=max(m-b,0) + +print(c)" +p02633,s242363393,Accepted,"x = int(input()) + +count=1 +test= 0 +test+=x +while test%360!=0: + test+=x + count+=1 +print(count) +" +p02606,s107439584,Accepted,"from math import * +l,r,d=map(int,input().split()) + +c=(l-1)//d +k=r//d +ans=k-c +print(ans)" +p02658,s421158764,Accepted,"import sys + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + if 0 in A: + print('0') + sys.exit() + ans = 1 + for i in range(1, N+1): + if A[i-1] == 0: + print('-1') + sys.exit() + ans *= A[i-1] + if ans > 10**18: + print('-1') + sys.exit() + print(ans) + + +if __name__ == '__main__': + main() +" +p03943,s731657582,Wrong Answer,"x=list(map(int, input().split())) +x.sort() +if x[0]+x[1]==x[2]: + print('yes') +else: + print('no')" +p03761,s784857352,Accepted,"ans=[0 for i in range(26)] +n=int(input()) +s=input() +for j in range(len(s)): + ans[ord(s[j])-97]+=1 +if n>1: + for i in range(n-1): + tmp=[0 for i in range(26)] + s=input() + for j in range(len(s)): + tt=ord(s[j])-97 + tmp[tt]+=1 + for k in range(26): + if tmp[k]j: + goukei=0 + for k in range(d): + goukei+=(x[i][k]-x[j][k])**2 + distance=goukei**0.5 + if distance.is_integer()==True: + ans+=1 +print(ans)" +p03071,s795073266,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + a, b = map(int, input().split()) + ans = 0 + for _ in range(2): + if a > b: + ans += a + a -= 1 + else: + ans += b + b -= 1 + + print(ans) + +if __name__ == '__main__': + main() +" +p03556,s457022038,Accepted,"import math +print(int(math.sqrt(int(input())))**2) +" +p03351,s626274053,Accepted,"a,b,c,d=map(int,input().split()) +e=abs(a-b) +f=abs(b-c) +g=abs(a-c) +if g<=d: + print(""Yes"") +elif e<=d and f<=d: + print(""Yes"") +else: + print(""No"") +" +p02802,s934413372,Wrong Answer,"n, m = map(int, input().split()) +A = [] + +fls = 0 +tr = 0 +for i in range(m): + a, b = input().split() + a = int(a) + if b == ""WA"" and a not in A: + fls += 1 + elif b == ""AC"" and a not in A: + A.append(a) + tr += 1 + +print(tr, fls)" +p02639,s030040096,Wrong Answer,"def binary_search(list, item): + + low = 0 + high = len(list) - 1 + + while low <= high: + # ... check the middle element + mid = (low + high) // 2 + guess = list[mid] + if guess == item: + return mid + if guess > item: + high = mid - 1 + else: + low = mid + 1 + return None + +my_list = [1,2,0,4,5] +print(binary_search(my_list,5)) # => 1" +p03416,s761089201,Accepted,"A, B = list(map(int, input().split())) + +cnt = 0 +for value in range(A, B+1): + length = len(str(value)) + #print(length) + #print(value) + value_back = """" + for i in range(length): + value_back += str(value)[length - i -1] + if value == int(value_back): + cnt +=1 + #print(int(value_back)) + +print(cnt)" +p02767,s447646797,Accepted,"n=int(input()) +x=list(map(int,input().split())) + +min_=min(x) +max_=max(x) +ans=list() +for xy in range(min_, max_+1): + life=0 + for xx in x: + life+=(xx-xy)**2 + ans.append(life) +print(min(ans))" +p02779,s420105582,Accepted,"n=int(input()) +A=set(map(int, input().split())) +if n==len(A): + print('YES') +else: + print('NO')" +p02813,s196310422,Accepted,"import itertools +N = int(input()) +P,Q = input().rstrip().split("" ""),input().rstrip().split("" "") + +for i in range(N): + P[i],Q[i] = int(P[i]),int(Q[i]) + +seq=list(range(1,N+1)) +a = list(itertools.permutations(seq, N)) + +for i in range(len(a)): + if a[i] == tuple(P): + pindex= i+1 + if a[i] == tuple(Q): + qindex= i+1 + +print(abs(pindex-qindex))" +p03760,s718010801,Wrong Answer,"o=list(input()) +e=list(input()) +n=len(o) +m=len(e) +ans=[] +for i in range(m): + ans.append(o[i]) + ans.append(e[i]) +if n!=m: + ans.append(o[-1]) +print("""".join(ans)) +if """".join(ans)==""aattccooddeerrbreeggiunlnaerrccoonntteesstt"": + print(""a"") +" +p02695,s859344211,Wrong Answer,"n, m, q = map(int, input().split()) + +abcds = [] +for i in range(q): + abcds.append(list(map(int, input().split()))) + +# 数列の作成 +import itertools +items = list(range(1, m+1)) + +combs = itertools.combinations(items, n) +ans = 0 +for comb in combs: + point = 0 + + for abcd in abcds: + if (int(comb[abcd[1]-1])-int(comb[abcd[0]-1]) == abcd[2]): + point += abcd[3] + ans = max(ans, point) + +print(ans)" +p03385,s927554002,Wrong Answer,"S = sorted(input()) +if S == sorted(S): + print('Yes') +else: + print('No')" +p02823,s023889754,Accepted,"N,A,B = map(int,input().split()) +if (B-A)%2: + print(min(B-1, N-A, A+(B-A)//2, N-B+1+(B-A)//2)) +else: + print((B-A)//2)" +p02989,s891373008,Wrong Answer,"N = int(input()) +p = [int(s) for s in input().split()] +sum([ sorted([p1,p2,p3])[1] == p1 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])])" +p02615,s167459406,Accepted,"N=int(input()) +A=list(map(int,input().split())) +A.sort() +A.reverse() +ans=0 + + +ans+=A[0] +if (N-2)%2==0: + ans+=sum(A[1:int((N-2)/2)+1])*2 +else: + ans+=sum(A[1:int((N-3)/2)+1])*2 + ans+=A[int((N-1)/2)] + + +print(ans)" +p02607,s449412428,Accepted,"n = int(input()) +la = [int(w) for w in input().split()] + +ans = 0 + +for i, a in enumerate(la): + if i % 2 == 0 and a % 2 == 1: + ans += 1 +print(ans) +" +p02879,s547846124,Accepted,"A,B = map(int, input().split()) +if A >= 10 or B >= 10: + print(-1) +else: + print(A*B)" +p03041,s250487902,Accepted,"n,k=map(int,input().split()) +s=input() +s=s[:k-1]+s[k-1].lower()+s[k:] +print(s)" +p03309,s613134256,Accepted,"import numpy as np + +N = int(input()) +A = np.array(list(map(int, input().split(' ')))) + +diff = A - (np.arange(N) + 1) +diff.sort() + +if N % 2 == 0: + median = (diff[N // 2] + diff[N // 2 - 1]) // 2 +else: + median = diff[N // 2] + +print(np.sum(np.abs(diff - median))) +" +p02946,s993203472,Accepted,"K,X=list(map(int,input().split())) +Min = max(X - (K -1),-1000000) +Max = min(X + (K-1),1000000) +ans = [] +for i in range(Min,Max+1): + ans.append(i) +ans = map(str,ans) +ans = ' '.join(ans) +print(ans)" +p02833,s482140476,Accepted,"n = int(input()) +if n%2: + print(0) +else: + #2と5があれば10ができる→5の方が少ない→素因数5の数を数える + ans = (n//5)//2 + tmp = 5 + while True: + tmp *= 5 + if tmp > n: + break + ans += (n//tmp)//2 + print(ans)" +p02711,s283482114,Wrong Answer,"N = input() +if ( '5' in N ): + print(""Yes"") +else: + print(""No"") + " +p04012,s500597412,Accepted,"import collections +import sys +import numpy as np +sys.setrecursionlimit(1000000000) +from heapq import heapify,heappop,heappush,heappushpop +MOD = 10**9+7 +import itertools +import math + +w = input() +c = collections.Counter(w) +li = [] +for value in c.values(): + li.append(value) +for i in range(len(li)): + if li[i]%2 != 0: + print(""No"") + sys.exit() +print(""Yes"")" +p03457,s649794382,Accepted,"N = int(input()) + +locx = 0 +locy =0 +time = 0 +for i in range(N): + t,x,y = map(int,input().split()) + nowtime = t-time + dis = abs(locx-x)+abs(locy-y) + if (nowtime-dis)<0 : + print(""No"") + exit() + if (nowtime-dis)%2 == 1: + print(""No"") + exit() + + + time = t + locx = x + locy = y + + +else : + print(""Yes"")" +p02900,s168928214,Accepted,"def prime_factors(n): # 戻り値はiterable type + i = 2 + while i * i <= n: + if n % i: + i += 1 + else: + n //= i + yield i # whileループを進めるごとにイテレータに値を貯め続ける + if n > 1: + yield n + +A, B = map(int, input().split()) + +data = set(prime_factors(A)) & set(prime_factors(B)) +print(len(data) + 1) +" +p03944,s478834726,Accepted,"w,h,n = map(int, input().split()) + +L = 0 +R = w +D = 0 +U = h + +for _ in range(n): + x,y,a = map(int, input().split()) + if a==1: + L = max(L,x) + if a==2: + R = min(R,x) + if a==3: + D = max(D,y) + if a==4: + U = min(U,y) + #print(L, R, D, U) + +x = max(0, R-L) +y = max(0, U-D) +#print(x, y) +ans = x*y + +print(ans)" +p03785,s117359068,Wrong Answer,"N,C,K = map(int, input().split()) +L = [int(input()) for i in range(N)] +cap = 0 +begin = 0 +count = 1 + +for i in range(N): + a = L[i] + if begin == 0: + begin = a + elif a < begin + K and cap < C: + count += 1 + else: + cap = 1 + begin = a + count += 1 +print(count)" +p02742,s634003787,Accepted,"import sys +sys.setrecursionlimit(10 ** 7) + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +H, W = map(int, input().split()) + +al = H * W + +if H == 1 or W == 1: + ans = 1 +elif al % 2 == 0: + ans = al // 2 +else: + ans = (al + 1) // 2 + +print(ans) +" +p02778,s512852758,Accepted,"s = input() + +l = len(s) + +print(""x"" * l) + +" +p03221,s675528624,Accepted,"n,m=map(int,input().split()) + +l=[[] for j in range(n)] +for i in range(m): + p,y=map(int,input().split()) + l[p-1].append([y,i]) +for j in range(n): + l[j].sort(key=lambda x:x[0]) +lis=[] +for j in range(n): + for t in range(len(l[j])): + pre='0'*(6-len(str(j+1)))+str(j+1) + y='0'*(6-len(str(t+1)))+str(t+1) + b=pre+y + lis.append([b,l[j][t][1]]) +lis.sort(key=lambda x:x[1]) +for li in lis: + print(li[0])" +p03109,s427546828,Wrong Answer,"from datetime import datetime +if datetime.strptime(input(), '%Y/%m/%d') >= datetime.strptime('2019/04/30', '%Y/%m/%d'): + print(""TBD"") +else: + print(""Heisei"")" +p03061,s668269323,Accepted,"from fractions import gcd + +NN = 202020 +MOD = 10**9+7 +INF = float(""inf"") + +N = int(input()) +A = list(map(int, input().split())) +left = [0]*N +right = [0]*N + +left[0] = A[0] +for i in range(1, N-1): + left[i] = gcd(left[i-1], A[i]) + +right[-1] = A[-1] +for i in range(N-2, 0, -1): + right[i] = gcd(right[i+1], A[i]) + +# print(left, right) +max_val = max(left[-2], right[1]) +for i in range(1, N-1): + max_val = max(max_val, gcd(left[i-1], right[i+1])) + +print(max_val) +" +p02759,s402014907,Wrong Answer,"N = int(input()) +if N% 2 ==0: + print(N/2) +else: + print(((N-1)/2)+1) +" +p02759,s318540606,Accepted,"n=int(input()) +if n%2==0: + print(int(n//2)) +else: + print(int(n//2)+1)" +p03109,s257466684,Accepted,"S = input() + +y = S[0:4] +m = S[5:7] +d = S[8:10] + +if y < ""2019"": + print(""Heisei"") + +elif (y == ""2019"") and (m < ""04""): + print(""Heisei"") + +elif (y == ""2019"") and (m == ""04"") and (d <= ""30""): + print(""Heisei"") + +elif (y == ""2019"") and (m == ""04"") and (d > ""30""): + print(""TBD"") + +elif (y == ""2019"") and (m >= ""05""): + print(""TBD"") + +elif (y > ""2019""): + print(""TBD"")" +p03327,s663035785,Wrong Answer,"print(['ABC', 'ABD'][len(input())-3])" +p03657,s242033482,Accepted,"a,b=map(int, input().split()) + +print(""Possible"" if (a%3==0 or b%3==0 or (a+b)%3==0) else ""Impossible"")" +p02971,s283003523,Accepted,"n=int(input()) +import copy +l=[int(input()) for i in range(n)] +a=copy.deepcopy(l) +l.sort(reverse=True) +ma=l[0] +sec=l[1] +for i in a: + if i==ma: + print(sec) + else: + print(ma) + +" +p03696,s129542751,Wrong Answer,"N = int(input()) +S = list(input()) +L = 0 +out = [] +for i in range(N): + X = S[i] + if X==""("": + L += 1 + out.append(""("") + elif X=="")"": + if L>0: + L += -1 + out.append("")"") + else: + out.append(""()"") +for i in range(L): + out.append("")"") +print("""".join(out))" +p02607,s824082082,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) + +cnt = 0 +for i in range(n): + if i % 2 == 1: + if a[i] % 2 == 1 : + cnt += 1 + +print(cnt) + +" +p03730,s825587218,Accepted,"a,b,c=map(int,input().split()) + +ans=""NO"" +for i in range(0,b+1): + for j in range(0,a+1): + if a*i == b*j+c: + ans=""YES"" + break + +print(ans) +" +p02767,s219062839,Accepted,"import sys + +N = int(input()) + +line = input().split("" "") +X = [] + +for e in line: + X.append(int(e)) + +ans = sys.maxsize +for P in range(101): + curr = 0 + + for x in X: + curr += (x - P)**2 + + ans = min(ans, curr) + + +print(ans)" +p03838,s298097424,Wrong Answer,"x,y=map(int, input().split()) + +if x<=y: + ans=min(y-x, y-(-x)+1) + +else: + #xの方が大きい + ans=1+abs(abs(x)-abs(y)) + if x*y>0: + ans+=1 +print(ans) + + +" +p03208,s187885403,Accepted,"n,k = map(int,input().split()) +h = [int(input()) for _ in range(n)] + +h.sort() +mi = h[-1] +for i in range(n-k+1): + mi = min(mi,h[i+k-1]-h[i]) +print(mi)" +p02547,s704321029,Accepted,"N = int(input()) +xy = [map(int, input().split()) for _ in range(N)] +x, y = [list(i) for i in zip(*xy)] +ans=""No"" +for i in range(0,N-2): + if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]: + ans=""Yes"" +print(ans)" +p02767,s093457396,Wrong Answer,"n = int(input()) +x = [int(i) for i in input().split()] +x.sort() + +ans = 10000 + +for p in range(x[-1]): + sum =0 + for i in range(n): + sum += (x[i]-p)**2 + + ans = min(ans,sum) + + +print(ans) + " +p03000,s937666549,Accepted,"n, x = map(int, input().split()) +Ls = list(map(int, input().split())) +ans = 1 +target = 0 +for l in Ls: + target += l + if target <= x: + ans += 1 + else: + print(ans) + exit() +print(ans)" +p03555,s100820372,Accepted,"C = list(input() for i in range(2)) +print(""YES"" if C[0]==C[1][::-1] else ""NO"")" +p02647,s105506250,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) +for _ in range(k): + accu = [0]*(n+1) + for i in range(n): + accu[max(i-a[i], 0)] += 1 + accu[min(i+a[i]+1, n)] -= 1 + now = 0 + for i in range(n): + now += accu[i] + a[i] = now + if sum(a)==n*n: + break +print(*a)" +p02861,s749087698,Accepted,"n=int(input()) +plis=[] +llis=[] +for i in range(n): + x,y=map(int,input().split()) + plis.append([x,y]) +for i in range(n): + for j in range(n): + if i (new:=abs(a-co[i][0])+abs(b-co[i][1])): + output = i+1 + tmp = new + print(output) " +p03617,s129737756,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) +x = N % 2 +y = N // 2 +arr = [4*Q*x, 2*H*x, S*x] +arr1 = [8*Q*y, 4*H*y, 2*S*y, D*y] +#if N % 2 == 0: +# arr.append(int(0.5*D*N)) +#else: +# arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q))) + +print(min(arr) + min(arr1))" +p04029,s599743214,Accepted,"# A - キャンディーとN人の子供イージー +# N+(N-1)+.... + +# 子供の人数を入力 +child_number = int(input()) +# print(child_number) + +# 計算 +answer = int(child_number * (child_number + 1) / 2) + +# 表示 +print(answer)" +p02882,s841025226,Accepted,"# 二分法 + +import math + +a,b,x = map(int, input().split()) + +l = 0 +r = math.pi/2 + + + +while r-l>10**(-10): + z = (l+r)/2 + if b*math.tan(z)>a: + flag = b*a**2-a**3/2/math.tan(z) > x + else: + flag = a*b**2*math.tan(z)/2 > x + if flag: + r = z + else: + l = z + +print(90-math.degrees(l)) + + + + + +" +p03042,s731382819,Accepted,"s=input() +s1=int(s[0:2]) +s2=int(s[2:]) + +if (s1==0 or s1>12) and (s2==0 or s2>12): + print(""NA"") +elif (s1>0 and s1<=12) and ((s2>0 and s2<=12)): + print(""AMBIGUOUS"") +elif (s1>0 and s1<=12) and (s2==0 or s2>12): + print(""MMYY"") +else: + print(""YYMM"") +" +p03723,s260276820,Wrong Answer,"A, B, C = map(int, input().split()) +if A == B == C: + print(-1) +else: + cnt = 0 + while A%2 == B%2 == C%2 == 0: + x = B//2+C//2 + y = A//2+C//2 + z = A//2+B//2 + A = x + B = y + C = z + cnt += 1 + print(cnt)" +p02924,s361752864,Wrong Answer,"def resolve(): + n=int(input()) + sum=int((n*(1+n)/2)) + print(sum-n) +resolve()" +p02603,s274699354,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +kane = 1000 +kabu = 0 +if a[0] < a[1]: + kabu = kane // a[0] + kane %= kabu +for i in range(1, n - 1): + if a[i - 1] < a[i]: + kane += a[i] * kabu + kabu = 0 + if a[i] < a[i + 1]: + kabu = kane // a[i] + kane %= a[i] +kane += a[n - 1] * kabu +print(kane)" +p02689,s563621540,Accepted,"n,m = map(int,input().split("" "")) +h = [int(_) for _ in input().split("" "")] + +tmp=[0]*n + +for i in range(m): + a,b = map(int,input().split("" "")) + if h[a-1] > h[b-1]: + if tmp[a-1] != 1: + tmp[a-1]=2 + tmp[b-1]=1 + elif h[a-1] < h[b-1]: + tmp[a-1]=1 + if tmp[b-1] != 1: + tmp[b-1]=2 + else: + tmp[a-1]=1 + tmp[b-1]=1 + +ans=tmp.count(0)+tmp.count(2) + +print(ans)" +p03943,s642011604,Wrong Answer,"a, b, c = map(int, input().split()) + +candies = [] +candies.append(a) +candies.append(b) +candies.append(c) + +max_candy = max(candies) + +candies.remove(max_candy) + +if sum(candies) == max_candy: + print(""YES"") +else: + print(""NO"") +" +p03131,s352700481,Accepted,"k, a, b = map(int, input().split()) +print(k+1 + (k-a+1)//2 * max(0, b-a-2))" +p03324,s826192402,Accepted,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +from collections import Counter, deque +from collections import defaultdict +from itertools import combinations, permutations, accumulate, groupby, product +from bisect import bisect_left,bisect_right +from heapq import heapify, heappop, heappush +from math import floor, ceil +from operator import itemgetter +def printns(x): print('\n'.join(x)) +def printni(x): print('\n'.join(list(map(str,x)))) +def I(): return int(input()) +def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) +def LI2(): return [int(input()) for i in range(n)] +def MXI(): return [[LI()]for i in range(n)] +inf = 10**17 +mod = 10**9 + 7 + + +d,n=MI() +ans=100**d*(n+n//100) +print(ans)" +p04043,s435755394,Wrong Answer,"iroha = input() +iroha = iroha.split("" "") +iroha = sorted(iroha) +print(iroha)" +p02832,s936443774,Accepted,"n=int(input()) +A=list(map(int,input().split())) +now=1 +ans=0 +for i in A: + if i!=now: + ans+=1 + else: + now+=1 +if now==1: + print(-1) +else: + print(ans)" +p03632,s308313669,Accepted,"#ABC 070B + +a,b,c,d = map(int,input().split()) + +if a < c: + if min(b,d)-min(b,c) < 0: + print(0) + else: + print(min(b,d)-min(b,c)) +else: + if min(b,d)-min(a,d) < 0: + print(0) + else: + print(min(b,d)-min(a,d)) + +" +p02719,s873979240,Accepted,"n, k = map(int, input().split()) + +print(min(n, n % k, abs((n % k) - k))) +" +p02690,s511589117,Accepted,"X = int(input()) + +def make_divisors(n): + divisors = [] + for i in range(1, int(n**0.5)+1): + if n % i == 0: + divisors.append(i) + if i != n // i: + divisors.append(n//i) + + # divisors.sort() + return divisors + +d = make_divisors(X) + +ans =[0,0] + +for i in d: + + for j in range(-10000,10000): + if j**5 - (j-i)**5 == X: + print(j,j-i) + exit()" +p03380,s920295322,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +a.sort(reverse=True) + +tmp = 0 +num = 0 +for i in range(n): + if(a[i] >= a[0]//2): + aa = a[0]-a[i] + if(aa > tmp): + tmp = aa + num = a[i] + else: + if(a[i] > tmp): + tmp = aa + num = a[i] + +print(a[0], num)" +p02615,s727879102,Accepted,"N = int(input()) +A = sorted(list(map(int, input().split()))) +# A = sorted(list(map(int, input().split())), reverse=True) + + +# print(A) + +idx = [] +for i in range(N + 1 // 2): + idx.append(i) + idx.append(i) + +idx = idx[::-1] +idx = idx[1:N] +# print(idx) +ans = 0 +for i in idx: + ans += A[i] +print(ans) +" +p03262,s900277963,Wrong Answer,"from math import gcd +N,X=map(int,input().split()) +x=list(map(int,input().split())) + +if N==1: + print(abs(X-x[0])) + +else: + l=[] + for i in range(N-1): + l_=abs(x[i+1]-x[i]) + l.append(l_) + #print(l) + ans=l[0] + for i in range(1,len(l)): + ans=gcd(ans,l[i]) + + print(ans)" +p02707,s983245448,Wrong Answer,"N = int(input()) + +A = list(map(int,input().split())) + +sum = 0 +for i in range(N): + print(A.count(i+1)) + sum += A.count(i+1) + if sum == (N-1): + break" +p03625,s222964399,Accepted,"from collections import Counter +n = int(input()) +a = list(map(int,input().split())) +c = Counter(a) +d = [0,0] +for i in c: + if c[i]>1: + d.append(i) + if c[i]>3: + d.append(i) +d.sort() +print(d[-1]*d[-2])" +p03427,s235448600,Wrong Answer,"r = input() +# print(r) +if len(str(int(r)+1)) == len(r)+1: + print(len(r)*9) +if r[0] == 1: + print((len(r)-1)*9) +else: + print(int(r[0])-1+(len(r)-1)*9)" +p03767,s621931102,Wrong Answer,"n = int(input()) +l = sorted(list(map(int,input().split()))) +print(sum(l[n:-n]))" +p02675,s409191499,Accepted,"data = input() +name = ['pon','pon','hon', 'bon','hon','hon','pon','hon','pon','hon'] +print(name[int(data[-1])])" +p03543,s123310012,Accepted,"n = input() +if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]: + print('Yes') +else: + print('No')" +p02823,s864434355,Accepted,"N, A, B = map(int, input().split()) + +if abs(A-B) % 2 == 0: + print(abs(A-B)//2) + +else: + ans1 = min(A, B) + (max(A, B)-min(A, B)-1)//2 + ans2 = N-max(A, B)+1 + (N-min(A, B) - (N-max(A, B)) -1)//2 + print(min(ans1, ans2))" +p03059,s057940191,Accepted,"a,b,t=map(int,input().split()) +print(int((t//a)*b))" +p03495,s534771341,Accepted,"from collections import Counter + + +n, k = map(int, input().split()) +m = Counter(input().split()) +print(sum(sorted(m.values(), reverse=True)[k:])) +" +p02899,s568598388,Wrong Answer,"def main(): + N = int(input()) + A = list(map(int, input().split())) + + re = [] + + for i in range(N): + re.insert(A[i] - 1, i + 1) + + print(*re) + + +if __name__ == ""__main__"": + main() +" +p03328,s455733763,Accepted,"import bisect + +a, b = map(int, input().split()) + +towers = [] +last = 0 +for i in range(1, 1000): + towers.append(last+i) + last += i + +diff = b - a + +print(towers[diff-1] - b)" +p02779,s983832920,Accepted,"N=int(input()) +A=list(map(int,input().split())) +import collections + +c = collections.Counter(A) +c = c.most_common() +if c[0][1] == 1: + print(""YES"") +else: + print(""NO"")" +p02813,s764870704,Accepted,"from itertools import permutations + +N = int(input()) +P = tuple(map(int, input().split())) +Q = tuple(map(int, input().split())) + +perm = list(permutations(range(1, N+1), N)) +print(abs(perm.index(P) - perm.index(Q))) +" +p02600,s832840241,Wrong Answer,"s = int(input()) +if(s >=1800 and s<2000): + print(1) +elif(s>=500 and s<800): + print(7) +elif(s>=800 and s<1000): + print(6) +elif(s>=1000 and s<1200): + print(5) +elif(s>=1200 and s<1400): + print(4) +elif(s>=1400 and s<1600): + print(3) +elif(s>=1600 and s<1800): + print(2) +else: + print(8) +" +p02766,s165442587,Accepted,"n, k = map(int,input().split()) + +if n == 1: + print(1) +else: + a=1 + ans = 0 + while a<=n: + a *=k + ans += 1 + + print(ans) +" +p02866,s951237440,Accepted,"#! /usr/bin/env python3 + +from fractions import gcd +# from math import gcd +from collections import Counter, deque, defaultdict +from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge +from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort +from itertools import accumulate, product, permutations, combinations, combinations_with_replacement + +ans = lambda x : x % 998244353 +MOD = 998244353 + +N = int(input()) +D = [int(_) for _ in input().split()] + +c = Counter(D) + +ans = 1 * (not D[0]) * (c[0] == 1) +for i in range(1, max(c.keys())+1): + ans *= pow(c[i-1], c[i], MOD) + ans %= MOD + +print(ans) +" +p02618,s284533027,Accepted,"d = int(input()) +c = list(map(int,input().split())) +ans = [] +for i in range(d): + s = list(map(int,input().split())) + ans += [s.index(max(s))+1] +for i in ans: + print(1)" +p04005,s951660814,Accepted,"A,B,C = map(int,input().split()) + +if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: + ans = 0 +else: + ans = min(A*B,B*C,C*A) +print(ans)" +p03910,s914437382,Wrong Answer,"n = int(input()) +s = set() + +sub = 1 +while n != 0: + new = n - sub + if new not in s: + print(sub) + s.add(sub) + n = new + sub += 1" +p03623,s074625226,Accepted,"x, a, b = map(int, input().split()) +if abs(a-x) < abs(b-x): + print('A') +else: + print('B')" +p02719,s998216424,Accepted,"N, K = map(int, input().split()) + +if NK/2: + print(K-N) + else: + print(N) + +elif N==K: + print(0) +else: + amari = N%K + if amari>K/2: + print(K-amari) + else: + print(amari)" +p02848,s379056413,Accepted,"n = int(input()) +s = input() +s = list(s) +a = '' +for i in range(len(s)): + if 'A' <= chr(ord(s[i]) + n) and chr(ord(s[i]) + n) <= 'Z': + s[i] = chr(ord(s[i]) + n) + else: + s[i] = chr(ord('A') + (ord(s[i]) + n) % (ord('Z') + 1)) + a += s[i] +print(a)" +p04011,s315547973,Wrong Answer,"N,K,X,Y=[int(input()) for i in range(4)] + +if(K>N): + N=K +else: + N=N +Z=K*X+(N-K)*Y +print(Z)" +p03000,s475281287,Accepted,"a,b=map(int,input().split()) +arr=list(map(int,input().split())) +c=1 +s=0 +for i in range(a): + s+=arr[i] + if s<=b: + c+=1 + else: + break + +print(c) " +p02972,s732298178,Accepted,"N = int(input()) +a = [0]+list(map(int, input().split())) +b = [0 for _ in range(N+1)] + +for i in reversed(range(1, N+1)): + tmp = 0 + for j in range(i, N+1, i): + tmp += b[j] + + if(tmp%2 == a[i]): + b[i] = 0 + else: + b[i] = 1 + + +ans = [] +for i, j in enumerate(b): + if(j == 1): + ans.append(i) +print(len(ans)) +if(len(ans)): + print(*ans)" +p02773,s542747915,Accepted,"n = int(input()) +d = dict() + +for _ in range(n): + s = input() + + if s in d: + d[s] += 1 + else: + d[s] = 1 + + +items = list(d.items()) +max_num = max([v[1] for v in items]) +ans = [] + +for k,v in items: + if max_num == v: + ans.append(k) + +ans.sort() + +for v in ans: + print(v) +" +p02911,s781702631,Accepted,"n, k, q = map(int, input().split()) +a = [int(input()) for _ in range(q)] + +score = [0]*n +for i in a: + score[i-1] += 1 + +for i in range(n): + print(""Yes"") if k-q+score[i] > 0 else print(""No"")" +p02687,s719173165,Accepted,"def main(): + from builtins import int, map, list, print + import sys + sys.setrecursionlimit(10 ** 6) + S = input() + print(['ABC', 'ARC'][S == 'ABC']) + + +if __name__ == '__main__': + main() +" +p02630,s675093315,Accepted,"#!/usr/bin/env python3 +from collections import Counter + +n = int(input()) +a = list(map(int, input().split())) +q = int(input()) +cnt = Counter(a) +s = sum(a) +for _ in range(q): + b, c = map(int, input().split()) + s += (c - b) * cnt[b] + cnt[c] += cnt[b] + cnt[b] = 0 + print(s) +" +p02873,s251368023,Accepted,"S = input() + +s = S.replace('<>', '<,>').replace('><', '>,<').split(',') +lst = [ss.count('<') - ss.count('>') for ss in s] + +ans = [0] + +for i in lst: + if i > 0: + ans += list(range(1,i+1)) + else: + ans[-1] = max(ans[-1], -i) + ans += list(range(-i-1,-1, -1)) + +print(sum(ans)) +" +p04011,s700742233,Accepted,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) + +sum = 0 +for i in range(0,n): + if i= N: + print(c[i]) + sys.exit()" +p03795,s872631220,Accepted,"N = int(input()) + +x = 800 * N +y = 200 * (N // 15) + +total_Money = x - y +print(total_Money)" +p03264,s223916473,Wrong Answer,"k=int(input()) +if k % 2 == 0: + print(k / 2 * k / 2) +else: + print(k // 2 * (k // 2 + 1))" +p03329,s585249888,Accepted,"N = int(input()) + +P = [1] + +for i in range(1, N): + if 6**i > N: + break + P.append(6**i) + +for i in range(1, N): + if 9**i > N: + break + P.append(9**i) + +P.sort() + +DP = [float('inf')] * (N + 1) +DP[0] = 0 +for i in range(N): + for p in P: + if i + p > N: + break + DP[i+p] = min(DP[i+p], DP[i] + 1) +print(DP[N]) +" +p03252,s788449091,Accepted,"from collections import defaultdict + +s = input() +t = input() + +dicts = defaultdict(int) +dictt = defaultdict(int) + +cs = [] +ct = [] + +for i in range(len(s)): + dicts[s[i]] += 1 + dictt[t[i]] += 1 + cs.append(dicts[s[i]]) + ct.append(dictt[t[i]]) + + +if cs == ct: + print('Yes') +else: + print('No')" +p03836,s873309879,Accepted,"def main(): + sx, sy, tx, ty = map(int, input().split()) + vert = ty - sy + hor = tx - sx + ans = 'U'*vert + 'R'*hor + 'D'*vert + 'L'*hor + ans += 'L' + 'U'*(vert+1) + 'R'*(hor+1) + 'D' + ans += 'R' + 'D'*(vert+1) + 'L'*(hor+1) + 'U' + print(ans) +main()" +p02661,s558846280,Accepted,"n = int(input()) +al = [0] * n +bl = [0] * n +for i in range(n): + al[i], bl[i] = map(int, input().split()) + +al.sort() +bl.sort(reverse=True) + +if n % 2 == 0: + print((bl[n//2-1] - al[n//2-1])+((bl[n//2] - al[n//2])+1)) +else: + print(bl[n//2] - al[n//2]+1) +" +p02594,s768019963,Wrong Answer,"n = int(input()) + +if n ==30: + print('Yes') +else: + print('No')" +p03359,s637568170,Accepted,"a,b=map(int,input().split()) +if a>b: + print(a-1) +else: + print(a)" +p03252,s203271649,Accepted,"#!/usr/bin/env python3 +S = input().strip() +T = input().strip() + +trans = dict() +ans = True +for s, t in zip(S, T): + if trans.get(s, t) != t: + ans = False + break + trans[s] = t + +# print(trans) +print('Yes' if ans and len(set(trans.values())) == len(trans) else 'No')" +p02811,s823674337,Accepted,"K, X = map(int, input().split()) + +if(K * 500 >= X): + print(""Yes"") +else: + print(""No"")" +p03017,s291334937,Accepted,"n, a, b, c, d = map(int, input().split()) +s = list(input()) + +cant = False +if c>d: + cant = True + for i in range(max(0,b-2), min(d-1, n-2)): + if s[i]==s[i+1]==s[i+2]=='.': cant = False + +for i in range(b-1, d-1): + if s[i]==s[i+1]=='#': cant = True +for i in range(a-1, c-1): + if s[i]==s[i+1]=='#': cant = True + +print(""YNeos""[cant::2])" +p02768,s567010099,Accepted,"from functools import reduce + +def cmb(n,r,p): + r = min(n-r,r) + if r == 0: + return 1 + num = reduce(lambda x, y: (x*y)%p, range(n,n-r,-1)) + den = reduce(lambda x, y: (x*y)%p, range(1,r+1)) + return (num * pow(den,p-2,p)) % p + +m = 10**9 + 7 +n,a,b = map(int, input().split()) +ans = pow(2,n,m) - 1 +ans -= cmb(n,a,m) + cmb(n,b,m) +print(ans % m)" +p03317,s614149616,Accepted,"from math import ceil +N, K = map(int, input().split()) +A = list(map(int, input().split())) +ans = ceil((N-1)/(K-1)) +print(ans)" +p03469,s071484547,Accepted,""""""" +author : halo2halo +date : 24, Jan, 2020 +"""""" + +import sys +import itertools + +# import numpy as np + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +N=readline().decode('utf8') +S=N[:3]+'8'+N[4:] +print(S) +" +p03105,s293646207,Accepted,"A, B, C = map(int, input().split()) +print(C if C * A <= B else B // A) +" +p02719,s422451635,Wrong Answer,"import sys +n, k = list(map(int, input().split())) + +if (k == 1): + print(0) + sys.exit() + +s, a = divmod(n, k) + +ans = 0 +if (a == 0): + ans = s +else: + ans = a + +print(ans) +" +p02880,s224572906,Accepted,"from sys import exit +n=int(input()) +for i in range(1,10): + for j in range(1,10): + if i*j==n: + print(""Yes"") + exit() +print(""No"")" +p03035,s942131552,Wrong Answer,"a, b = map(int, input().split()) +if a >= 13: + print(b) +elif a >=6 and a < 13: + print(b/2) +else: + print(""0"") +" +p02842,s445722862,Accepted,"n = int(input()) +x0 = int(n/1.08) +if int(x0*1.08) == n: + print(x0) +elif int((x0+1)*1.08) == n: + print(x0+1) +else: + print(':(')" +p02793,s876185148,Wrong Answer,"#a,bの最大公約数 +def gcd(a, b): + while b: + a, b = b, a % b + return a +def lcm(x, y): + return x / gcd(x, y) * y +n=int(input()) +a=list(map(int,input().split())) +mod = 10**9+7 +lc=1 +for i in range(n): + lc = lcm(lc,a[i]) +print(lc) +print(a) +a = list(map(lambda x : (lc/x)%mod,a)) +print(a) +print(sum(a)%mod) +" +p02678,s836165548,Accepted,"from collections import deque + +N, M = map(int, input().split()) +G = [[] for _ in range(N)] + +for _ in range(M): + a, b = map(int, input().split()) + a, b = a-1, b-1 + G[a].append(b) + G[b].append(a) + +q = deque([0]) +dist = [-1]*N +dist[0] = 0 + +while q: + v = q.popleft() + for nv in G[v]: + if dist[nv] == -1: + dist[nv] = v+1 + q.append(nv) + +print(""Yes"") +print(*dist[1:], sep=""\n"") +" +p03861,s072812187,Accepted,"a, b, x = map(int, input().split()) +print(b // x - (a + x - 1) // x + 1) +" +p02726,s744424082,Wrong Answer,"N, X, Y = map(int, input().split()) + +lists = [0] * (N - 1) + +for i in range(N - 1): + for j in range(i + 1, N): + min_length = min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X)) + lists[min_length - 1] += 1 + +for k in lists: + print(k) + " +p02742,s722327832,Wrong Answer,"import math +H, W = map(int, input().split()) +print(math.ceil(H * W / 2))" +p03449,s039921205,Wrong Answer,"n = int(input()) +l = [] +for _ in range(2): + a = list(map(int,input().split())) + l.append(a) + +if n == 1: + print(l[0][0]+l[1][0]) + exit() + +m1 = [] +m2 = [] +m1.append(l[0][0]) +m2.append(l[1][0]) + +for i in range(1,n): + m1.append(m1[i-1]+l[0][i]) + m2.append(m2[i-1]+l[1][i]) + +ans = [0]*n +for j in range(n): + ans[j] = m1[j]+(m2[n-1]-m2[j-1]) + +print(max(ans))" +p02661,s887046647,Accepted,"n = int(input()) +A = [0]*n +B = [0]*n +for i in range(n): + a,b = map(int, input().split()) + A[i] = a + B[i] = b +A.sort() +B.sort(reverse=True) +if n%2 == 1: + ans = B[(n+1)//2-1]-A[(n+1)//2-1]+1 + print(ans) +else: + y = A[n//2-1] + A[n//2] + x = B[n//2-1] + B[n//2] + ans = x-y+1 + print(ans)" +p02765,s381017148,Accepted,"time,rate = map(int,input().split()) +ans = 0 +if time >= 10: + ans = rate +else: + ans = rate + 100*(10 - time) +print(ans)" +p02767,s929349414,Wrong Answer,"import numpy as np +import math + +N = list(map(int, input().split())) +X = list(map(int, input().split())) + + +P = N[0]//2 + +suma = 0 +for a in range(N[0]): + suma = suma + (X[a] + P)**2 + +Q = (N[0]//2)+1 +sumb = 0 +for b in range(N[0]): + sumb = sumb + (X[b] + Q)**2 +if suma < sumb: + print(suma) +else: + print(sumb)" +p03951,s959961550,Wrong Answer,"n=int(input()) +s=input() +t=input() +ans=0 +for i in range(n): + print(i,s[i:],t[:n-i]) + if s[i:] == t[:n-i]: + ans = max(n-i,ans) +print(2*n-ans)" +p03699,s488134420,Accepted,"n = int(input()) +sl = list(int(input()) for _ in range(n)) +sl_sum = sum(sl) +sl.sort() + +ans = 0 + +if sl_sum % 10 != 0: + ans = sl_sum +else: + for s in sl: + if (sl_sum - s)%10 != 0: + ans = max(sl_sum - s, ans) + +print(ans)" +p02676,s566331266,Wrong Answer,"k = int(input()) +s = input() + +if len(s) <= k: + print(s) +else: + print(s[:7] + '...') +" +p02784,s150048775,Accepted,"n,m=map(int,input().split()) +l=list(map(int,input().split())) +if(sum(l)>=n): + print(""Yes"") +else: + print(""No"")" +p02761,s829648638,Wrong Answer,"import sys +N, M = [int(x) for x in input().split()] + +digits = {x+1: 0 for x in range(N)} +for _ in range(M): + s, c = [int(x) for x in input().split()] + if s == 1 and c == 0: + if N != 1: + print(-1) + sys.exit() + if digits.get(s, -1) not in [c, 0]: + print(-1) + sys.exit() + digits[s] = c + +result = 0 +n = 0 +for i in sorted(digits.keys(), reverse=True): + result += digits[i] * (10 ** n) + n += 1 +print(result) +" +p03785,s080218022,Accepted,"n, c, k = map(int, input().split()) +t = [] +for _ in range(n): + t.append(int(input())) +t.sort() +first = t[0] +wait = 0 +need = 1 +for i in t: + wait += 1 + if first + k < i or wait > c: + need += 1 + wait = 1 + first = i + continue +print(need)" +p03107,s246061867,Wrong Answer,"s = input() + +print(max(s.count(""1""), s.count(""0"")) * 2) +" +p04031,s764217958,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +mn=10**18 +for i in range(-100,101): + sm=0 + for k in range(n): + sm+=(a[k]-i)**2 + mn=min(sm,mn) + +print(mn)" +p02888,s086201226,Accepted," +N = int(input()) +L = sorted(list(map(int, input().split()))) + +from bisect import bisect_left + +ans = 0 +for c in range(2, N): + for a in range(c-1): + b_index = bisect_left(L, L[c]-L[a]+1) + + if b_index <= a: + b_index = a + 1 + if c - b_index > 0: + ans += c - b_index + +print(ans)" +p02973,s652856878,Accepted,"n = int(input()) + +colors = [] + +for i in range(n): + a = int(input()) + if i == 0: + colors.append(a) + continue + if colors[-1] >= a: + colors.append(a) + elif a > colors[0]: + colors[0] = a + else: + l, r = 0, len(colors) + while r-l > 1: + k = (r+l)//2 + if a > colors[k]: + r = k + else: + l = k + if a > colors[l]: + colors[l] = a + else: + colors[r] = a + +print(len(colors))" +p03360,s356944027,Accepted,"li = list(map(int,input().split())) +k = int(input()) +li.sort() +ans = li[2]*(2**k)+li[0]+li[1] +print(ans)" +p03723,s149234112,Wrong Answer,"a, b, c = map(int, input().split()) +if a == b and b == c: + if a%2 == 0: + print(-1) + else: + print(0) +else: + ans = 0 + while a % 2 == 0 and b % 2 == 0: + a1 = a + b1 = b + c1 = c + a = (b1+c1)/2 + b = (a1+c1)/2 + c = (a1+b1)/2 + ans += 1 + print(ans)" +p03835,s820532062,Accepted,"k, s = map(int, input().split()) + +ans = 0 +for x in range(k+1): + for y in range(k+1): + z = s-x-y + if 0 <= z and z <= k: + ans += 1 +print(ans)" +p02553,s450494306,Accepted,"a,b,c,d=[int(i) for i in raw_input().split()] +print max(a*c,a*d,b*c,b*d) +" +p02971,s248589308,Accepted,"import sys + +N = int(input()) +A = [] +for i in range(N): + A.append(int(input())) +M = sorted(A) +if M[-1] == M[-2]: + for i in range(N): + print(M[-1]) + sys.exit() +high_num = M[-1] +for i in range(N): + if A[i] == high_num: + print(M[-2]) + else: + print(M[-1]) +" +p02787,s696727862,Accepted,"H,N = map(int,input().split()) +dp= [float(""INF"")]*(H+1) +dp[0]=0 +for i in range(N): + a,b = map(int,input().split()) + for j in range(1,H+1): + dp[j] = min(dp[j],dp[max(j-a,0)]+b) + +print(dp[-1])" +p03711,s468944743,Accepted,"x, y = map(int, input().split()) +l1= [1,3,5,7,8,10,12] +l2=[4,6,9,11] +l3=[2] +if x in l1 and y in l1: + print('Yes') +elif x in l2 and y in l2 : + print('Yes') +else : + print('No')" +p02829,s864896231,Accepted,"a = int(input()) +b = int(input()) +q =[1,2,3] +q.remove(a) +q.remove(b) +print(q[0])" +p03106,s155731351,Wrong Answer,"a,b,k =map(int ,input().split()) +n =[] +for i in range(1 ,100): + if a %i ==0 and b %i ==0: + n.append(i) +n.sort(reverse =True) +print(n[k-1])" +p02771,s565822590,Accepted,"A,B,C=map(int,input().split()) + +if(A==B and (B==C and A==C)): + print(""No"") + +elif(A!=B and (B!=C and A!=C)): + print(""No"") +else: + print(""Yes"")" +p03693,s040377704,Accepted,"r,g,b = input().split() +l = int(r+g+b) +print(""YES"" if l%4 == 0 else ""NO"")" +p02607,s846788023,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = 0 +for i in range(0, N, 2): + if A[i] % 2 == 1: + ans += 1 + +print(ans) +" +p03487,s984478419,Accepted,"def mycounter(d,i): + if i in d: + d[i]+=1 + else: + d[i]=1 + return d + +n=int(input()) +a=list(map(int,input().split())) +d=dict() +for i in a: + d=mycounter(d,i) +p=0 +for i,j in d.items(): + if ij: + p+=j +print(p)" +p03221,s450358869,Accepted,"from collections import defaultdict + +n, m = map(int, input().split()) +yp = [] +for i in range(m): + p, y = map(int, input().split()) + yp.append((y, p, i)) +yp = sorted(yp) + +code = [0] * m +ctr = defaultdict(int) +for i in range(m): + ctr[yp[i][1]] += 1 + x = ctr[yp[i][1]] + code[yp[i][2]] = '{:06}{:06}'.format(yp[i][1], x) +for c in code: + print(c)" +p02618,s932986855,Accepted,"for i in range(365): + print(i%26+1)" +p03774,s897768550,Accepted,"n,m=map(int,input().split()) +ls=[list(map(int,input().split())) for _ in range(n)] +lc=[list(map(int,input().split())) for _ in range(m)] + +for i in range(n): + p=0 + ans=10**9 + for j in range(m): + dis=abs(lc[j][1]-ls[i][1])+abs(lc[j][0]-ls[i][0]) + if ans>dis: + ans=dis + p=j+1 + print(p) + + + " +p03721,s733266627,Wrong Answer,"N, T = map(int, input().split()) +A=[0]*N +B=[0]*N +for i in range(N): + a,b=map(int,input().split()) + A[i]=a + B[i]=b + +count=0 +for i in range(N): + count=count+B[i] + if count>=T: + print(A[i]) + exit()" +p03221,s255221883,Accepted,"n, m = map(int, input().split()) + +arr = [[] for _ in range(n)] + +p = [0] * m +y = [0] * m + +for i in range(m): + p[i], y[i] = map(int, input().split()) + arr[p[i]-1].append(y[i]) + +for i in range(n): + arr[i].sort() + +import bisect +for i in range(m): + num = bisect.bisect_left(arr[p[i]-1], y[i]) + 1 + a = str(p[i]) + b = str(num) + print(a.zfill(6) + b.zfill(6)) +" +p03623,s375533095,Wrong Answer,"x, a, b = map(int, input().split()) +print(min([abs(x-a), abs(x-b)]))" +p03971,s507793414,Accepted,"N, A, B = map(int, input().split()) +S = input() +cnt = 0 +cnt1 = 0 +for i in range(len(S)): + if S[i]==""a"" or S[i]==""b"": + if S[i]==""a"" and cnt= 0: + print(n) +else: + print(-1) +" +p03329,s516880876,Wrong Answer,"from functools import * +@lru_cache(maxsize=None) +def f(x): + if x==1:return 1 + s=1000000000 + for u in [1]+[6**i for i in range(1,11)]+[9**i for i in range(1,11)]: + if x-u>=1: + s=min(s,f(x-u)+1) + return s +for i in range(1,100001):f(i) +print(f(int(input())))" +p03633,s065970926,Accepted,"from fractions import gcd +N = int(input()) +ans = 1 +for _ in range(N): + t = int(input()) + ans = t * ans // gcd(t, ans) +print(ans)" +p02576,s891985294,Accepted,"n,x,t=map(int,input().split(' ')) +if n%x==0: + print((n//x)*t) +else: + print(((n//x)+1)*t) +" +p02607,s488957470,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +count = 0 +for i in range(N): + if A[i] % 2 != 0 and i%2!=0: + count += 1 +print(count)" +p02989,s833191555,Accepted,"K = int(input()) +problems = list(map(int,input().split())) + +problems.sort() + +divider = K // 2 +ABC = problems[:divider] +ARC = problems[divider:] + +print(ARC[0] - ABC[-1]) +" +p03761,s019114921,Accepted,"from collections import Counter +n = int(input()) +S = [input() for _ in range(n)] + +count = Counter(S[0]) +for s in S[1:]: + c = Counter(s) + count = count & c + +ls = sorted(count.items()) + +ans = """" +for i, j in ls: + ans += i * j + +print(ans)" +p03797,s184598953,Accepted,"import sys + +n, m = map(int, sys.stdin.readline().split()) + +def main(): + if n >= m // 2: res = m // 2 + else: res = n + (m - 2 * n) // 4 + print(res) + +if __name__ == '__main__': + main()" +p04019,s929292324,Accepted,"s = list(set(list(input()))) + +if len(s)%2 == 0: + if (""N"" in s and""S"" in s) or (""E"" in s and ""W"" in s): + print('Yes') + else: + print('No') +else: + print('No')" +p03778,s827210053,Accepted,"w, a, b = map(int, input().split()) +if a <= b and b <= a+w: + print(0) +elif b <= a+w and a <= b: + print(0) +else: + print(min(abs(a-b-w), abs(a+w-b)))" +p02953,s188665356,Accepted,"N = int(input()) +H = list(map(int, input().split())) + +prev = H[0] +flag = True +for i in range(N-1): + now = H[-i-1] + after = H[-i-2] + if after - now > 1: + flag = False + break + elif after - now == 1: + H[-i-2] -= 1 + else: + pass +print('Yes') if flag else print('No')" +p02691,s516207636,Accepted,"from collections import defaultdict +N = int(input()) +A = list(map(int, input().split())) + +cnt = defaultdict(int) +ans = 0 +for i, a in enumerate(A, start=1): + ans += cnt[-a + i] + cnt[a + i] += 1 + +print(ans) +" +p03545,s514640559,Accepted,"import itertools +a,b,c,d = list(input()) + + +for ops in itertools.product(['+','-'],repeat=3): + eq = a+ops[0]+b+ops[1]+c+ops[2]+d + x = eval(eq) + + if x==7: + break + +answer = eq+'=7' +print(answer)" +p02606,s078373928,Accepted,"def main(): + left, right, div = [int(x) for x in input().split()] + ans = sum(x % div == 0 for x in range(left, right + 1)) + print(ans) + + +if __name__ == '__main__': + main() +" +p04043,s096869360,Wrong Answer,"if list(map(int,input().split())).sort()==[5,5,7]: + print(""YES"") +else: + print(""NO"")" +p03073,s589240678,Wrong Answer,"s=input() +i=0 +c=0 +l=len(s) +while i 0: + n = n - bl -re + ans += bl +if bl == 0 or n < 0: + print(round(ans)) +elif bl >= n: + ans = ans + n + print(round(ans))" +p03243,s135714639,Accepted,"N = input() + +print(str(int(N[0]) + 1) * 3 if int(N[0] * 3) < int(N) else N[0] * 3)" +p03001,s755604038,Wrong Answer,"A, B, C, D = map(int, input().split()) +S = A*B//2 +if A%2==1 and B%2==1: + S += 0.5 + +ans = 0 +if C == A//2 and D == B//2: + ans = 1 +print(S,ans)" +p03815,s183115244,Accepted,"x = int(input()) + +if x % 11 == 0: + ans = x//11 * 2 +elif x % 11 > 6: + ans = x//11 * 2 + 2 +else: + ans = x//11 * 2 + 1 +print(ans)" +p03136,s104832400,Accepted,"n=int(input()) +l=list(map(int,input().split())) + +l.sort(reverse=True) +if l[0]= l or b >= l: + print(""Yes"") +else: + print(""No"")" +p02681,s821371690,Accepted,"# A +S = input() +T = input() +ans = 'No' +if S == T[:-1]: + ans = 'Yes' +print(ans)" +p02836,s056732690,Wrong Answer,"s = input() +n = len(s) +n //= 2 +ans = 0 +for i in range(n): + if not s[i] == s[n-i-1]: + ans += 1 + +print(ans)" +p03545,s622195024,Wrong Answer,"a=list(input()) +for i in range(4): + a[i]=int(a[i]) +x=sum(a)-7 +dict={0:'+',1:'-'} +for i in range(2): + for j in range(2): + for k in range(2): + if x==(i*a[1]+j*a[2]+k*a[3])*2: + print(a[0],dict[i],a[1],dict[j],a[2],dict[k],a[3],'=7',sep='') + break" +p02717,s627191112,Accepted,"al = list(map(int, input().split())) + +print(al[2], al[0], al[1]) +" +p02696,s178270594,Accepted,"#create date: 2020-05-02 21:18 + +import sys +stdin = sys.stdin + +def ns(): return stdin.readline().rstrip() +def ni(): return int(ns()) +def na(): return list(map(int, stdin.readline().split())) + +def main(): + a, b, n = na() + x = min(n, b - 1) + ans = a * x // b - a * ( x // b) + print(ans) + +if __name__ == ""__main__"": + main()" +p02917,s869629788,Accepted,"N = int(input()) +#6 +B = [int(i) for i in input().split()] +# 153 10 10 23 + +A = [0]*N + +A[0] = B[0] +A[N-1] = B[N-2] + +for i in range(1,N-1): + A[i] = min(B[i],B[i-1]) + +print(sum(A))" +p02700,s725902700,Wrong Answer,"a,b,c,d = list(map(int,input().split())); + +if a//d < c//b : + print('Yes'); +else : + print('No');" +p02615,s366663924,Accepted,"def main(): + N = int(input()) + A = list(map(int, input().split())) + A.sort(reverse=True) + r = A[0] + for i in range(1, N//2): + r += 2 * A[i] + if N % 2 == 1: + r += A[N//2] + return r +print(main()) +" +p03730,s694705150,Accepted,"import sys +A, B, C = map(int, input().split()) +N = A +while N < A * B: + if N % B == C: + print('YES') + sys.exit() + N += A +print('NO')" +p02627,s525407230,Accepted,"s = input() +t = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"" +for i in t: + if s == i: + print(""A"") + break +else: + print(""a"")" +p03672,s987387882,Accepted,"s = input() + +while len(s) > 2: + s = s[:-2] + n = len(s) // 2 + if s[:n] == s[n:]: + print(len(s)) + exit(0) +print(1) +" +p02695,s278101856,Accepted,"import itertools +N, M, Q = map(int, input().split()) +abcd = [list(map(int, input().split())) for i in range(Q)] +ans = 0 +for A in itertools.combinations_with_replacement(range(1, M+1), N): + score = [] + for i in range(Q): + a = abcd[i][0] + b = abcd[i][1] + c = abcd[i][2] + d = abcd[i][3] + if A[b-1]-A[a-1] == c: + score.append(d) + ans = max(ans,sum(score)) +print(ans) +" +p02578,s738518456,Wrong Answer,"#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def main(): + N = int(input()) + A = list(map(int, input().split())) + ans = 0 + + for i in range(N - 1): + diff = A[i] - A[i - 1] + if diff > 0: + ans += diff + print(ans) + + +if __name__ == ""__main__"": + main() +" +p02613,s577855416,Wrong Answer,"n=int(input()) + +judge_list=[] +for i in range(n): + a=input() + judge_list.append(a) + +ac=judge_list.count('AC') +ac=str(ac) +wa=judge_list.count('WA') +wa=str(wa) +tle=judge_list.count('TLE') +tle=str(tle) +re=judge_list.count('RE') +re=str(re) + +print(""AC""+"" ""+""×""+"" ""+ac) +print(""WA""+"" ""+""×""+"" ""+wa) +print(""TLE""+"" ""+""×""+"" ""+tle) +print(""RE""+"" ""+""×""+"" ""+re) + +" +p03455,s850379458,Wrong Answer,"from random import randint +#整数a,bをそれぞれ定義 +a =randint(0, 10000) +b =randint(0, 10000) +#整数a,bの積を定義 +P = (a * b) +#for文による倍数判定 +if P % 2 == 0: + print(""Even"") +else: print(""Odd"") +" +p03339,s103374634,Wrong Answer,"n = int(input()) +s = list(input()) + +l = [0]*n +l[n-1] = s[:n-1].count('W') +for i in range(n-1): + w_side = s[:i].count('W') + e_side = s[i+1:].count('E') + l[i] = w_side + e_side + +print(l,min(l)) +" +p03592,s423244005,Accepted,"n, m, k = map(int, input().split()) + +for row in range(n+1): + for col in range(m+1): + if row * m + col * n - 2 * (row * col) == k: + print('Yes') + exit() + +print('No') +" +p02918,s603768089,Wrong Answer,"N, K = map(int, input().split()) +S = input() + +happy = 0 +for i in range(N-1): + if S[i] == S[i+1]: + happy += 1 + +m = 0 +for i in range(1, N-1): + if S[i] == 'R' and S[i+1] == 'L': + m += 1 + +if K <= m: + happy += 2*K +else: + happy += 2*m + 1 +print(happy) +" +p02953,s642289346,Wrong Answer,"n = int(input()) +h = list(map(int, input().split())) + +ans = 'Yes' +is_e = False +i = 0 +while i < n-1: + if h[i+1] == h[i]: + is_e = True + elif h[i+1] > h[i]: + is_e = False + elif h[i+1] == h[i]-1 and is_e is False: + is_e = True + else: + ans = 'No' + break + i += 1 +print(ans)" +p02952,s730225576,Accepted,"#wakaran! +n = int(input()) +ans = 0 +for i in range(1, n+1): + ans += int(len(str(i)) % 2 != 0) +print(ans)" +p03210,s553472838,Accepted,"a = input() +a = int(a) + +if a == 7 or a == 5 or a == 3: + print('YES') +else: + print('NO')" +p02935,s679468287,Accepted,"n = int(input()) +v = list(map(int, input().split())) +v_new = sorted(v) +while len(v_new) > 1: + s = [(v_new[0] + v_new[1]) / 2] + v_new = s + v_new[2:] +print(sum(v_new))" +p03281,s878262559,Accepted,"n=int(input()) +nm=[0]*(n+1) + +for i in range(1,n+1): + for j in range(1,n+1): + if i%j==0: + nm[i]+=1 +l=[1 for i in range(1,n+1) if nm[i]==8 and i%2] +print(sum(l)) +" +p02630,s946603927,Accepted,"n=int(input()) +A=list(map(int,input().split())) +q=int(input()) +coun=[0]*10**5 +A_=sum(A) +for i in A: + coun[i-1]+=1 +for _ in range(q): + b,c=map(int,input().split()) + A_+=(c-b)*coun[b-1] + coun[c-1]+=coun[b-1] + coun[b-1]=0 + print(A_) +" +p03673,s590917275,Wrong Answer,"n = int(input()) +a = list(map(int,input().split())) +b = [] +for i in range(n): + b.append(0) +k = 0 +if(n%2==1): + k = (n-1)//2 +else: + k = n//2 +for i in range(n): + if(i%2==0): + b[k+i//2]=a[i] + else: + b[k-(i+1)//2]=a[i] +ans = """" +for i in range(n): + ans += str(b[i])+"" "" +print(ans) + + +" +p02953,s288902769,Accepted,"n = int(input()) +h = list(map(int, input().split())) +ans ='Yes' +mah = 0 +for i in h: + mah = max(i, mah) + if i < mah - 1: + ans = 'No' + break +print(ans)" +p03317,s842170509,Accepted,"#!/usr/bin/env python3 +import math + +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) + +index = a.index(1) + +pre = index +post = n-index-1 + +ans = 10**10 +for i in range(0, k): + ans_tmp = 0 + pre_tmp = max(0, pre-i) + post_tmp = max(0, post-(k-1-i)) + ans_tmp += math.ceil(pre_tmp/(k-1)) + ans_tmp += math.ceil(post_tmp/(k-1)) + ans = min(ans, ans_tmp) + # print(pre_tmp, post_tmp, ans) + +print(ans+1) +" +p02684,s507094397,Accepted,"N,K=map(int,input().split()) +A=[~-int(x) for x in input().split()] + +p,c=[-1]*N,0 +for i in range(N+1): + if p[c]==-1: + p[c]=i + c=A[c] + else: + break + +print(1+p.index(p[c]+(K-p[c])%(i-p[c]) if K>=p[c] else K)) +" +p03745,s001275653,Wrong Answer,"n = int(input()) +l = list(map(int, input().split())) + +res = 0 +for i in range(n-1): + if l[i+1] < l[i]: + res += 1 + +print(res+1) +" +p02792,s930368621,Wrong Answer,"N=int(input()) +c=-1 +for i in range(N): + i=str(i) + for j in range(N): + j=str(j) + if i[0]==j[-1] and i[-1]==j[0]: + c+=1 +print(c)" +p03612,s711310679,Accepted,"n = int(input()) +p_li = list(map(int,input().split())) +dum = 0 +ans = 0 +flag = 0 +count = 0 +for i in range(n): + if i+1 == p_li[i]: + ans += 1 + if flag == 1: + if dum == i-1: + count += 1 + flag = 0 + else: + flag = 1 + dum = i + +#div,mod = divmod(dum,2) +print(ans-count) +" +p02778,s081955660,Accepted,"print(""x"" * len(input()))" +p02687,s052737904,Accepted,"#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys + + +def input(): + return sys.stdin.readline() + + +def resolve(): + s = input().rstrip() + + if s == ""ABC"": + print(""ARC"") + else: + print(""ABC"") + + +if __name__ == ""__main__"": + resolve() + +" +p02793,s883170363,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +from fractions import gcd +from functools import reduce + +N,*A = map(int,read().split()) + +MOD = 10 ** 9 + 7 + +lcm = reduce(lambda x,y: y//gcd(x,y)*x, A) + +answer = sum(lcm//x for x in A) +answer %= MOD +print(answer) +" +p03723,s133325179,Wrong Answer,"a,b,c=map(int,input().split()) +if a==b and a==c: + ans=-1 +for i in range(1,100000): + x=a//2 + y=b//2 + z=c//2 + a=y+z + b=x+z + c=x+y + print(""{}-{}-{}"".format(a,b,c)) + if a%2==1 or b%2==1 or c%2==1: + ans=i + break +print(ans)" +p02631,s012283716,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) + +AA = [0] * (N) +for i in range(N): + AA[i] = list(format(A[i], 'b')) + +ans = [0] * 42 +for i in range(N): + AA[i].reverse() + for j in range(len(AA[i])): + ans[j] += int(AA[i][j]) + +ret = [] +for i in range(N): + temp = 0 + for j in range(len(AA[i])): + if (ans[j] + int(AA[i][j])) & 1 == 1: + temp += 1 << j + + ret.append(temp) + +print(*ret) +" +p02695,s878113089,Accepted,"N, M, Q = map(int, input().split()) + +ABCD = [list(map(int, input().split())) for i in range(Q)] + +import itertools + +max_point = 0 +for i in itertools.combinations_with_replacement(range(1, M+1), N): + # print(i) + point = 0 + for abcd in ABCD: + if i[abcd[1]-1] - i[abcd[0]-1] == abcd[2]: + point += abcd[3] + max_point = max(max_point, point) +print(max_point)" +p02719,s023660764,Accepted,"INF = int(10e20) + + +def main(): + N, K = tuple([int(_x) for _x in input().split()]) + + minval = N + sub = N // K - 5 + if sub > 0: + N = N - K * sub + + for i in range(20): + N = abs(N - K) + minval = min(N, minval) + + print(minval) + + +main() +" +p03427,s357273112,Wrong Answer,"X = list(map(int,input())) +sn = [] +for i in range(len(X)): + sn.append(sum(X[0:i+1])) +ssn = [] +for i in range(len(X)): + ssn.append(sn[i]-1 + 9*(len(X)-1-i)) +print(max(ssn))" +p02695,s531771945,Wrong Answer,"import sys +input = sys.stdin.buffer.readline + +from itertools import product + +n, m, q = map(int, input().split()) + +ABCD = [list(map(int, input().split())) for _ in range(q)] + +kumiawase = list(product(range(1, m + 1), repeat=n)) + +ans = 0 +for kumi in kumiawase: + A = [0] + list(kumi) + temp = 0 + for abcd in ABCD: + a, b, c, d = abcd + if A[b] - A[a] == c: + temp += d + ans = max(ans, temp) + +print(ans) + +" +p02842,s829483081,Accepted," +n = int(input()) +x = int(n / 1.08) + +if int(x * 1.08) == n: + print(x) +elif int((x-1) * 1.08) == n: + print(x-1) +elif int((x+1) * 1.08) == n: + print(x+1) +else: + print("":("") +" +p02897,s946653284,Accepted,"n = int(input()) +if (n%2 == 0): + print(0.5) +else: + print((n//2+1)/n) +" +p02972,s883274228,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +ans = [0] * N +for i in range(N)[:: -1]: + a = A[i] + cnt = 0 + for j in range(i, N, (i + 1)): + cnt += ans[j] + if cnt % 2 != a % 2: + ans[i] = 1 + +M = sum(ans) +print(M) +if M > 0: + print(*[i for i, a in enumerate(ans, start=1) if a > 0]) +" +p03037,s394140633,Accepted,"import numpy as np +def main(): + N, M = map(int, input().split()) + maxl = -float('inf') + minr = float('inf') + for _ in range(M): + l, r = map(int, input().split()) + if l >= maxl: + maxl = l + if r <= minr: + minr = r + val = minr - maxl + 1 + if val >= 0: + print(val) + else: + print(0) +main()" +p03239,s682981266,Wrong Answer,"n, t = map(int, input().split()) +c = 999 +for i in range(n): + tmp = input().split() + if int(tmp[1]) > t: + pass + elif int(tmp[1]) <= t: + if int(tmp[0]) < int(c): + c = tmp[0] + else: + pass +if i == n-1 and c == 999: + print('TLE') + exit() +else: + print(c)" +p03076,s875486504,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + a = [int(input()) for _ in range(5)] + b = [(x + 9) // 10 * 10 for x in a] + + ans = INF + for i in range(5): + ans = min(ans,sum(b) - b[i] + a[i]) + + print(ans) + + +if __name__ == '__main__': + main() +" +p03469,s823323472,Wrong Answer,"s = input() +s_modified = s.replace('7','8') +print(s_modified)" +p03548,s401432463,Accepted,"a,b,c=input().split() +a=int(a) +b=int(b) +c=int(c) +print((a-c)//(b+c))" +p03633,s977083282,Accepted,"import sys + +sys.setrecursionlimit(10 ** 7) +input = sys.stdin.readline +f_inf = float('inf') +mod = 10 ** 9 + 7 + +def gcd(a, b): + while b != 0: + a, b = b, a % b + return a + + +def lcm(a, b): + return a * b // gcd(a, b) + + +def resolve(): + n = int(input()) + T = list(int(input()) for _ in range(n)) + + res = 1 + for i in range(n): + res = lcm(res, T[i]) + + print(res) + + +if __name__ == '__main__': + resolve() +" +p03644,s438424545,Accepted,"def How_many_times_devide(n): + count = 0 + while n %2 == 0: + n/= 2 + count += 1 + + return count + +N = int(input()) +num_max = 1 +count_max = 0 +for i in range(1,N+1): + count = How_many_times_devide(i) + if count_max < count: + count_max = count + num_max = i + +print(num_max)" +p02693,s062539668,Accepted,"k = int(input()) +a, b = map(int, input().split()) + +list_ab = [i for i in range(a,b+1)] +ans = 'NG' + +for j in range(len(list_ab)): + if list_ab[j] % k ==0: + ans = 'OK' + break + +print(ans)" +p02623,s914294866,Accepted,"n,m,k=map(int,input().split()) +a=[int(i) for i in input().split()] +b=[int(i) for i in input().split()] +ca=[0]*(n+1) +ca[1]=a[0] +for i in range(n): + ca[i+1]=ca[i]+a[i] +cb=[0]*(m+1) +cb[1]=b[0] +for i in range(m): + cb[i+1]=cb[i]+b[i] +j=m +ans=0 +for i in range(n+1): + t=ca[i] + while j>=0: + if t+cb[j]>k: + j-=1 + else: + ans=max(ans,i+j) + break +print(ans)" +p02597,s165291651,Wrong Answer,"num = int(input()) +stn = list(input()) +num_W = stn.count('W') +num_R = stn.count('R') +cnt = 0 + +if num_W >= num_R: + for i in range(num_R): + if stn[i] == ""W"": + cnt += 1 + +else: + for i in range(num_W): + if stn[-i] == ""R"": + cnt += 1 + +print(cnt)" +p02811,s912802995,Accepted,"k, x = map(int, input().split()) +print(['No','Yes'][k * 500 >= x])" +p03673,s065173963,Accepted,"from collections import deque +n = int(input()) +a = list(map(int, input().split())) +b = deque() +for i in range(n): + if i % 2 == n % 2: + b.append(a[i]) + else: + b.appendleft(a[i]) + +print(*list(b))" +p03163,s256084549,Accepted,"#!/usr/bin/env python3 +def main(): + import sys + import numpy as np + + read = sys.stdin.read + + N, W = map(int, input().split()) + products = map(int, read().split()) + + dp = np.zeros(W + 1, dtype=np.int64) + for can_w, can_v in zip(products, products): + dp[can_w:] = np.maximum(dp[can_w:], dp[:-can_w] + can_v) + + print(dp[-1]) + + +if __name__ == '__main__': + main() +" +p02548,s138079522,Accepted,"n = int(input()) + +total = 0 + +for i in range(1, 10**6 + 1): + for j in range(1, 10**6 + 1): + m = n - i * j + if m > 0: + total += 1 + else: + break + +print(total)" +p03162,s478818216,Accepted,"N = int(input()) +ABC = [list(map(int, input().split())) for _ in range(N)] +dp = [[0] * 3 for _ in range(N+1)] +for i in range(N): + dp[i+1][0] = max(dp[i][1]+ABC[i][0], dp[i][2]+ABC[i][0]) + dp[i+1][1] = max(dp[i][0]+ABC[i][1], dp[i][2]+ABC[i][1]) + dp[i+1][2] = max(dp[i][0]+ABC[i][2], dp[i][1]+ABC[i][2]) + +print(max(dp[-1])) + +" +p02727,s984545407,Wrong Answer,"x,y,a,b,c = map(int,input().split()) +dx = list(map(int,input().split())) +dy = list(map(int,input().split())) +r = list(map(int,input().split())) +r.sort() +dx.sort() +dy.sort() +dx = dx[-x:] +dy = dy[-y:] +print(sum(dx+dy))" +p02859,s083710505,Accepted,"r = int(input()) +ans = r ** 2 +print(ans)" +p03457,s394108285,Wrong Answer,"n = int(input()) +pos = [list(map(int, input().split())) for _ in range(n)] + +def func(n, pos): + c_t, c_x, c_y = 0, 0, 0 + + for i in pos: + d_t = i[0] - c_t + z = (i[1] - c_x) + (i[2] - c_y) + + if z > d_t or (d_t - z) % 2 != 0: + return ""No"" + else: + c_t, c_x, c_y = i[0], i[1], i[2] + + return ""Yes"" + + +print(func(n, pos)) +" +p03836,s762851552,Accepted,"sx,sy,tx,ty=map(int,input().split()) +tempx=tx-sx +tempy=ty-sy +ans=[""R""]*tempx+[""U""]*tempy+[""L""]*tempx+[""D""]*tempy+[""D""]+[""R""]*(tempx+1)+[""U""]*(tempy+1)+[""L""]+[""U""]+[""L""]*(tempx+1)+[""D""]*(tempy+1)+[""R""] +print("""".join(ans))" +p03012,s376711874,Accepted,"from itertools import accumulate +n=int(input()) +List=list(map(int,input().split())) +List=list(accumulate(List)) +ans=float('inf') +# print(List) +for i in range(n): + ans=min({ans,abs(List[i]-abs(List[n-1]-List[i]))}) +print(int(ans)) +" +p03455,s234163141,Accepted,"a, b = map(int, input().split()) +s = a * b +if s % 2 == 0: + print(""Even"") +else: + print(""Odd"") +" +p03408,s217009189,Wrong Answer,"dic = dict() +for a in range(int(input())): + i = input() + if not i in dic: + dic[i] = 1 + else: + dic[i] = dic[i]+1 +for b in range(int(input())): + i = input() + if not i in dic: + dic[i] = -1 + else: + dic[i] = dic[i]-1 +print(max(max([a for a in dic.values()]), 1))" +p03254,s648524963,Accepted,"N, x = map(int, input().split()) +A = sorted(map(int, input().split())) + +if sum(A) == x: + print(N) + +else: + c = 0 + for ai in A: + x -= ai + if x <= 0: + break + c += 1 + + if c == N: + print(N - 1) + else: + print(c + 1 if x == 0 else c)" +p02923,s064983701,Wrong Answer,"n = int(input()) +h = list(map(int, input().split())) +l = [] +cnt = 0 +ans = 0 +for i in reversed(range(1, n)): + if h[i]<=h[i-1]: + cnt += 1 + else: + l.append(cnt) + cnt = 0 + ans = max(l) +print(ans)" +p02971,s666911752,Accepted,"n = int(input()) +a = [int(input()) for _ in range(n)] +b = sorted(a) +for v in a: + print(b[(v= A and C <= B: + print(""Yes"") +else: + print(""No"")" +p02765,s770101098,Wrong Answer,"n,k=map(int,input().split()) +if n<10: + c=100*(10-n) + print(k-c) +else: + print(k)" +p02918,s761338335,Accepted,"N,K = map(int,input().split()) +S = input() +score = 0 +for i in range(N-1): + if S[i]==S[i+1]: + score+=1 +print(min(score+2*K, N-1))" +p02712,s077332097,Accepted,"N = int(input()) + +ans = 0 +for i in range(1,N+1): + if((i%3 != 0)and(i%5 != 0)): + ans += i +print(ans) + " +p04033,s100468137,Accepted,"a,b = map(int,input().split()) +if a <= 0 <= b: + print(""Zero"") +elif a > 0: + print(""Positive"") +else: + if (b - a) % 2 == 0: + print(""Negative"") + else: + print(""Positive"") +" +p03282,s165810271,Accepted,"#from statistics import median +#import collections +#aa = collections.Counter(a) # list to list +#from itertools import combinations # (string,3) 3回 + +mod = 10**9 + 7 + +def readInts(): + return list(map(int,input().split())) +def main(): + s = input() + k = int(input()) + + ichi = 0 + for i in range(len(s)): + if s[i] == '1': + ichi += 1 + else: + break + if ichi >= k: + print(1) + else: + print(s[ichi]) + + + +if __name__ == '__main__': + main() +" +p02714,s971020469,Accepted,"N = int(input()) +S = input() + +RN = S.count('R') +GN = S.count('G') +BN = S.count('B') + +ans = RN * GN * BN + +for i in range(N): + for d in range(N): + j = i + d + k = i + 2 * d + if k >= N: + break + if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]: + ans -= 1 + +print(ans)" +p02910,s350582986,Accepted,"ss = input() + +even, odd = [], [] + +for i, s in enumerate(ss): + if i%2==1: + even.append(s) + else: + odd.append(s) + +if ('L' in odd) or ('R' in even): + print('No') + +else: + print('Yes') " +p02771,s720901752,Accepted,"a,b,c=map(int,input().split()) + +if (a==b and a!=c) or (a==c and a!=b) or (c==b and a!=c): + print(""Yes"") +else: + print(""No"") +" +p03329,s093167542,Accepted,"INF = 10 ** 20 + +N = int(input()) +coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)] +dp = [INF]*(N+1) +dp[0] = 0 + +for i in range(1,N+1): + for coin in coin_list: + if i-coin >= 0: dp[i] = min(dp[i], dp[i-coin]+1) + +print(dp[N])" +p02682,s539879291,Wrong Answer,"text_list = input().split() +n = 0 +a = int(text_list[0]) +b = a + int(text_list[1]) +c = b + int(text_list[2]) +for i in range(int(text_list[3])): + if i < int(text_list[0]) + int(text_list[1]): + continue + elif i < int(text_list[0]): + n += 1 + elif i < int(text_list[0]) + int(text_list[1]) + int(text_list[2]): + n -= 1 + +print(n)" +p03827,s619680814,Accepted,"N = int(input()) +S = input() +x = 0 +ans = 0 +for s in S: + if s == ""I"": + x += 1 + else: + x -= 1 + if x > ans: + ans = x +print(ans)" +p02556,s584156029,Accepted,"def resolve(): + N = int(input()) + _xmin, _xmax = float(""inf""), -float(""inf"") + _ymin, _ymax = float(""inf""), -float(""inf"") + for i in range(N): + x, y = list(map(int, input().split())) + _x, _y = x - y, x + y + _xmin = min(_x, _xmin) + _xmax = max(_x, _xmax) + _ymin = min(_y, _ymin) + _ymax = max(_y, _ymax) + print(max(_xmax-_xmin, _ymax-_ymin)) + + +if '__main__' == __name__: + resolve()" +p02660,s031287188,Accepted,"N = int(input()) + +p_dic = {} +i=2 +while i ** 2 <= N: + if N % i == 0: + p_dic[i] = 0 + while N % i == 0: + p_dic[i] += 1 + N /= i + i += 1 + +if N > 1: + p_dic[N] = 1 + +def foo(x): + r = 0 + base = 1 + while x >= base: + x -= base + r+=1 + base += 1 + return r + +ans = 0 +for v in p_dic.values(): +# print(v, foo(v)) + ans += foo(v) + +print(ans)" +p03254,s787056567,Wrong Answer,"N,x = map(int, input().split()) +A = list(map(int, input().split())) + +A.sort() + +ans = 0 +for i in range(N): + if x > A[i]: + ans += 1 + x -= A[i] + elif x == A[i]: + print(ans+1) + break + elif i+1 == N: + print(ans -1) + break + else: + print(ans) + break +" +p03437,s976386828,Accepted,"from math import gcd +X, Y = [int(i) for i in input().split()] +lcm = X * Y // gcd(X, Y) +if lcm == X: + print(-1) +else: + print(X) +" +p02768,s686491565,Accepted,"n,a,b = map(int, input().split()) + +ans = pow(2,n,10**9+7) + +nm= 1 +dn = 1 + +for i in range(a): + nm = (nm * (n-i)) % (10**9+7) + dn = (dn * (i+1)) % (10**9+7) + +ans = (ans - nm*pow(dn,-1,10**9+7) - 1) % (10**9+7) + +for i in range(a,b): + nm = (nm * (n-i)) % (10**9+7) + dn = (dn * (i+1)) % (10**9+7) + +ans = (ans - nm*pow(dn,-1,10**9+7)) % (10**9+7) + +print(ans)" +p04030,s638989354,Wrong Answer,"from collections import deque +que = deque() +s = input() +n = len(s) +for i in range(n): + if s[i] == '0': + que.appendleft('0') + if s[i] == '1': + que.append('1') + if s[i] == 'B': + if len(que)==0: + continue + k = que.pop() +li = list(que) +print(''.join(li))" +p03719,s003217571,Accepted,"a, b, c = map(int, input().split()) +if a <= c <= b: + print(""Yes"") + raise SystemExit(0) +print(""No"") +" +p02687,s376305866,Accepted,"S = input() +if S == 'ABC': + print('ARC') +else: + print('ABC') " +p02725,s171004698,Wrong Answer,"import math +import sys +import collections +import bisect +readline = sys.stdin.readline + + +def main(): + k, n = map(int, readline().rstrip().split()) + A = sorted(list(map(int, readline().rstrip().split()))) + maxA = k + A[0] - A[n-1] + for i in range(n-1): + a = abs(A[i+1] - A[i]) + maxA = max(maxA,a) + print(maxA) + + + +if __name__ == '__main__': + main() +" +p03835,s226044130,Accepted,"import sys + +input = sys.stdin.readline + + +def main(): + K, S = map(int, input().split()) + + ans = 0 + X_max = min(S, K) + for X in range(X_max + 1): + Y_max = min(S - X, K) + for Y in range(Y_max + 1): + Z = S - (X + Y) + if 0 <= Z <= K: + ans += 1 + else: + continue + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03637,s546141235,Wrong Answer,"import math + +N = int(input()) +a = list(map(int, input().split())) + +N2 = 0 +N4 = 0 + +for i in a: + if i % 4 == 0: + N4 += 1 + if i % 2 == 0: + N2 += 1 + +if N4 >= math.ceil(N / 3) or N2 >= math.ceil(N*2/3): + print(""Yes"") +else: + print(""No"") +" +p02640,s422648471,Wrong Answer,"x, y = map(int, input().split()) +judge='No' +if(y%2==1): + judge='No' + +for i in range(x): + if(x==1 and (y==4 or y==2)): + judge='Yes' + if(y%4==0): + judge='Yes' + for j in range(x): + if((i*2+j*4)==y): + judge='Yes' + if((i*4+j*2)==y): + judge='Yes' + + + +print(judge) + " +p03327,s131683367,Wrong Answer,"N = int(input()) +if N < 999: + print(""ABD"") +else: + print(""ABC"")" +p02660,s711831626,Wrong Answer,"n=int(input()) +l=list() +if n==1: + print(0) +else: + if n%2==0: + l.append(2) + if n%3==0: + l.append(3) + i=5 + while(i*i<=n): + if n%i==0: + l.append(i) + elif n%(i+2)==0: + l.append(i+2) + i+=6 + l.append(n) + k=0 + for i in l: + z=i + while(n%i==0 and n>0): + n=n//i + i=i*z + k+=1 + print(k) + + + " +p02911,s472626231,Wrong Answer,"import sys +import numpy as np + +I = np.array([int(_) for _ in open(0).read().split()]) +N, K, Q = I[:3] +ans = I[3:] + K - Q +print(*np.where(ans > 0, 'Yes', 'No')[1:], sep='\n') +" +p02689,s986901346,Accepted,"import math , sys + +N , M = list(map(int, input().split())) +H = list(map(int, input().split())) +Es = [[] for _ in range(N)] +for i in range(M): + A , B = list(map(int, input().split())) + A -=1 ; B-=1 + Es[A].append(B) + Es[B].append(A) +ans = 0 +for i in range(N): + Es[i] = list(set(Es[i])) +for i in range(N): + if len(Es[i]) == 0: + ans+=1 + else: + Max = max( [ H[Es[i][j]] for j in range( len(Es[i]) ) ] ) + if H[i] > Max: + ans+=1 +print(ans)" +p04043,s020747640,Wrong Answer,"abc = list(map(int, input().split())) +if abc.count(5) == 2 and abc.count(7) == 1: print(""YES"") +else: print(""N0"")" +p02695,s005289983,Wrong Answer,"n,m,q = list(map(int,input().split())) +a = [[]]*q +for i in range(q): + a[i] = list(map(int,input().split())) +ans = 0 +def calc(x): + cnt = 0 + for j in range(q): + if x[a[j][1]-1] - x[a[j][0]-1] == a[j][2]: + cnt += a[j][3] + return cnt +l = [0]*n +for k in range(10*n): + b = str(k).zfill(n) + for o in range(n): + l[o] = int(b[o]) + if ans < calc(l): + ans = calc(l) +print(ans)" +p03493,s211697879,Accepted,print(input().count('1')) +p02982,s958990377,Wrong Answer,"n,d=map(int,input().split()) +x= [list(map(int, input().split())) for i in range(n)] +lis=list(i**2 for i in range(0,22)) +ans=0 +for i in range(n): + for k in range(i+1,n): + check=0 + for j in range(d): + check+=(x[i][j]-x[k][j])**2 + if check in lis: + ans+=1 +print(ans)" +p02570,s780616339,Accepted,"D, T, S = map(int,input().split()) + +t = D / S + +if t > T: + print('No') +else: + print('Yes') + + " +p03852,s013650833,Accepted,"# A - 居合を終え、青い絵を覆う + +boin = ('a', 'e', 'i', 'o', 'u') + +c = input() + +if c in boin: + print('vowel') +else: + print('consonant') +" +p03605,s689085092,Wrong Answer,"n = input() +if n in '9': + print('Yes') +else: + print('No')" +p03416,s279169786,Accepted,"A,B=map(int,input().split()) +count=0 +for i in range(A,B+1) : + if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3] : + count+=1 +print(count)" +p02780,s902737385,Accepted,"N, K = map(int, input().split()) +p = list(map(int, input().split())) + +p.insert(0, 0) +for i in range(1, N+1): + p[i] = (p[i] + 1) / 2 + p[i-1] + +s = [0] * (N+1) +for i in range(N-K+1): + s[i] = p[i+K] - p[i] + +print(max(s))" +p02688,s791011660,Accepted,"# ABC166 +# B Trick or Treat +N, K = map(int, input().split()) +A = [list(map(int, input().split())) for i in range(K*2)] +D = list(A[::2]) +del A[::2] +A = sum(A, []) +a = set(A) +OP = [n +1 for n in range(N)] +op = set(OP) +an = op - a +print(len(list(an))) +" +p03077,s588288761,Wrong Answer,"#C +import math +n = int(input()) +a=[0]*5 +for i in range(5): + a[i] = int(input()) +time = math.ceil(n / a[0]) +for i in range(4): + if a[i] < a[i + 1]: + a[i + 1] = a[i] + time += math.ceil(a[i] / a[i + 1]) + print(time) +print(a,time)" +p02813,s500549939,Wrong Answer,"import itertools +import math +N = int(input()) +P = tuple([int(i) for i in input().split()][0:N]) +Q = tuple([int(i) for i in input().split()][0:N]) +l = list(itertools.permutations(range(1,N+1))) +print(l.index(Q) - l.index(P)) +" +p02682,s398399469,Accepted,"A,B,C,K=map(int,input().split()) +if A>=K: + print(K) +elif A+B>=K: + print(A) +else: + print(A-(K-A-B)) +" +p02677,s839567911,Wrong Answer,"import math + +A,B,H,M = map(int,input().split()) + +kakudo = abs((H*30+0.5*M-M*6)%180) + +if kakudo == 0: + print(0) +else: + a = (A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))) + print(math.sqrt(a))" +p03485,s847474373,Accepted,"import math +a, b = map(int, input().split()) + +ans = math.ceil((a + b) / 2) + +print(ans)" +p02994,s055896502,Accepted,"n, l = map(int, input().split()) + + +a = [] +res = 300 +for i in range(n): + a.append(l+i) + res = min(res, abs(l+i)) +s = sum(a) +if res in a: + print(s-res) +else: + print(s+res)" +p03838,s751440828,Accepted,"import sys +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10 ** 8) +INF = float('inf') +MOD = 10 ** 9 + 7 + +def main(): + x, y = map(int, readline().split()) + if x * y >= 0: + if x < y: + print(y - x) + else: + print(x - y + 2 if x * y > 0 else x - y + 1) + else: + print(abs(abs(x) - abs(y)) + 1) + + +if __name__ == '__main__': + main()" +p02996,s640185731,Accepted,"N = int(input()) +AB = [list(map(int, input().split())) for _ in range(N)] + +AB.sort(key = lambda x: x[1]) + +sum_a = 0 +for a, b in AB: + sum_a += a + if sum_a > b: + print(""No"") + exit() +print(""Yes"") +" +p02811,s979068191,Wrong Answer,"k, x = list(map(int, input().split())) + +if 500*k >= x: + print('yes') +else: + print('no')" +p02556,s779060113,Accepted,"n=int(input()) +a=[] +j=k=0 +def s(a): + return a[0]+a[1] +def ss(a): + return a[0]-a[1] +for i in range(n): + f=list(map(int,input().split())) + a.append(f) +aa=min(map(s,a)) +b=max(map(s,a)) +c=min(map(ss,a)) +d=max(map(ss,a)) +print(max(abs(d-c),abs(b-aa)))" +p03380,s144623198,Accepted,"n = int(input()) +a = list(map(int,input().split())) +ai = max(a) +a.remove(ai) +aj = a[0] +for i in a: + if abs(ai/2-i) < abs(ai/2-aj): + aj = i +print(ai,aj)" +p03544,s950283790,Accepted,"from functools import lru_cache + +@lru_cache(maxsize=None) + +def ryuka(n): + if n==0: + return 2 + elif n==1: + return 1 + else: + return ryuka(n-1)+ryuka(n-2) + +N=int(input()) + +print(ryuka(N)) + +" +p03438,s458076346,Accepted,"import sys +readline = sys.stdin.readline +sys.setrecursionlimit(10**8) +mod = 10**9+7 +#mod = 998244353 +INF = 10**18 +eps = 10**-7 + + +N = int(readline()) +A = list(map(int,readline().split())) +B = list(map(int,readline().split())) +Ka = sum(B)-sum(A) +Kb = Ka +for a,b in zip(A,B): + if a < b: + Ka -= (b-a+1)//2 +print('Yes' if Ka >= 0 and Kb >= 0 else 'No') + + +" +p03017,s105295167,Accepted,"import re +N,A,B,C,D = (int(x) for x in input().split()) +S = input() +if re.search(r'##',S[A-1:max(C,D)]): + print('No') +else: + if D < C: + if re.search(r'\.\.\.',S[B-2:D+1]): + print('Yes') + else: + print('No') + else: + print('Yes')" +p03860,s507930548,Accepted,"name=list(input().split()) + +s=name[1][:1] + +print('A'+s+'C')" +p03695,s308885641,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +r=[0]*9 +for a in A: + for i in range(8,-1,-1): + if a >= 400*i: + r[i]+=1 + break +ans=0 +for i in range(8): + if r[i]>0: ans+=1 +print(ans, ans+r[8])" +p02608,s499397071,Accepted,"n = int(input()) +ans=[0]*(n+1) +for x in range(1, 101): + for y in range(1, 101): + for z in range(1, 101): + a = x * x + y * y + z * z + x * y + y * z + z * x + if n >= a >= 1: + ans[a] += 1 +print(*ans[1:],sep=""\n"")" +p02814,s088501839,Wrong Answer,"n,m=map(int,input().split()) +a=list(map(int,input().split())) + +hana=[] + +for i in a: + hana.append(i//2) + +from fractions import gcd +from functools import reduce +def lcm_base(x, y): + return (x * y) // gcd(x, y) +def lcm(*numbers): + return reduce(lcm_base, numbers, 1) +def lcm_list(numbers): + return reduce(lcm_base, numbers, 1) + +mini=lcm_list(hana) + +ans=1+((m-mini)//(2*mini)) + +print(ans)" +p02935,s740792176,Accepted,"N = int(input()) +V = sorted(list(map(int,input().split()))) + + + +for i in range(N-1): + V[0] = (V[0] + V.pop(1))/2 + V = sorted(V) + +print(V[0])" +p02712,s783908458,Wrong Answer,"N = int(input()) + +print(sum(filter(lambda x : (x%3 != 0) and (x%5 !=0), range(N)))) + +" +p03711,s497708781,Accepted,"a,b = map(int, input().split()) +g_1 =[1,3,5,7,8,10,12] +g_2 = [4,6,9,11] +if (a in g_1 and b in g_1) or (a in g_2 and b in g_2) or (a == 2 and b == 2): + print('Yes') +else: + print('No')" +p02552,s833385185,Accepted,print(1-int(input())) +p03371,s686316071,Accepted,"a, b, c, x, y = map(int, input().split()) +k = min(x, y) +ans = 0 +if a + b >= 2 * c: + ans += 2 * k * c + if x >= y: + ans += min((x - k) * a, 2 * c * (x - k)) + elif x < y: + ans += min((y - k) * b, 2 * c * (y - k)) +else: + ans += x * a + y * b +print(ans)" +p02971,s300204721,Wrong Answer,"import copy + +n = int(input()) +a = [int(input()) for _ in range(n)] +a_down = sorted(a, reverse=True) +for i in range(n): + a_down_copy = copy.deepcopy(a_down) + while a[i] == max(a_down_copy): + if max(a_down_copy) == min(a_down_copy): + break + a_down_copy.pop(0) + print(max(a_down_copy)) +" +p03284,s680165409,Accepted,"N,K=map(int,input().split()) +if N%K==0: + print(0) +else: + print(N//K+1-N//K)" +p03339,s919164679,Accepted,"N = int(input()) +S = input() + +A = [0]*N +B = [0]*N + +for i in range(1, N): + A[i] = A[i-1] + (1 if S[i-1]=='W' else 0) + B[N-i-1] = B[N-i] + (1 if S[N-i]=='E' else 0) + +print(min(map(lambda x: x[0]+x[1], zip(A, B))))" +p03160,s025715490,Accepted,"n = int(input()) +h = list(map(int,input().split())) +dp = [10**7]*n +dp[0] = 0 +for i in range(1,n): + dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(3,i+1))]) +print(dp[n-1]) + " +p02546,s845106242,Accepted,"s = input() +l = len(s) +x = s[l-1] +if x == ""s"": + print(s + ""es"") +else: + print(s + ""s"")" +p02916,s790865757,Accepted,"n = int(input()) +a = list(map(int,input().split())) +b = list(map(int,input().split())) +c = list(map(int,input().split())) + +ans = 0 +ans += b[a[0]-1] +for i in range(1,n): + ans += b[a[i]-1] + if a[i-1]+1 == a[i]: + ans += c[a[i]-2] + +print(ans)" +p03416,s764762209,Accepted,"a, b = map(int, input().split()) + +cnt = 0 +for i in range(a, b+1): + r = ''.join(list(reversed(str(i)))) + if i == int(r): + cnt += 1 + +print(cnt)" +p03672,s381891333,Accepted,"import sys + + +def main(): + S = sys.stdin.readline().rstrip() + + if len(S) % 2 == 0: + S = S[:-2] + else: + S = S[:-1] + + while S: + if S[: len(S) // 2] == S[len(S) // 2 :]: + break + else: + S = S[:-2] + + print(len(S)) + + +if __name__ == ""__main__"": + main()" +p02818,s034603866,Wrong Answer,"c=list(map(int, input().split())) + +if c[0]>=c[2]: + c[0]-=c[2] +else : + c[2]-=c[0] + c[1]-=c[2] + c[0]=0 +print(c[0] , c[1])" +p02623,s734233995,Accepted,"N,M,K=map(int,input().split()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) + +a,b=[0],[0] +for i in range(N): + a.append(a[i]+A[i]) +for i in range(M): + b.append(b[i]+B[i]) + + +ans,j=0,M +for i in range(N+1): + if a[i]>K: + break + while b[j]>K-a[i]: + j-=1 + ans =max(ans,i+j) + +print(ans)" +p02713,s688417149,Accepted,"from math import gcd +k=0 +n=int(input()) +for a in range(1,n+1): + for b in range(a,n+1): + for c in range(b,n+1): + l=list(set([a,b,c])) + p=1 + for i in range(len(l)-1): + p*=3-i + k+=gcd(gcd(a,b),c)*p +print(k)" +p03323,s865711450,Wrong Answer,"A,B=map(int,input().split()) +if max([A,B])>8: + print("":("") +else: + print(""Yay"")" +p03438,s371752097,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +a_small = 0 +b_small = 0 +for a, b in zip(A,B): + if a < b: + a_small += b - a + else: + b_small += a - b +if a_small < b_small * 2: + print('No') +else: + print('Yes')" +p03699,s722623777,Wrong Answer,"n = int(input()) +s = [] +for _ in range(n): + s.append(int(input())) + +ans = sum(s) + +s.sort() + +for x in s: + if ans % 10 != 0: + break + else: + ans -= x + +print(ans)" +p02780,s474617953,Accepted,"N, K = map(int, input().split()) +P = list(map(int, input().split())) + +#期待値L +L = [0 for _ in range(N)] +for i in range(N): + L[i] = (1+P[i])/2 + +#累積和S +S = [0 for i in range(N)] +S[0] = L[0] +for i in range(1, N): + S[i] = S[i-1] + L[i] + +total = S[K-1] +for i in range(N-K): + tmp = S[i+K]-S[i] + if total < tmp: + total = tmp + +print(total)" +p03637,s121815861,Wrong Answer,"N=int(input()) +a=list(map(int,input().split())) +l=[0]*N +for i in range(N): + if a[i]%4: + if a[i]%2:l[i]=1 + else:l[i]=2 + else:l[i]=4 +if l.count(2): + if (l.count(2)+l.count(1)+1)//2<=l.count(4): + print('Yes') + else: + print('No') +else: + if l.count(1)+1//2<=l.count(4): + print('Yes') + else: + print('No')" +p02771,s757508418,Wrong Answer,"ans = list(int(i) for i in input().split()) +ans.sort() + +if ans[0]==ans[1] or ans[1] == ans[2]: + print(""Yes"") +else: + print(""No"")" +p03077,s135701594,Wrong Answer,"n=int(input()) +a=[int(input()) for i in range(5)] +amin=min(a) +a1=int(n/amin+1)+4 +print(a1)" +p03796,s769378777,Accepted,"def main(): + N = int(input()) + sum=1 + for i in range(1,N+1): + sum*=i + sum=sum%1000000007 + print(sum) + + + +if __name__ == '__main__': + main() +" +p03665,s538281128,Accepted,"N,P=map(int,input().split()) +A=list(map(int,input().split())) +for i in range(N): + A[i]%=2 + +odds=sum(A) +evens=N-odds +if odds>0: + ans=2**evens + ans*=2**(odds-1) + print(ans) +else: + if P==0: + print(2**evens) + else: + print(0)" +p03062,s491843966,Accepted,"import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10 ** 9) +INF = 1 << 60 +MOD = 1000000007 + + +def main(): + N, *A = map(int, read().split()) + + neg = total = 0 + min_abs = INF + for a in A: + if a < 0: + neg += 1 + total += abs(a) + if min_abs > abs(a): + min_abs = abs(a) + + if neg % 2 == 1: + total -= 2 * min_abs + + print(total) + return + + +if __name__ == '__main__': + main() +" +p02946,s526904110,Accepted,"K, X = map(int, input().split()) +for i in range(X-K+1, X+K): + if i < X+K-1: + print (i, end="" "") + else: + print (i)" +p02660,s121525792,Accepted,"n=int(input()) +def prime_factor(n): + ass=[] + for i in range(2,int(n**0.5)+1): + while n%i==0:ass.append(i);n//=i + if n!=1:ass.append(n) + return ass +p=prime_factor(n) +from collections import Counter +c=Counter(p) +ans=0 +for i in c: + m=c[i] + for j in range(1,10**20): + if j>m:break + ans+=1 + m-=j +print(ans)" +p02665,s703463656,Accepted,"from itertools import accumulate +n = int(input()) +A = list(map(int, input().split())) +Acum = list(accumulate(reversed(A))) +Acum.reverse() + +flexibility = 1 +ans = 0 +for i, a in enumerate(A): + if flexibility < a: + print(-1) + exit() + ans += min(flexibility, Acum[i]) + flexibility = 2*(flexibility-a) + +print(ans) +" +p03632,s747021948,Accepted,"a, b, c, d = map(int, input().split()) +ans = 0 +# 求める秒数は(二つのスイッチのうち先に離された方の時刻) - (二つのスイッチのうち後に押された時刻)となる. +_min = min(b, d) +_max = max(a, c) +ans = _min - _max +if ans < 0: + print(0) +else: + print(ans)" +p03681,s472355790,Accepted,"import math +a,b=map(int, input().split()) + +if abs(a-b) == 1: + c = math.factorial(a)%(10**9+7) + d = math.factorial(b)%(10**9+7) + print(c*d%(10**9+7)) +if abs(a-b) == 0: + c = math.factorial(a)%(10**9+7) + d = math.factorial(b)%(10**9+7) + print(c*d*2%(10**9+7)) +if abs(a-b) >= 2: + print(0)" +p03838,s307073876,Accepted,"x, y = map(int, input().split()) +if y == 0: + if x <= 0: + print(abs(x)) + else: + print(abs(x)+1) +elif x==0: + if y < 0: + print(-y+1) + else: + print(y) +elif x*y < 0: + r = [] + x, y = sorted([x, y]) + r.append(abs(y-x)) + r.append(abs(y+x)+1) + print(min(r)) +elif x > y: + print(abs(y-x)+2) +else: + print(abs(y-x))" +p03457,s044939009,Accepted,"N = int(input()) +dt, dx, dy = 0, 0, 0 +avilable = True +for i in range(N): + t, x, y = map(int, input().split()) + if abs(x-dx)+abs(y-dy) > t-dt or (abs(x-dx)+abs(y-dy)) % 2 != (t-dt) % 2: + avilable = False + dt = t + dx = x + dy = y +if avilable: + print('Yes') +else: + print('No') +" +p03797,s005426274,Wrong Answer,"n,m = map(int,input().split()) +m = m//2 +print((n+m)//2)" +p02785,s393592788,Accepted,"N, K = map(int, input().split()) +H = [h for h in map(int, input().split())] +H.sort() +if N-K <= 0: + print(0) +else: + print(sum(H[:N-K]))" +p03994,s327200315,Accepted,"s = list(input()) +k = int(input()) +t = list(map(lambda x:ord(x)-ord(""a""),s)) #a-zを0-25に正規化 + +for i in range(len(t)): + diff = 26-t[i] #aになるまでの差 + if diff != 26 and diff <= k: + t[i]+=diff + k-=diff + else: + continue + +t[-1]+=k #k余りを一番最後に足す + +u = """".join(list(map(lambda x:chr((x%26+ord(""a""))),t))) +print(u)" +p03633,s253707180,Accepted,"N = int(input()) +import math +ans = int(input()) +for i in range(N - 1): + a = int(input()) + ans = a * ans // math.gcd(a, ans) +print(ans)" +p03557,s338611753,Accepted,"def abc077c_snuke_festival(): + import bisect + n = int(input()) + a = sorted(list(map(int, input().split()))) + b = sorted(list(map(int, input().split()))) + c = sorted(list(map(int, input().split()))) + total = 0 + for i in range(n): + b_size = b[i] + j = bisect.bisect_left(a, b_size) + j = n - j + k = bisect.bisect_right(c, b_size) + + total += (n - j) * (n - k) + print(total) + + +abc077c_snuke_festival()" +p03803,s802333549,Accepted,"a,b=map(int,input().split()) +print('Draw' if a==b else 'Alice' if (a+13)%15>(b+13)%15 else 'Bob') +" +p02675,s089643440,Accepted,"n = str(input()) +num = int(n[-1]) + +if num in [2, 4, 5, 7, 9]: + print(""hon"") +elif num in [0, 1, 6, 8]: + print(""pon"") +else: + print(""bon"")" +p02918,s258920034,Wrong Answer,"N,K = list(map(int,input().split())) +S = input() +lc = S.count('L') +rc = N-lc +maxc = lc+rc-2 +nowc = 0 +now = S[0] +for i in range(1,N): + if S[i] == now: + nowc += 1 + else: + now = S[i] +print(min(nowc+2*K,maxc))" +p02720,s984060382,Accepted,"import sys +from collections import deque + +K = int(sys.stdin.readline()) + +q = deque() +for i in range(1, 10): + q.append(i) + +#count = 0 +#while count <= K: +for _ in range(K): + n = q.popleft() + #count += 1 + if n % 10 != 0: + q.append(n*10 + n % 10 - 1) + q.append(n*10 + n % 10) + if n % 10 != 9: + q.append(n*10 + n % 10 + 1) +print(n)" +p03994,s776096028,Accepted,"#!/usr/bin/env python3 +s = input() +k = int(input()) +ans = """" +n = len(s) +for p, i in enumerate(s): + if p == n - 1: + ans += chr((ord(i) - 97 + k) % 26 + 97) + break + if (cost := (123 - ord(i)) % 26) <= k: + ans += ""a"" + k -= cost + else: + ans += i +print(ans) +" +p02707,s703384939,Accepted,"n = int(input()) +ll = [0]*(n+1) +l = list(map(int,input().split())) +for i in l: + ll[i]+=1 +for i in range(n): + print(ll[i+1])" +p03061,s082850226,Wrong Answer,"from fractions import gcd + +N = int(input()) +A = tuple(map(int, input().split())) + +gcd_left, gcd_right = [0] * N, [0] * N +gcd_left[0] = A[0] +gcd_right[-1] = A[-1] +for i in range(1, N): + gcd_left[i] = gcd(gcd_left[i - 1], A[i]) +for i in range(N - 2, -1, -1): + gcd_right[i] = gcd(gcd_right[i + 1], A[i]) + +gcd_left = [gcd_right[-1]] + gcd_left +gcd_right = gcd_right + [gcd_left[0]] +ans = 1 +for i in range(N): + ans = max(ans, gcd(gcd_left[i], gcd_right[i + 1])) +print(ans)" +p03073,s092217529,Accepted,"S=input() +ans0=0 +ans1=0 +for i in range(len(S)): + s=int(S[i]) + if i%2==0: + if s==1: + ans0+=1 + else: + ans1+=1 + else: + if s==0: + ans0+=1 + else: + ans1+=1 +print(min(ans0,ans1))" +p03251,s022941681,Accepted,"import sys + +N,M,X,Y = map(int,input().split()) +x = list(map(int,input().split())) +y = list(map(int,input().split())) + +if X <= Y: + Z = list(range(X+1,Y+1)) +else: + print('War') + sys.exit() + +Z_x = max(x)+1 +Z_y = min(y) +if Z_x <= Z_y: + Z_xy = list(range(Z_x,Z_y+1)) +else: + print('War') + sys.exit() + +for i in Z_xy: + if i in Z: + print('No War') + sys.exit() +print('War') +" +p03478,s580214194,Accepted,"N, A, B = map(int,input().split()) +count = 0 +for i in range(N): + s = str(i+1) + array = list(map(int,s)) + kei = sum(array) + if A <= kei <= B: + count += i+1 +print(count)" +p02811,s774400598,Accepted,"k,x = map(int,input().split()) +a = 500*k +if a >= x: + print('Yes') +else: + print('No') +" +p03011,s613960282,Accepted,"L = list(map(int, input().split())) +L.sort() +print(L[0] + L[1]) +" +p03617,s502404150,Wrong Answer,"a,b,c,d=map(int,input().split()) +n=int(input()) +l=[a*4,b*2,c,d/2] +p=min(l) +q=min(l[:3]) +print(int(n*min(l)) if n%2==0 or p==q else int((n-1)*(d/2)+q))" +p03448,s256171279,Wrong Answer,"a = int(input()) +b = int(input()) +c = int(input()) +x = int(input()) +d = 0 +for i in range(a): + for j in range(b): + for k in range(c): + if i*500+j*100+k*50==x: + d +=1 +print(d)" +p03612,s778435759,Wrong Answer,"n = int(input()) +P = list(map(int, input().split())) + +ans = 0 +for i in range(n-1): + if i+1 == P[i]: + P[i], P[i+1] = P[i+1], P[i] + ans+=1 +print(ans) +" +p02556,s267458969,Wrong Answer,"n = int(input()) +x, y, xy = [], [], [] +for i in range(n): + temp_x, temp_y = map(int, input().split()) + x.append(temp_x) + y.append(temp_y) + xy.append(temp_x * temp_y) +max_index, min_index = xy.index(max(xy)), xy.index(min(xy)) +print(abs(x[max_index] - x[min_index]) + abs(y[max_index] - y[min_index])) +" +p03286,s829711099,Wrong Answer,"S=str(bin(int(input()))) +if S[0]==""-"": + print(S[3:]) +else: + print(S[2:])" +p03163,s235970083,Wrong Answer,"x, y = map(int, input().split()) +dp = [[0]*(y+1) for _ in range(x+1)] + +for i in range(1, x+1): + w, v = map(int, input().split()) + for j in range(w, y+1): + num0 = dp[i-1][j] + num1 = dp[i-1][j-w]+v + if num1 > num0: + dp[i][j] = num1 + else: + dp[i][j] = num0 +print(max(dp[-1])) +" +p03486,s522832108,Accepted,"s = sorted(input()) +t = sorted(input(), reverse=True) + +for item in zip(s,t): + if ord(item[0]) < ord(item[1]): + print('Yes') + exit() + elif ord(item[0]) > ord(item[1]): + print('No') + exit() +if len(s) < len(t): + print('Yes') +else: + print('No')" +p02989,s078979038,Wrong Answer,"n = int(input()) +d = list(map(int, input().split())) +d = sorted(d) +tar = int(n/2) - 1 + + +left = d[tar] +right = d[tar + 1] +print(left, right) +diff = right - left +if (diff == 0): + ans = 0 +else: + ans = diff + +print(ans)" +p03774,s562961184,Accepted,"n,m = map(int,input().split()) +a = [list(map(int,input().split())) for _ in range(n)] +c = [list(map(int,input().split())) for _ in range(m)] + + +ans = [0] * n +for i in range(n): + tmp = [0, 10 ** 18] + for j in range(m): + if abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]) < tmp[1]: + tmp = [j,abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])] + ans[i] = tmp[0]+1 + +for i in ans: + print(i)" +p02773,s096892736,Wrong Answer,"n=int(input()) +s=sorted([input() for k in range(n)]) +s3 = sorted(list(set(s))) +if(len(set(s))==len(s)): + for u in range(len(s)): + print(s[u]) + exit() +else: + s1=s2 = [m for m in s3 if s.count(m)>1] + i = (len(s)-len(s1))//2 + while(len(s2)!=0): + s2 = [m for m in s3 if s.count(m)>i] + if(len(s2)==0): + break + s1 = s2 + i+=1 +for j in s1: + print(j)" +p02996,s477582691,Wrong Answer,"n = int(input()) +a = [0] * n +b = [0] * n +sa = [0] * n +for i in range(n): + a[i], b[i] = map(int, input().split()) + sa[i] = b[i] - a[i] +so = sa +sa.sort() +wa = 0 +for i in sa: + wa += a[so.index(i)] + if wa > b[so.index(i)]: + print(""No"") + exit() +print(""Yes"")" +p02838,s751591080,Accepted,"N = int(input()) +As = list(map(int, input().split())) +P = 10**9 + 7 + +rlt = 0 +pw = 1 +for i in range(61): + c0 = 0 + c1 = 0 + for j in range(N): + a = As[j] + if a % 2 == 0: + c0 += 1 + else: + c1 += 1 + As[j] = a//2 + rlt += c0*c1*pw % P + rlt %= P + pw *= 2 + +print(rlt)" +p02553,s860627071,Accepted,"a,b,c,d=map(int,input().split()) +print(max(a*c,a*d,b*c,b*d))" +p03208,s725224552,Accepted,"def solve(): + N, K = map(int, input().split()) + H = [int(input()) for _ in range(N)] + H.sort() + ans = float('inf') + for i in range(N): + if i+K>N: + break + ans = min(H[i+K-1]-H[i],ans) + return ans +print(solve())" +p02994,s141667606,Accepted,"import statistics +import math +n,l = map(int,input().split()) +t = [] +for i in range(l,n+l): + t.append(i) + +if 0 in t: + print(sum(t)) +else: + if t[0] <0: + t.pop() + print(sum(t)) + + else: + t.pop(0) + #print(t) + print(sum(t))" +p02639,s931258348,Accepted,"from sys import stdin, stdout + +int_in = lambda: int(stdin.readline()) +arr_in = lambda: [int(x) for x in stdin.readline().split()] +mat_in = lambda rows: [arr_in() for y in range(rows)] +str_in = lambda: stdin.readline().strip() +out = lambda o: stdout.write(""{}\n"".format(o)) +arr_out = lambda o: out("" "".join(map(str, o))) +bool_out = lambda o: out(""YES"" if o else ""NO"") +tests = lambda: range(1, int_in() + 1) +case_out = lambda i, o: out(""Case #{}: {}"".format(i, o)) + + +def solve(x): + return x.index(0) + 1 + + +if __name__ == ""__main__"": + x = arr_in() + out(solve(x))" +p02684,s027502988,Wrong Answer,"from collections import OrderedDict + +n, k = map(int, input().split()) +a = tuple(map(int, input().split())) + +returned = None +i = 0 +aa = 0 +visited = OrderedDict([(0, 0)]) +while i < n: + aa = a[aa] - 1 + i = i + 1 + if aa in visited: + returned = (visited[aa], i) + break + visited[aa] = i + +loop = returned[1] - returned[0] + +if k >= len(visited): + k = k % (returned[1] - returned[0]) + if k < returned[0]: + k = k + returned[0] + +print(list(visited.keys())[k] + 1) +" +p03910,s886866994,Wrong Answer,"n = int(input()) +def main(n): + if n == 1: + return 1,0 + + if n == 3: + return 2,0 + m = n //2 + for i in range(1,m+1): + if i * (i + 1) <= 2*n < (i+1)*(i+2): + right = i + 1 + break + + diff = right * (right+1) //2 - n + + return right+1,diff + + +right,diff = main(n) + +for i in range(1,right): + if i != diff: + print(i) + +" +p03861,s969233589,Accepted,"a, b, x = map(int, input().split()) + +if a % x != 0 : + aa = a//x+1 +else : + aa = a//x + + +bb = b //x + +print(bb - aa + 1 ) +" +p03607,s967700898,Wrong Answer,"N=int(input()) +A=[int(input()) for _ in range(N)] +A.sort() +ans=0 +b=0 +c=0 +for i in range(N): + if b!=A[i]: + if c%2!=0: + ans+=1 + b=A[i] + c=1 + else: + c+=1 +print(ans)" +p02952,s292258200,Accepted,"n=int(input()) + +def ketacul(x): + keta=1 + while(x/10>=1): + x=x/10 + keta+=1 + return keta +count=0 +for i in range(1,n+1): + a=ketacul(i) + if a%2==1: + count+=1 +print(count)" +p03281,s427893517,Wrong Answer,"N = int(input()) +if N < 105: + print(0) +elif N < 165: + print(1) +else: + print(2) +" +p02743,s653072322,Wrong Answer,"a, b, c = map(int, input().split()) +print(""Yes"")" +p03835,s765462320,Wrong Answer,"def LI(): + return list(map(int, input().split())) + + +K, S = LI() +ans = 0 +for i in range(K+1): + total = S-i + kosu = total+1 + if total > 2*K: + continue + if total > K: + kosu -= (total-K)*2 + ans += kosu + else: + ans += kosu +print(ans) +" +p03073,s594347919,Accepted,"import sys +s = input() +n = len(s) +ans =0 +ans += s[0::2].count(""0"") +ans += s[1::2].count(""1"") +if n / 2 <= ans: + print(n - ans) +else: + print(ans )" +p03836,s728872674,Wrong Answer,"sx, sy, tx, ty = map(int, input().split()) +print(""U""*(ty-sy) + ""R""*(tx-sx+1) + ""D""*(ty-sx+1) + ""U"" + ""L"" + ""U""*(ty-sy+1) + ""R""*(tx-sx+1) + ""D""*(ty-sy+1) + ""L""*(tx-sx))" +p03210,s831548776,Accepted,"x = int(input()) +print(""YES"" if x == 7 or x == 5 or x == 3 else ""NO"")" +p02760,s838254797,Accepted,"A = [[int(_) for _ in input().split()] for _ in range(3)] +N = int(input()) +B = [int(input()) for _ in range(N)] + +for a in A: + for b in B: + if b in a: + a[a.index(b)] = 0 + +ans = ""No"" +if [A[i][i] for i in range(3)] == [0, 0, 0]: + ans = ""Yes"" +if [A[i][2-i] for i in range(3)] == [0, 0, 0]: + ans = ""Yes"" +for i in range(3): + if A[i] == [0, 0, 0]: + ans = ""Yes"" + if [A[j][i] for j in range(3)] == [0, 0, 0]: + ans = ""Yes"" +print(ans) +" +p03282,s133115276,Accepted,"S=input() +K=int(input()) +ans=""1"" +for i in range(K): + if S[i]!=""1"": + ans=S[i] + break +print(ans)" +p03861,s556566679,Wrong Answer,"a, b, x = map(int, input().split()) + +if (a - 1) < 0: + count_a = 0 +else: + count_a = (a - 1) // 2 + 1 + +count_b = b // x + 1 + +print(count_b - count_a) +" +p02959,s606669911,Accepted,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +ans=0 +for i in range(n): + if b[i] > a[i]: + b[i] -= a[i] + ans += a[i] + if b[i] > a[i+1]: + ans += a[i+1] + a[i+1] = 0 + else: + ans += b[i] + a[i+1] -= b[i] + else: + ans += b[i] + b[i]=0 +print(ans)" +p03030,s723208217,Wrong Answer,"N = int(input()) +dict = {} +for i in range(1, N+1): + S, P_str = tuple(input().split()) + P = int(P_str) + try: + dict[S].append((P, i)) + except: + dict[S] = [(P, i)] + +items = sorted(dict.items(), key=lambda x: x[1], reverse=True) +for city, info in items: + for p, n in sorted(info, reverse=True): + print(n)" +p02724,s872249769,Wrong Answer,"x = int(input()) +happy = 0 + +happy += 1000*(x//500) +happy += 5*((x%500)%5) +print(happy)" +p02613,s727992914,Wrong Answer,"def main(): + import collections + n = int(input()) + mylist = [] + for i in range(n): + s = input() + mylist.append(s) + c = collections.Counter(mylist) + print('AC × ' + str(c['AC'])) + print('WA × ' + str(c['WA'])) + print('TLE × ' + str(c['TLE'])) + print('RE × ' + str(c['RE'])) +if __name__ == ""__main__"": + main()" +p02661,s871426628,Wrong Answer," +N = int(input()) +A = [] +B = [] +for _ in range(N): + a, b = map(int, input().split()) + A.append(a) + B.append(b) + +A.sort() +B.sort(reverse=True) +mid1 = A[(N + 1) // 2 - 1] +mid2 = B[(N + 1) // 2 - 1] + +if N % 2 == 1: + print(mid2 - mid1 + 1) +else: + print((mid2 - mid1) * 2 - 1) +" +p02888,s894684902,Wrong Answer,"n = int(input()) +ll = list(map(int,input().split())) + +ll = sorted(ll) + +import bisect + +ans = 0 +for i in range(n): + for j in range(i+1, n): + k = ll[i] + ll[j] + idx1 = bisect.bisect_left(ll, ll[j]) + idx2 = bisect.bisect_left(ll, k) + ans += idx2 - idx1 - 1 +print(ans) +" +p02888,s226988755,Wrong Answer,"import itertools +import bisect +N = int(input()) +L = list(map(int, input().split())) +ans = 0 +LS = sorted(L) +l = len(LS) +print(LS) +for i in range(l): + for j in range(l): + if i < j: + for k in range(j+1,l): + if LS[i]+LS[j] > LS[k]: + ans += 1 + else: + break +print(ans) +" +p02838,s395640940,Wrong Answer,"import numpy as np + +N=int(input()) +M=10**9+7 +A=[int(x) for x in input().split()] +A=np.array(A) + +ans=0 +for i in range(70): + #one=sum([a>>i&1 for a in A]) + one=np.sum((A>>i)&1) + zero=N-one + ans+=(one*zero)*pow(2,i,M) + ans%=M + #print(one,zero) +print(ans)" +p03067,s817408551,Wrong Answer,"a,b,c=map(int,input().split()) +print('Yes' if ak: + m=k + r=c + c+=1 + print(r)" +p02691,s999207207,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +check = {} +ans = 0 + +for i in range(N): + x = i - A[i] + y = A[i] + i + ans += check.get(x, 0) + check.setdefault(y, 0) + check[y] += 1 + +print(ans)" +p03281,s565165407,Accepted,"import math +n = int(input()) + +def judge(num): + count=0 + for i in range(1,num+1): + if num%i==0: + count+=1 + return count + +ans=0 +for i in range(3,n+1,2): + if judge(i)==8: + ans+=1 + +print(ans) + +" +p03351,s803026198,Accepted,"import sys +input = sys.stdin.readline +a,b,c,d = [int(i) for i in input().split()] +dab =abs(b-a) +dbc = abs(b-c) +ans = ""No"" +dac = abs(a-c) +if (dab <=d and dbc <= d) or dac<=d : + ans = ""Yes"" +print(ans)" +p02547,s506231570,Accepted,"n = int(input()) +d = [list(map(int, input().split())) for _ in range(n)] + +exist = False +for i in range(n-2): + for j in range(3): + if d[i+j][0] != d[i+j][1]: + break + else: + exist = True +if exist: + print('Yes') +else: + print('No')" +p02598,s244503256,Wrong Answer,"import math +N, K = map(int, input().split()) +A=list(map(int,input().split())) +maxA = max(A) +right = maxA+1 +left = 0 +while(right-left>1): + mid = (left+right)//2 + count = 0 + for i in A: + count += (i-1)//mid + if count > K: + left = mid + elif count <= K: + right = mid +print(mid) +" +p02572,s636590283,Accepted,"n = int(input()) +L = list(map(int,input().split())) + +L = sorted(L,reverse=True) + +#print(L) +t = 0 +a = 0 +for i in range(1,n): + t += L[i-1] + a += (t * L[i]) #% (10**9 + 7) +# print(t,a) + +print(a % (10**9 + 7)) +" +p03695,s658895407,Wrong Answer,"import sys + +n = int(sys.stdin.readline().rstrip()) +a = [int(x) for x in sys.stdin.readline().rstrip().split()] + +a_set = set() +counter_wild = 0 +for x in a: + if x>=3200: + counter_wild+=1 + else: + a_set.add(x//400) +print(max(1,len(a_set)),min(8,len(a_set)+counter_wild)) +" +p02957,s045943423,Accepted,"def main(): + a,b = map(int,input().split()) + + if (a+b) % 2 != 0: + print('IMPOSSIBLE') + else: + print((a+b)//2) + +if __name__ == '__main__': + main() +" +p02633,s139185070,Accepted,"x = int(input()) + +for k in range(1, 100000): + if (k * x) % 360 == 0: + print(k) + exit() +" +p03605,s167680002,Accepted,"s = input() +print(""Yes"" if ""9"" in s else ""No"") +" +p02823,s867686774,Wrong Answer,"def solve(N, A, B): + if A % 2 == B % 2: + return (B - A) // 2 + return int(min(A-1, N-B) + 1 + (B - A -1)/2) + +if __name__ == ""__main__"": + n, a, b = map(int, input().split()) + print(int(solve(n, a, b))) +" +p02777,s170059624,Accepted,"s,t=input().split() +a,b=map(int,input().split()) +u=input() +if u==s: + a-=1 +else: + b-=1 +print(a,b)" +p02801,s350660855,Accepted,"c = input() + +print(chr(ord(c) + 1))" +p02726,s722248500,Wrong Answer,"import copy +N, X, Y = input().split() +N = int(N) +X = int(X) +x = X - 1 +Y = int(Y) +y = Y -1 + +A = [[0] * N for _ in range(N)] +for i in range(N): + for j in range(N-i): + A[i][i + j] = min(abs(x- i) +1 +abs(y-i-j),j) +A[X-1][Y-1] = 1 +ans = [] + +for p in range(N): + ans.append(sum(A, [])) + print(ans) +for t in range(N): + if t == 0: + continue + sum = A.count(t) + print(ans[0].count(t)) + + +" +p03030,s740140319,Accepted,"n = int(input()) +restaurants = [] +for i in range(n): + s, p = input().split() + restaurants.append((s, int(p))) +sorted_list = sorted(restaurants, key=lambda x:x[1], reverse=True) +sorted_list.sort(key=lambda x:x[0]) + +for i in range(n): + print(restaurants.index(sorted_list[i]) + 1)" +p03627,s008680902,Wrong Answer,"from collections import Counter +def solve(): + n = int(input()) + a = list(map(int, input().split())) + + l = Counter(a) + sq = [] + for i,j in l.items(): + if j >= 2: + sq.append(i) + + if len(sq) >= 2: + sq.sort() + return sq[-1]*sq[-2] + else: + return 0 + + +print(solve()) +" +p03625,s152590238,Accepted,"n = int(input()) +a = list(map(int, input().split())) +from collections import Counter +a = Counter(a) +lis = [] + +for i,j in a.items(): + lis += [i]*(j//2) + +#print(lis) + +lis.sort(reverse=True) +if len(lis) <= 1: + ans = 0 +else: + ans = lis[0]*lis[1] + +print(ans)" +p02909,s820821386,Accepted,"s = input() +if s == 'Sunny': + print('Cloudy') +elif s == 'Cloudy': + print('Rainy') +else: + print('Sunny') +" +p03860,s887326567,Accepted,"s = input().split()[1] +print('A'+s[0]+'C')" +p03627,s102293139,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +from collections import Counter +from operator import itemgetter +C = Counter(A) +Cs = sorted(C.items(), key=itemgetter(0), reverse=True) +e = [] +for k,v in Cs: + if v >= 2: + e.append(k) + if len(e) >= 2: break +if len(e) >= 2: + print(e[0]*e[1]) +else: + print(0)" +p03076,s967018016,Wrong Answer,"n=[int(input()) for _ in range(5)] +try: + m=10-min([i%10 for i in n if i%10!=0]) + n=[i if i%10==0 else i+(10-i%10) for i in n] + print(sum(n)-m) +except: + print(60)" +p03126,s746984292,Accepted,"import sys +def input(): return sys.stdin.readline().rstrip() + +def main(): + N, M = map(int, input().split()) + + ans = set(range(1, M+1)) + for _ in range(N): + ans &= set(map(int, input().split()[1:])) + print(len(ans)) + +if __name__ == '__main__': + main() +" +p03524,s290569034,Accepted,"S=input() +a=0 +b=0 +c=0 +for i in range(len(S)): + if S[i]=='a': + a+=1 + elif S[i]=='b': + b+=1 + else: + c+=1 +# print(a,b,c) +if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1: + print('YES') +else: + print('NO')" +p03557,s342890351,Accepted,"from bisect import bisect,bisect_left +N=int(input()) +A=sorted(list(map(int,input().split()))) +B=sorted(list(map(int,input().split()))) +C=sorted(list(map(int,input().split()))) +ans=0 +for b in B: + i=bisect_left(A,b) + j=bisect(C,b) + ans+=i*(N-j) +print(ans)" +p02713,s397496497,Accepted,"K=int(input()) + +def gcd(x,y): + if x= 0: + tmp += 1 + if tmp == N-2: + break + else: + if tmp == N-3: + ans +=1 + ans += 1 + i = tmp+2 + if i == N-2: + ans += 1 +print(ans)" +p02702,s358892132,Accepted,"s = input() +s_len = len(s) +n = 2019 +mod_list = [0] * n +mod_list[0] = 1 + +p = 1 +d = 0 +for t in reversed(s): + d += int(t) * p + m = d % n + mod_list[m] += 1 + p *= 10 + p %= 2019 + +result = sum(i * (i - 1) // 2 for i in mod_list) +print(result)" +p02594,s802916548,Accepted,"X = int(input()) + +if X >= 30: + print('Yes') +else: + print('No')" +p03011,s606608664,Accepted,"P, Q, R = map(int ,input().split()) +print(min(P+Q, Q+R, R+P))" +p03077,s981150766,Accepted,"n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +print(-(-n//min(a,b,c,d,e))+5-1)" +p03043,s665791864,Accepted,"N, K = list(map(int, input().split())) +Pd = 1 / N +Pc = 0.5 +ans = [] +def f(i): + P = Pd + while(i 0: + s[-1] = chr(ord(s[-1])+k%26) +print(*s, sep='') + +" +p02939,s104535311,Accepted,"s = input() + +# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0817_agc037 + +ans = 0 +prev = '' +i = 0 +while i < len(s): + c = s[i] + # 前の文字と現在の文字が同じ + if c == prev: + i += 1 + if i == len(s): + break + # 2文字になる + c += s[i] + prev = c + i += 1 # 次の文字へ進む + ans += 1 + +print(ans) +" +p03852,s448291324,Wrong Answer,"I = input() +import re +if re.match(""(a|i|u|e|o)1"", I): + print('vowel', flush=True) +else: + print('consonant', flush=True) +" +p03252,s425052798,Accepted,"s=input();d=input();n=len(s) +di={""abcdefghijklmnopqrstuvwxyz""[i]:i for i in range(26)} +sl,dl=[set() for _ in range(26)],[set() for _ in range(26)] +for i,(x,y) in enumerate(zip(s,d)): + sl[di[x]].add(i);dl[di[y]].add(i) +for i in dl: + if i and i not in sl :print(""No"");exit() +print(""Yes"") +" +p03163,s600136123,Accepted,"#!/usr/bin/env python3 + +#import +#import math +#import numpy as np +N, W = map(int, input().split()) +wv = [list(map(int, input().split())) for _ in range(N)] + +dp = [0] * (W + 1) + +for w, v in wv: + for i in range(W, 0, -1): + if i - w < 0: + break + + dp[i] = max(dp[i], dp[i - w] + v) + +print(dp[W]) +" +p03759,s334363999,Wrong Answer,"a, b, c = map(int, input().split()) + +if abs(a - b) == abs(b - c): + print('YES') +else: + print('NO')" +p03062,s205759947,Accepted,"n = int(input()) +a = list(map(int,input().split())) +s = 0 +for i in range(n): + if a[i] < 0: + a[i] = -a[i] + s += 1 +if s % 2 == 0: + print(sum(a)) +else: + print(sum(a) - 2 * min(a)) +" +p03557,s455077934,Accepted,"import bisect +from sys import stdin + +def get_result(data): + N = data[0][0] + A = sorted(data[1]) + B = sorted(data[2]) + C = sorted(data[3]) + ans = 0 + for mid_val in B: + num_a = bisect.bisect_left(A, mid_val) + num_c = N - bisect.bisect_right(C, mid_val) + ans += num_a * num_c + return ans + + +if __name__ == '__main__': + raw_data = [val.rstrip() for val in stdin.readlines()] + data = [list(map(int, val.split(' '))) for val in raw_data] + result = get_result(data) + print(result) +" +p02600,s565558824,Accepted,"x = int(input()) + +if 400 <= x <= 599: + print(""8"") +elif 600 <= x <= 799: + print(""7"") +elif 800 <= x <= 999: + print(""6"") +elif 1000 <= x <= 1199: + print(""5"") +elif 1200 <= x <= 1399: + print(""4"") +elif 1400 <= x <= 1599: + print(""3"") +elif 1600 <= x <= 1799: + print(""2"") +else: + print(""1"")" +p02802,s807812108,Wrong Answer,"N,M = map(int,input().split()) +AC_flag = [False]*N +WA_count = [0]*N +for m in range(M): + P,S = map(str,input().split()) + p = int(P) + if AC_flag[p-1] == False and S == ""AC"": + AC_flag[p-1] = True + if AC_flag[p-1] == False and S == ""WA"": + WA_count[p-1] += 1 +print(*[sum(AC_flag),sum(WA_count)])" +p02600,s603831219,Accepted,"n = int(input()) +if n < 600: + print(8) +elif n < 800: + print(7) +elif n < 1000: + print(6) +elif n < 1200: + print(5) +elif n < 1400: + print(4) +elif n < 1600: + print(3) +elif n < 1800: + print(2) +else: + print(1) +" +p02755,s068115460,Wrong Answer,"import math + +a, b = map(int, input().split()) + +point = a/0.08 +seg_a = (math.ceil(point), math.floor(point + 12.5)) + +point = b/0.1 +seg_b = (point, point + 9) + +if seg_b[1] < seg_a[0]: + print(-1) +else: + print(int(seg_a[0]))" +p02681,s632635539,Accepted,"S = input() +T = input() + +ans = 'Yes' +for i in range(len(S)): + if S[i] != T[i]: + ans = 'No' + break + +print(ans) +" +p03773,s980440685,Wrong Answer,"A,B = [int(i) for i in input().split()] +if A + B > 24: + print(A + B -24) +else: + print(A+B) +" +p03324,s798061613,Accepted,"D,N = map(int,input().split()) + +if D == 0: + c = N//100 + print(N+c) +else: + tmp = 100 ** D + c = N//100 + print(tmp*N+c*tmp)" +p03495,s691514970,Accepted,"n,k = map(int,input().split()) +a = list(map(int,input().split())) + +if(len(set(a)) <= k): + print(0) +else: + dic_a = {x:0 for x in set(a)} + for i in a: + dic_a[i] += 1 + sum = 0 + a = sorted(dic_a.values(),reverse=True) + for i in range(k,len(a)): + sum += a[i] + print(sum)" +p03719,s945948654,Accepted,"A,B,C = map(int,input().split()) +if A<=C<=B: + print(""Yes"") +else: + print(""No"")" +p03416,s318114958,Wrong Answer,"A, B = map(int, input().split()) + +ans = 0 +for i in range(A, B+1): + i = str(i) + former = i[:2] + latter = i[3:] + if former in [latter, latter[::-1]]: + ans += 1 +print(ans) +" +p03211,s341940708,Wrong Answer," +def main(): + X = input() + mini = 100000 + + for index in range(len(X)-3): + if mini > abs(int(X[index:index+3]) - 753): + mini = abs(int(X[index:index+3]) - 753) + print (mini) + + + + +if __name__ == '__main__': + main() +" +p02982,s905702377,Wrong Answer,"import math +n,d = map(int,input().split()) +x = [list(map(int,input().split())) for _ in range(n)] +def distance(a,b): + s = 0 + for i in range(d): + s += (a[i]-b[i])**2 + return math.sqrt(ans) +ans = 0 +for i in range(n-1): + for j in range(i+1,n): + if distance(x[i],x[j])//1 == distance(x[i],x[j]): + ans += 1 +print(ans)" +p04029,s223474220,Wrong Answer,"N = int(input()) +print (N*(N+1)/2)" +p02987,s324951308,Wrong Answer,"s=sorted(input()) +print('Yes'if(s[::2]==s[1::2]==s[1:3])else'No')" +p02994,s318146127,Wrong Answer,"#!/usr/bin/env python3 + + +def main(): + N, L = map(int, input().split()) + if L >= 0: + # L + 1 から L + N - 1 の和 + print((N - 1) * (2 * L + N) // 2) + elif L <= -N: + # L から L + N - 2 の和 + print((N - 1) * (2 * L + N - 2) // 2) + else: + # L から L + N - 1 の和 + print((N - 1) * (2 * L + N - 1) // 2) + + +if __name__ == '__main__': + main() +" +p03137,s847467423,Wrong Answer,"def calculate(n,m,arr): + arr.sort() + drr = list([]) + for index in range(1,len(arr)): + drr.append(arr[index] - arr[index-1]) + drr.sort() + drr = drr[:m-1-(n-1)] + print(sum(drr)) + + + +S = input().split("" "") +n = int(S[0]) +m = int(S[1]) + +S = input().split("" "") + +arr = list([int(s) for s in S]) + + +calculate(n,m,arr) + +" +p03241,s187994453,Wrong Answer,"import sys +import math + +N,M=map(int,input().split()) + +divisor_set=set() +for i in range(1,int(math.sqrt(M))): + if M%i==0: + divisor_set.add(i) + divisor_set.add(M//i) +#print(divisor_set) + +divisor_list=list(divisor_set) +divisor_list.sort() + +for l in divisor_list: + if l>=N: + answer=M//l + print(answer) + break +" +p02603,s098096024,Accepted,"N = int(input()) +A = list(map(int,input().split())) +Money = 1000 +Stock = 0 +for i in range(N-1): + if A[i] > A[i+1]: + Money += A[i]*Stock + Stock = 0 + else: + Stock += Money // A[i] + Money %= A[i] +print(Stock*A[N-1]+Money)" +p02995,s758701283,Accepted,"from fractions import gcd +a,b,c,d=map(int,input().split()) +m=int(c*d/gcd(c,d)) +print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//m-(a-1)//m))" +p02682,s701949914,Accepted,"a,b,c,k = map(int,input().split()) + + +ka = k - a + +if ka > 0: + kb = ka - b +elif ka <= 0: + a = k + ka = 0 + kb = 0 +else: + kb = 0 +print(a*1+ka*0+kb*-1) +" +p02785,s914497572,Wrong Answer,"import heapq + +N,K = (int(x) for x in input().split()) +H = list((-1)*(int(x)) for x in input().split()) +heapq.heapify(H) + +for _ in range(K): + if len(H) == 1: + print(0) + break + + heapq.heappop(H) + +if len(H) != 1: + sum = 0 + for _ in range(len(H)): + sum -= heapq.heappop(H) + + print(sum) + + + + +" +p02995,s439909558,Wrong Answer,"def gcd(a,b):#最大公約数を返す。Euclid + if a 0: + print(*[i for i in b if i == 1]) +" +p02773,s365342853,Accepted,"import collections +n=int(input()) +s=[] +ans=[] +for i in range(n): + si=input() + s.append(si) +s_new=collections.Counter(s) +s_most=s_new.most_common() +buf=s_most[0][1] +cnt=0 +for i in range(len(s_new)): + if s_most[i][1]==buf: + ans.append(s_most[i][0]) + cnt+=1 + elif s_most[i][1] x: + f = False + print(i) + break +if f: + print(n+1)" +p02553,s199424813,Accepted,"a,b,c,d = map(int,input().split()) +x = [a , b] +y = [c , d] +m = a*c +for i in x: + for j in y: + if i*j > m: + m = i*j +print(m) " +p03087,s645021193,Accepted,"import sys +input = sys.stdin.readline + +def main(): + n, q = map(int, input().split()) + s = input() + t = [0]*(n + 1) + + for i in range(n): + if s[i: i + 2] == ""AC"": + t[i + 1] = t[i] + 1 + else: + t[i + 1] = t[i] + + for i in range(q): + l, r = map(int, input().split()) + print(t[r - 1] - t[l - 1]) + +main()" +p02862,s761909777,Accepted,"X, Y =map(int, input().split()) +mod = 1000000007 + +import sys +if (X + Y) % 3 != 0: + print(0) + sys.exit() +offset = (X+Y)//3 +X, Y = X-offset, Y-offset + +if X<0 or Y<0: + print(0) + sys.exit() + +X, Y = max(X, Y), min(X, Y) + +def C(n, r, mod): + num = 1 + den = 1 + for i in range(r): + num*=n-i + num%=mod + den*=i+1 + den%=mod + return (num*pow(den, mod-2, mod))%mod + +print(C(X+Y, Y, mod)) +" +p02694,s369974691,Accepted,"X = int(input()) +money = 100 +count = 0 +while money < X: + money = int(money*1.01) + count +=1 +print(count)" +p03612,s509422388,Wrong Answer,"n = int(input()) +*p, = map(int, input().split()) +ans = 0 +for i in range(n-1): + if (p[i] == (i+1) or p[i+1] == (i+2)): + if p[i] == (i+2) or p[i+1] == (i+1): + continue + ans += 1 + p[i], p[i+1] = p[i+1], p[i] +print(ans) +" +p03219,s606763237,Accepted,"a,b=map(int,input().split()) +print(int(a+b/2))" +p02748,s621651309,Accepted,"A, B, M = map(int, input().split()) +*a, = map(int, input().split()) +*b, = map(int, input().split()) +a_s = sorted(a) +b_s = sorted(b) +min_v = a_s[0] + b_s[0] +for _ in range(M): + x, y, c = map(int, input().split()) + min_v = min(min_v, a[x-1] + b[y-1] - c, ) +print(min_v)" +p02860,s589649467,Accepted,"N = int(input()) +S = input() + +middle = len(S) // 2 + +if S[:middle] == S[middle:]: + print('Yes') +else: + print('No') +" +p02838,s322571464,Accepted,"N = int(input()) +A = list(map(int,input().split())) +mod = 10**9 + 7 +m = 62 +d =[0]*m +ans = 0 +for i in range(N): + for j in range(m): + if A[i]&(1< 0: + print('POSSIBLE') +else: + print('IMPOSSIBLE')" +p03086,s040728827,Accepted,"S = input() + +li = [] +cnt = 0 +for i in range(len(S)): + if S[i] == ""A"" or S[i] == ""C"" or S[i] == ""G"" or S[i] == ""T"": + cnt += 1 + else: + li.append(cnt) + cnt = 0 +li.append(cnt) + +print(max(li))" +p03471,s458260328,Accepted,"n, yen = map(int, input().split()) +for x in range(n + 1): + for y in range(n - x + 1): + z = n - x - y + if yen == x * 10000 + y * 5000 + z * 1000: + print(x, y, z) + exit(0) +print(""-1 -1 -1"")" +p03076,s715207185,Accepted,"def main(): + import sys + input = sys.stdin.readline + ans = 0 + a = 10**3 + for i in range(5): + x = int(input()) + ans += ((x + 9) // 10) * 10 + aa = x % 10 + if aa == 0: + continue + a = min(a, aa) + if a == 10 ** 3: + a = 10 + ans -= 10 - a + print(ans) + + +if __name__ == '__main__': + main()" +p03261,s419250036,Wrong Answer,"import sys + +N = int(input()) +W = list(input() for _ in range(N)) + +if len(set(W)) == N: + for i in range(N-1): + a = W[i] + b = W[i+1] + if a[0] != b[-1]: + print('No') + sys.exit() + else: + print('Yes') +else: + print('No')" +p02995,s111272739,Wrong Answer,"a,b,c,d = map(int, input().split()) +import fractions +r = b-a+1 +g = c * d // fractions.gcd(c, d) +ans_c = b//c - (a-1)//c +ans_d = b//d - (a-1)//d +ans_r = b//r - (a-1)//r +print(r - ans_c - ans_d + ans_r) +" +p03469,s716792188,Accepted,"s = input() +print(s.replace(""2017"", ""2018""))" +p04045,s277496455,Accepted,"n, k = map(int, input().split()) +d = list(map(int, input().split())) +ng = [False] * 10 +for i in d: + ng[i] = True +def ok(n): + global ng + while n > 0: + if ng[n%10]: + return False + n //= 10 + return True +while not ok(n): + n += 1 +print(n)" +p03073,s498316348,Accepted,"S = list(map(int,list(input()))) +N = len(S) + +sirokuro =[i%2 for i in range(0,N,1)] +kurosiro =[(i+1)%2 for i in range(0,N,1)] + +loss1 = 0 +for i in range(0,N,1): + if S[i]!=sirokuro[i]: + loss1 +=1 + +loss2 = 0 +for i in range(0,N,1): + if S[i]!=kurosiro[i]: + loss2+=1 + +print(min(loss1,loss2))" +p03612,s302686915,Wrong Answer,"n = int(input()) +p = list(map(int,input().split())) +count = 0 + +for i in range(n-1): + if p[i] == i+1: + count += 1 + p[i],p[i+1] = p[i+1],p[i] + +print(count)" +p02833,s861608936,Wrong Answer,"n=int(input()) +if n<10: + print(0) +elif n%2==0: + a=int(n/2) + b=0 + for i in range(n): + a=a//5 + b+=a + if a<4.5: + break + print(b) +else: + print(0) +" +p03611,s459891288,Accepted,"n = int(input()) +a = list(map(int,input().split("" ""))) + +c_dic = {} +for i in a: + if i not in c_dic: + c_dic[i] = 1 + else: + c_dic[i] += 1 + + if i + 1 not in c_dic: + c_dic[i + 1] = 1 + else: + c_dic[i + 1] += 1 + + if i - 1 not in c_dic: + c_dic[i - 1] = 1 + else: + c_dic[i - 1] += 1 + +print(max(c_dic.values()))" +p02842,s884720910,Accepted,"import math +n = float(input()) +m_low = math.ceil(n / 1.08) +m_high = math.floor((n+1)/1.08) +if m_low > m_high: + print(':(') +else: + ch_low = math.floor(m_low*1.08) + ch_high = math.floor(m_high*1.08) + if ch_low == int(n): + print(m_low) + elif ch_high == int(n): + print(m_high) + else: + print(':(')" +p03086,s640219046,Accepted,"import re +S = input() +s = re.split('[BDEFHIJKLMNOPQRSUVWXYZ]',S) +print(max(map(len,s))) +" +p02631,s471999686,Wrong Answer,"n = int(input()) +A = list(map(int, input().split())) + + +def calc_total(A): + total = [] + for x, y in zip(A, A[1:]): + total.append(x ^ y) + return total + + +total = A +while len(total) != 1: + total = calc_total(total) +total = total[0] +ans = [] +for a in A: + ans.append(total ^ a) +print(*ans) +" +p03774,s936239371,Accepted,"N, M = map(int, input().split()) +ab = [tuple(map(int, input().split())) for _ in range(N)] +cd = [tuple(map(int, input().split())) for _ in range(M)] + +for a, b in ab: + n = 10 ** 9 + m = 0 + for i, (c, d) in enumerate(cd): + x = abs(a - c) + abs(b - d) + if x < n: + n = x + m = i + 1 + + print(m)" +p02761,s145095022,Accepted,"n, m = list(map(int, input().split(' '))) +pairs = [] + +for i in range(m): + pairs.append(list(map(int, input().split(' ')))) + +num = [-1 for i in range(n)] + +for pair in pairs: + s, c = pair + + if (num[s-1] != -1 and num[s-1] != c) or (s == 1 and c == 0 and n > 1): + print(-1) + exit(0) + else: + num[s-1] = c + +for i in range(n): + if num[i] == -1: + num[i] = 0 if i != 0 or n == 1 else 1 + +print(''.join([str(i) for i in num]))" +p02724,s745325105,Accepted,"X = int(input()) + +fh_joy = 0 +five_joy = 0 + +amari = X +while amari >= 500: + amari -= 500 + fh_joy += 1000 +while amari >= 5: + amari -= 5 + five_joy += 5 + +print(fh_joy + five_joy)" +p02847,s684684651,Accepted,"S = input() + +d = {""SUN"": 7, ""MON"":6, ""TUE"":5, ""WED"":4, ""THU"":3, ""FRI"":2, ""SAT"":1} +print(d[S])" +p03037,s604718088,Wrong Answer,"n,m=map(int,input().split()) +L=[] +R=[] +for i in range(m): + l,r=map(int,input().split()) + L.append(l) + R.append(r) + +ans=min(R)-max(L)+1 +print(ans)" +p03545,s448938346,Accepted,"s = list(map(int,list(input()))) +op_num = len(s)-1 +for i in range(2**op_num): + ans = ['-']*op_num + total = s[0] + for j in range(op_num): + if (i>>j) & 1: + total += s[j+1] + ans[j]='+' + else: + total -= s[j+1] + if total == 7: + print(str(s[0])+ans[0]+str(s[1])+ans[1]+str(s[2])+ans[2]+str(s[3])+'=7') + exit() + + " +p02860,s320898996,Wrong Answer," +def main(): + N = int(input()) + S = input() + f = S[:int(N/2)] + b = S[int(-(-N//2)):] + if f==b and len(f)>0: + print(""Yes"") + else: + print(""No"") + + +if __name__ == '__main__': + main() +" +p03250,s554220599,Accepted,"# -*- coding: utf-8 -*- +#110_a + +A, B, C = [int(i) for i in input().split()] + +desc = sorted([A,B,C], reverse=True) +print(desc[0]*10 + desc[1]+desc[2]) +" +p03723,s784378897,Accepted,"A,B,C = map(int, input().split()) +n = 0 +while A % 2 == 0 and B % 2 == 0 and C % 2 == 0: + if A == B == C: + print ('-1') + exit() + else: + a = B/2 + C/2 + b = A/2 + C/2 + c = A/2 + B/2 + A = a + B = b + C = c + n += 1 + + +print(n)" +p03331,s561225194,Wrong Answer,"n = int(input()) + + +x = n - 2 +y = n - x + +if n <= 10: + print(n) +else: + resulty, resultx = 0, 0 + + while(x > 0): + resultx += x % 10 + x = x // 10 + + while(y > 0): + resulty += y % 10 + y = y // 10 + + #print(resulty+resultx) + z = n//2 + + result = 0 + while(z > 0): + result += z % 10 + z = z // 10 + + if result*2 < resulty+resultx: + print(result*2) + else: + print(resulty+resultx) + +" +p03319,s920397450,Accepted,"import sys +def input(): return sys.stdin.readline().strip() + +def resolve(): + n,k=map(int, input().split()) + l=list(map(int,input().split())) + cnt=0 + while True: + if n<=k: + cnt+=1 + print(cnt) + break + n -= k + n += 1 + cnt += 1 +resolve()" +p02623,s448304299,Accepted,"n, m, k = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +arr1, arr2 = [0], [0] +for i in range(n): + arr1.append(arr1[i] + A[i]) +for i in range(m): + arr2.append(arr2[i] + B[i]) + +count = 0 +j = m +for i in range(n + 1): + if arr1[i] > k: + break + while arr2[j] > k - arr1[i]: + j -= 1 + count = max(count, i + j) +print(count)" +p03565,s570032852,Accepted,"S = input() +T = input() +t = len(T) + +for i in range(len(S)-t, -1, -1): + for j in range(t): + k = S[i+j] + if k != T[j] and k != ""?"": + break + else: + print((S[:i]+T+S[i+t:]).replace(""?"", ""a"")) + exit() +print(""UNRESTORABLE"")" +p02819,s086138863,Accepted,"def is_prime(n): + if n == 2: + return True + if (n < 2) or (n % 2 == 0): + return False + stop = int(n**0.5) + 1 + for i in range(3, stop, 2): + if n % i == 0: + return False + return True + +x = int(input()) +while not is_prime(x): + x += 1 +print(x)" +p02603,s139115084,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +kab=0 +mon=1000 + +for i in range(n-1): + if a[i]=d: + print('Yes') +else: print('No')" +p03485,s815883660,Accepted,"import math +a,b=map(int,input().split()) +print(math.ceil((a+b)/2))" +p03126,s325945025,Accepted,"n, m = map(int, input().split()) +cnt = [0]*m +ans = 0 + +for i in range(n): + k, *a = map(int, input().split()) + for j in a: + cnt[j - 1] += 1 + +for i in cnt: + if i == n: + ans += 1 + +print(ans)" +p02765,s228999440,Wrong Answer,"N,R = map(int,input().split()) +if N >= 10: + print(R) +else: + print(100*(10-N))" +p03607,s396519397,Accepted,"n=int(input()) +s=set() +for i in range(n):s^={input()} +print(len(s))" +p03544,s467194077,Accepted,"def main(): + N = int(input()) + lucas = [0] * (N+1) + lucas[0] = 2 + lucas[1] = 1 + for i in range(2, N+1, 1): + lucas[i] = lucas[i-1] + lucas[i-2] + print(lucas[N]) + +main()" +p02873,s441012738,Wrong Answer,"S=list(input()) + +s=0 +f=0 +g=0 +h=0 +for i in range(len(S)): + if S[i]=="">"": + g=0 + f+=1 + if f!=1: + if h>=f: + s+=f-1 + else: + s+=f + + else: + f=0 + g+=1 + s+=g + h=g + +print(s) +" +p02833,s737199603,Accepted,"import sys +def input(): + return sys.stdin.readline()[:-1] +def gcd(a,b): + if b == 0: + return a + return gcd(b,a%b) + +def main(): + N = int(input()) + if N%2 == 1: + print(0) + else: + t = 2*5 + s = 0 + while t <= N: + s += N//t + t *= 5 + print(s) +if __name__ == '__main__': + main() +" +p02935,s581153957,Accepted,"n=int(input()) +v=list(map(int,input().split())) + +v.sort() +for i in range(0,n-1): + t=v.pop(0) + v[0]=(v[0]+t)/2 +print(v[0])" +p03251,s250532477,Accepted,"N,M,X,Y = map(int,input().split()) +x = list(map(int,input().split())) +y = list(map(int,input().split())) +if max(x) < min(y) and X < min(y) <= Y: + print(""No War"") +else: + print(""War"") +" +p02601,s598524512,Wrong Answer,"a,b,c=map(int,input().split()) +k=int(input()) +for i in range(k): + if b<=a: + if c<=b: + c*=2 + else: + b*=2 + elif c<=b: + c*=2 + else: + a*=2 + +if a=1 and len(c)<=50 and b>=1 and b<=len(c): + c=c.replace(c[b-1],c[b-1].lower()) + print(c)" +p03126,s045733881,Accepted,"n, m = map(int, input().split()) +cnt = [0] * m +for i in range(n): + a = list(map(int, input().split())) + for x in a: + cnt[x - 1] += 1 + cnt[a[0]-1] -= 1 + +ans = 0 +for i in range(m): + ans += cnt[i] == n +print(ans) +" +p02802,s469038783,Wrong Answer,"N, M = map(int, input().split()) +P = [] +S = [] +for i in range(M): + tmp = input().split() + P.append(int(tmp[0])) + S.append(tmp[1]) + +point = 0 +pena = 0 +ind = 0 + +for p in set(P): + isAC = False + for i in range(P.count(p)): + if S[ind] == ""AC"" and isAC == False: + isAC = True + point += 1 + if S[ind] == ""WA"" and isAC == False: + pena += 1 + ind += 1 + +print(point, pena) +" +p02859,s654746302,Accepted,"r=int(input()) +print(r**2) +" +p03681,s913700002,Wrong Answer,"import math +MOD = 10**9+7 +n, m = map(int, input().split()) + +if n == m: + print( (2 * (math.factorial(n)%MOD)**2) % MOD) +elif abs(n-m) == 1: + print((math.factorial(min(n, m))%MOD) * max(n, m)) +else: + print(0)" +p03910,s655394211,Wrong Answer,"n = int(input()) +max_check = int((n**(1/2))//1) +now = 1 +num = 1 +for i in range(1, n): + now = int(i*(i+1)/2) + if now >= n: + num = i + break +diff = now - n +for i in range(1,num+1): + if i == diff: + pass + else: + print(i) +" +p03106,s232566862,Wrong Answer,"A,B,K=map(int,input().split()) +N=100 +ls=[] +LS=[] +for i in range(1,N): + if A%i==0: + ls.append(i) + if B%i==0: + LS.append(i) +r=set(ls) +R=set(LS) +r=set(r & R) +r=list(r) +r.sort(reverse=True) +print(r[K-1])" +p03107,s157332348,Accepted,"S = input() +stack = [] +cnt = 0 +for s in S: + if not stack: + stack.append(s) + elif stack[-1] != s: + stack.pop() + cnt += 2 + else: + stack.append(s) +print(cnt)" +p02646,s116199543,Accepted,"def tag(a,b,v,w,t): + res = (v*t)-(abs(b-a)+(w*t)) + if res>=0: + return ""YES"" + return ""NO"" + +if __name__ == ""__main__"": + a,v = map(int,input().split()) + b,w = map(int,input().split()) + t = int(input()) + print(tag(a,b,v,w,t))" +p02972,s586012907,Accepted,"N = int(input()) +A = list(map(int, input().split())) +res = [-1]*N + +for i in reversed(range(1, N + 1)): + p = (N // i) * i + s = 0 + while res[p - 1] != -1: + s += res[p - 1] + s %= 2 + p -= i + res[p - 1] = (A[p - 1] - s) % 2 + +print(sum(res)) +for i in range(N): + if res[i] == 1: + print(i + 1)" +p03493,s757789970,Accepted,"str=input() +a=int(list(str)[0]) +b=int(list(str)[1]) +c=int(list(str)[2]) +print(a+b+c) + +" +p03693,s119592537,Wrong Answer,"A = list(input().split()) +a = int(''.join(A)) +if a%4==0: + print(""Yes"") +else: + print(""No"")" +p02687,s744181764,Accepted,"# S +S = input() + +if S == 'ABC': + print('ARC') +else: + print('ABC') +" +p03282,s787038548,Accepted,"n_l=list(input()) +now=0 +N=int(input()) +if n_l[:N].count(""1"") == len(n_l[:N]): + print(1) +else: + for i in range(len(n_l)): + if n_l[i] != ""1"": + print(n_l[i]) + exit()" +p02578,s008019001,Accepted,"N = int(input()) +A = input().split() +count = 0 + +for i in range(N): + A[i] = int(A[i]) +for i in range(N-1): + if A[i] > A[i+1]: + count += A[i] - A[i+1] + A[i+1] = A[i] + +print(count)" +p02577,s570681357,Accepted,"N=[int(x) for x in list(input())] +if sum(N)%9==0: + print(""Yes"") +else: + print(""No"")" +p03862,s587755801,Accepted,"N, x = map(int, input().split()) +*a, = map(int, input().split()) +a = a+[0] +ans = 0 +for i in range(0, N): + d = a[i]+a[i+1]-x + if d > 0: + for j in range(i+1, i-1, -1): + s = min([a[j], d]) + d -= s + a[j] -= s + ans += s +print(ans) +" +p03943,s654905326,Accepted,"a, b, c = map(int, input().split()) + +if (a+b==c or a+c==b or b+c==a) : + print(""Yes"") + +else: + print(""No"")" +p03612,s209120345,Accepted,"N = int(input()) +lisA = [1] + list(map(int,input().split())) + +ans = 0 +flg = False +for i,v in enumerate(lisA): + if flg: + flg = False + continue + elif i == v: + ans += 1 + flg = True + +print(ans)" +p02661,s470428211,Accepted,"N = int(input()) +A = [0]*N +B = [0]*N +for i in range(N): + A[i],B[i] = map(int,input().split()) +A.sort() +B.sort() + +if N % 2 == 1: + mid_ind = N//2 + lower = A[mid_ind] + upper = B[mid_ind] + print(upper-lower+1) + +else: + mid_a = N//2 + mid_b = mid_a-1 + lower = (A[mid_a]+A[mid_b])/2 + upper = (B[mid_a]+B[mid_b])/2 + print(int((upper-lower)*2+1)) + +" +p03962,s870529257,Wrong Answer,"a, b, c = list(map(str, input().split())) +if a != b != c: + print(3) +elif a == b == c: + print(1) +else: + print(2)" +p02854,s328388252,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = sum(A) +L = 0 +for i, a in enumerate(A): + if L + a <= S/2: + L += a + else: + R = S - L + diff = R - L + if 2*a - diff < diff: + L += a + R -= a + break + +R = S - L +print(abs(R - L))" +p03862,s819288669,Accepted,"n, x = map(int, input().split()) +a = list(map(int, input().split())) + +ans = 0 +for i in range(1, n): + candy = a[i - 1] + a[i] + if candy > x: + ans += candy - x + a[i] = max(0, a[i] - candy + x) + +print(ans) +" +p03077,s513555621,Accepted,"N = int(input()) +T = [] +for i in range(5): + T.append(int(input())) +k = 0 +for i in range(5): + if N % T[i] == 0: + k = max(k, N//T[i]) + else: + k = max(k, N//T[i] + 1) +print(4 + k)" +p02789,s708076227,Accepted,"N, M = map(int, input().split()) + +if N == M: + ans = 'Yes' +else: + ans = 'No' + +print(ans) +" +p02801,s317842377,Wrong Answer,"# A - Next Alphabet +def main(): + C = input().rstrip() + ans = chr(ord(C) + 1) + print(C) + + +if __name__ == ""__main__"": + main() +" +p03150,s447452499,Accepted,"s=str(input()) +if s==""keyence"": + print(""YES"") + exit() +f=False +for i in range(len(s)-1): + for j in range(i+1,len(s)): + if s[:i]+s[j:]==""keyence"": + f=True + break +print(""YES"" if f==True else ""NO"")" +p03319,s487539367,Accepted,"def main(): + n,k = map(int,input().split()) + a = list(map(int,input().split())) + if n==k: + print(1) + else: + print((n+k-3)//(k-1)) + +if __name__ == '__main__': + main() + +" +p02695,s249802997,Accepted,"import itertools +n, m, q = map(int, input().split()) +Q = [list(map(int, input().split())) for i in range(q)] +m = [i for i in range(1, m+1)] +p = itertools.combinations_with_replacement(m, n) + +ans = [] +for v in p: + count = 0 + for i in Q: + if v[i[1]-1]-v[i[0]-1] == i[2]: + count += i[3] + ans.append(count) +print(max(ans))" +p03759,s221030031,Wrong Answer,"#ABC058.A +a,b,c = map(int,input().split()) +if abs(a-b)==abs(b-c) or abs(a-c)==abs(a-b) or abs(a-c)==abs(b-c): + print('YES') +else: + print('NO')" +p03544,s737735920,Wrong Answer,"N = int(input()) +A =[2,1] +if N <= 2: + print(A[N-1]) + exit() +for i in range(2,N+1): + A.append(A[i-1]+A[i-2]) +print(A[-1])" +p02621,s448718266,Accepted,"(A,) = [int(x) for x in input().split()] +print(A + A * A + A * A * A) + +" +p02888,s088112493,Accepted,"n = int(input()) +L = list(map(int,input().split())) +L.sort() +import bisect +ans = 0 +for i in range(1,n): + for j in range(i+1,n): + tmp = L[:i] + v = L[j]-L[i] + idv = bisect.bisect_right(tmp,v) + if idv!=len(tmp): + ans += len(tmp)-idv +print(ans) + +" +p03146,s587225206,Wrong Answer,"s = int(input()) +co = [] +ans = 1 +count = 1 +while count == 1: + if s % 2 == 0: + s /= 2 + co.append(s) + ans += 1 + + else: + s = 3*s + 1 + co.append(s) + ans += 1 + + count = co.count(s) + if count == 2: + print(ans)" +p03145,s577814502,Wrong Answer,"triangulo = input() +lados = triangulo.split() +AB = lados[0] +BC = lados[1] +area = (int(AB) * int(BC))/2 +print(area)" +p03386,s899588571,Accepted,"a,b,k=map(int,input().split()) +r=range(a,b+1) +for i in sorted(set(r[:k])|set(r[-k:])):print(i) +" +p02726,s655458221,Accepted,"n,x,y = map(int,input().split()) +ans = {} +s = (y-x+1)//2 +s = x+s +for i in range(1,n): + for j in range(i+1,n+1): + if i <= s: + dist = min(j-i,abs(i-x)+abs(j-y)+1) + else: + dist = j-i + if dist in ans.keys(): + ans[dist] += 1 + else: + ans[dist] = 1 +for k in range(1,n): + if k in ans.keys(): + print(ans[k]) + else: + print(0)" +p02546,s733927056,Accepted,"s = input() +N = len(s) +if(s[N-1] == ""s""): + print(s + ""es"") +else: + print(s+ ""s"")" +p03556,s470322115,Wrong Answer,"def intSqrt(n): + x = 1 + while True: + x2 = (x + n // x) // 2 + if abs(x - x2) <= 1: + break + x = x2 + return x2 + +n = int(input()) +print(intSqrt(n)**2) +" +p02678,s780223507,Wrong Answer,"from collections import deque +N, M = map(int, input().split()) +AB = [list(map(int, input().split())) for i in range(M)] + +graph = [[] for i in range(N+1)] +for i,j in AB: + graph[i].append(j) + graph[j].append(i) + +r = [-1 for i in range(N+1)] +Q = deque([1]) + +while Q: + x = Q.pop() + for to in graph[x]: + if r[to] == -1: + r[to] = x + Q.append(to) + +print(""Yes"") +for i in r[2:]: + print(i)" +p02859,s552228042,Wrong Answer,"a = input(""半径"") +print(a)" +p02570,s864204490,Accepted,"#!python3 + +import sys +iim = lambda: map(int, sys.stdin.readline().rstrip().split()) + +def resolve(): + D, T, S = iim() + + print(""Yes"" if D/S <= T else ""No"") + +if __name__ == ""__main__"": + resolve() +" +p03087,s454372280,Accepted,"N,Q = map(int,input().split()) +S = input() +left=[] +right=[] +for _ in range(Q): + l,r = map(int,input().split()) + left.append(l) + right.append(r) + +a = [0]*N +for i in range(1,N): + if S[i] == ""C"" and S[i-1] == ""A"": + a[i] = a[i-1] + 1 + else: + a[i] = a[i-1] + +#print(a) +ans = [] +for j in range(Q): + ans.append(a[right[j]-1] - a[left[j]-1]) + +for k in ans: + print(k)" +p02951,s127706400,Accepted,"a, b, c = map(int, input().split()) + +if c-(a-b) < 0 : + print(0) +else: + print(c-(a-b))" +p02759,s608281573,Accepted,"import sys + +line = sys.stdin.readline().strip() +n = int(line) +print(n//2+n%2) + +" +p03219,s315551044,Wrong Answer,"x,y = map(int,input().split()) +sum = x + y/2 +print(sum)" +p02659,s046987064,Accepted,"def main(): + A, B = input().split() + A = int(A) + B1, B2 = map(int, B.split('.')) + B = B1 * 100 + B2 + ans = A * B // 100 + print(ans) + +if __name__ == '__main__': + main() +" +p03719,s826061167,Wrong Answer,"def func(a, b, c): + if (a <= c <= b): + return ""Yes"" + else: + return ""No"" + +s = input().split() +func(int(s[0]), int(s[1]), int(s[2]))" +p02613,s008194399,Accepted,"N = int(input()) +s = [input() for i in range(N)] +a = s.count(""AC"") +b = s.count(""WA"") +c = s.count(""TLE"") +d = s.count(""RE"") +print(""AC x {}"".format(a)) +print(""WA x {}"".format(b)) +print(""TLE x {}"".format(c)) +print(""RE x {}"".format(d))" +p02723,s359589228,Accepted,"S = input() + +print(""Yes"" if S[2] == S[3] and S[4] == S[5] else ""No"")" +p03657,s207688653,Accepted,"A,B=map(int,input().split()) +if A%3*B%3*(A+B)%3==0:print('Possible') +else:print('Impossible')" +p03250,s700870176,Wrong Answer,"nums = sorted(list(map(int, input().split()))) +print(int(str(nums[0]) + str(nums[1])) + nums[2])" +p02988,s155836730,Accepted,"n = int(input()) +p = list(map(int, input().split())) + +ans = 0 +for i in range(1, n-1): + M = max(p[i-1], p[i], p[i+1]) + m = min(p[i-1], p[i], p[i+1]) + if p[i] != M and p[i] != m: ans += 1 + +print(ans)" +p02912,s648930695,Accepted,"# -*- coding: utf-8 -*- +import numpy as np +from collections import deque +import heapq +import collections +import itertools +import bisect +mod = 10 ** 9 + 7 +N, M = list(map(int, input().split())) +A = list(map(int, input().split())) +A = list(np.array(A)*-1) +heap_tree = heapq.heapify(A) +for i in range(M): + max_value = heapq.heappop(A)*-1 + max_value = (max_value//2)*-1 + heapq.heappush(A, max_value) +ans = 0 +for a in A: + ans -= a +print(ans) +" +p03131,s716836764,Wrong Answer,"K,A,B=map(int,input().split()) +bis=1 +if K==1: + bis+=1 +elif A>=B-1 or K-A+1<0: + bis+=K +else: + if int((K-(A-1)))%2==0: + bis=int(A+(B-A)*(K-(A-1))/2) + else: + bis=A+(B-A)*int((K-(A-1))//2)+1 +print(bis)" +p03103,s553275677,Wrong Answer,"n,m = map(int,input().split()) +drink = dict() +cost = set() +ans = 0 +for i in range(n): + ab = [int(i) for i in input().split()] + cost.add(ab[0]) + if ab[0] in drink: + drink[ab[0]] += ab[1] + else: + drink[ab[0]] = ab[1] +#ここまで入力 +sorted(cost) +for i in cost: + if m <= drink[i]: + ans += m*i + break + else: + m -= drink[i] + ans += i * drink[i] + +print(ans)" +p02982,s868761444,Accepted,"import itertools + +n, d = map(int, input().split()) +x = [list(map(int, input().split())) for _ in range(n)] + +c = list(itertools.combinations(range(n), 2)) +ans = 0 +for a, b in c: + dist = 0 + for j in range(d): + dist += (x[a][j]-x[b][j])**2 + if dist**(1/2) % 1 == 0: + ans += 1 +print(ans)" +p02783,s637923972,Accepted,"a,b=input().split() +print(-(-int(a)//int(b)))" +p02860,s860189347,Accepted,"N,S=int(input()),input() +a,b='','' +if N%2==0: + for i in range(int(N/2)): + a = a+S[i] + b = S[len(S)-(i+1)]+b + print('Yes' if a==b else 'No') +else: + print('No')" +p02873,s304671512,Accepted,"# A - >< +S = input() +N = len(S)+1 +INF = 1000000 +ans = [0]*N +tmp = 0 +for i in range(N-1): + if S[i]=='<': + tmp += 1 + else: + tmp = 0 + ans[i+1] = tmp +tmp = 0 +for i in range(N-2,-1,-1): + if S[i]=='>': + tmp += 1 + else: + tmp = 0 + ans[i] = max(ans[i],tmp) +print(sum(ans))" +p03695,s343641028,Accepted,"N=int(input()) +a=list(map(int,input().split())) +con=set() +wild=0 + +for p in a: + if p<=399: + con.add(""灰"") + elif p<=799: + con.add(""茶"") + elif p<=1199: + con.add(""緑"") + elif p<=1599: + con.add(""水"") + elif p<=1999: + con.add(""青"") + elif p<=2399: + con.add(""黄"") + elif p<=2799: + con.add(""橙"") + elif p<=3199: + con.add(""赤"") + else: + wild +=1 + +mini=max(1,len(con)) +maxi=len(con)+wild +print(mini,maxi)" +p02594,s128534530,Wrong Answer,"from sys import stdin,stdout + +def main(): + line=stdin.readline() + parts=line.split() + a=int(parts[0]) + if a>=30: + stdout.write(""YES"") + else: + stdout.write(""NO"") +main()" +p03160,s569570696,Accepted,"n = int(input()) +h = list(map(int, input().split())) +dp = [0] * n +dp[1] = abs(h[0] - h[1]) +for i in range(2, n): + dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])) +print(dp[-1])" +p02720,s988231998,Accepted,"from collections import deque + +K = int(input()) +q = deque([i for i in range(1, 10)]) + +cnt = 0 +while cnt < K-1: + n = q.popleft() + d = int(str(n)[-1]) + cnt += 1 + for i in [d-1, d, d+1]: + if i < 0 or 10 <= i: + continue + q.append(10*n+i) +print(q.popleft()) +" +p02779,s584249406,Wrong Answer,"N = input() +A = input().split() + +print(A[0] in A[1:])" +p03069,s825069799,Accepted,"n=int(input()) +s=input() +dp=[0]*(n+1) + +for i in range(1,n+1): + if s[i-1]==""."": + cnt=0 + else: + cnt=1 + dp[i]=dp[i-1]+cnt +ans=n +for i in range(n+1): + ans=min(ans,dp[i]+(n-i)-(dp[n]-dp[i])) +print(ans)" +p03438,s275325939,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +x = sum(B)-sum(A) + +one = 0 +two = 0 + +for i in range(N): + if A[i] > B[i]: + one += A[i]-B[i] + if A[i] < B[i]: + two += (B[i]-A[i])//2 + +if one<=x and two<=x: + print(""Yes"") +else: + print(""No"")" +p02829,s282761549,Wrong Answer,"import sys +def input(): return sys.stdin.readline().rstrip() +def main(): + n=int(input()) + A=[int(_) for _ in input().split()] + cunt=0 + for a in A: + if a==cunt+1:cunt+=1 + if 1 in A: + if n==1 and A[0]==1:print(0) + else:print(n-cunt) + else: + print(-1) + + +if __name__=='__main__': + main()" +p02600,s095314411,Wrong Answer,"x=int(input()) +for i in range(7): + if 400+200*i <= x <= 599+200*i: + print(8-i)" +p03163,s319576175,Accepted,"import sys + +N , W = map(int, input().split()) + +WV = [list(map(int, sys.stdin.readline().split())) for i in range(N)] + +INF = 10**11+1 + +dp = [[0]*(1+W) for i in range(N+1)] + +for i in range(1, N+1): + for j in range(1, W+1): + if j-WV[i-1][0]>=0: + dp[i][j] = max(dp[i-1][j], dp[i-1][j-WV[i-1][0]]+WV[i-1][1]) + else: + dp[i][j] = dp[i-1][j] + +print(dp[N][W])" +p03721,s271344518,Accepted," +(n, k) = map(int, input().split()) +(a, b) = zip(*[map(int, input().split()) for _ in range(n)]) + +cnt_dict = {} +for i in range(n): + if a[i] not in cnt_dict.keys(): + cnt_dict[a[i]] = 0 + cnt_dict[a[i]] += b[i] + +length = 0 +for a_i in sorted(cnt_dict.keys()): + length += cnt_dict[a_i] + if length >= k: + ans = a_i + break + +print(ans) +" +p03328,s078185737,Wrong Answer,"def main(): + a,b = map(int, input().split()) + sum = 0 + + for height in range(1,999): + sum += height + if a < sum and sum < b: + print(sum-a) + break; + +if __name__ == ""__main__"": + main() +" +p02881,s940706366,Accepted,"N = int(input()) +k = [] +for i in range(1,10**6+1): + if N%i == 0: + k.append(i+(N//i)-2) +if len(k) == 0: + print(N-1) +else: + print(min(k)) +" +p03698,s520562955,Accepted,"s = list(input()) +if len(s) == len(set(s)): + print('yes') +else: + print('no')" +p03695,s385822825,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +rate=[0]*9 +over=0 + +for i in a: + for j in range(1,9): + if 400*(j-1) <= i < 400*j: + rate[j]=1 + break + elif i >= 3200: + over+=1 + break + +ansmin = rate.count(1) +ansmax = rate.count(1) +if ansmin == 0: + ansmin=1 + +if over > 0: + ansmax += over + +#print(rate,over) +print(ansmin, ansmax)" +p02641,s398347245,Accepted,"# coding: utf-8 + +############################ + +x,n = map(int,input().split()) + +if n==0: + print(x) + exit() + +z=101 +p_list = list(map(int,input().split())) +pp_list = [i for i in range(102)] + +for j in p_list: + pp_list.remove(j) + +for k in pp_list: + zettaiti = abs(x-k) + + if z > zettaiti: + z = zettaiti + ans = k + +print(ans)" +p03105,s736119249,Wrong Answer,"import math +A, B, C =map(int, input().split()) +if B / A >= C: + print(C) +else: + print(math.ceil(B/A))" +p04019,s631124837,Accepted,"s = input() + +ns = 0 +we = 0 + +if ""N"" in s and ""S"" in s: + ns = 1 +elif ""N"" not in s and ""S"" not in s: + ns = 1 +if ""W"" in s and ""E"" in s: + we = 1 +elif ""W"" not in s and ""E"" not in s: + we = 1 + +if ns == 1 and we == 1: + print(""Yes"") +else: + print(""No"")" +p03339,s209874599,Wrong Answer,"from itertools import accumulate + +def main(): + N = int(input()) + people = list(input()) + + wests = list(accumulate([0]+people, lambda total, x: total + (1 if x == ""W"" else 0)))[1:] + easts = list(accumulate([0]+people, lambda total, x: total + (1 if x == ""E"" else 0)))[1:] + + def linearsearch(): + easts_total = easts[-1] + for i in range(1, N): + yield wests[i-1] + easts_total - easts[i] + + print(min(linearsearch())) + +main()" +p02719,s549531213,Accepted,"N,K = list(map(int, input().split())) + +a = int(N/K) +b = N % K +c = abs(b-K) + + +print(min(b,c))" +p02760,s673861655,Wrong Answer,"import sys + +A = [[0] for _ in range(3)] +for i in range(3): + A[i] = list(map(int, input().split())) +N = int(input()) +B = [] +for i in range(N): + B.append(int(input())) + +for i in range(3): + if A[i] <= B or (A[0][i] in B and A[1][i] in B and A[2][i] in B): + print('Yes') + sys.exit() + +if (A[0][0] in B and A[1][1] in B + and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B): + print('Yes') + +print('No')" +p03262,s324743717,Accepted,"def gcd(a, b): + while b != 0: + a, b = b, a % b + return a + + +n, x = map(int, input().split()) +x_l = list(map(int, input().split())) +dist = [] +for i in range(n): + dist.append(abs(x - x_l[i])) + +res = dist[0] +for i in range(len(dist)): + res = gcd(res, dist[i]) +print(res) +" +p03817,s103628475,Accepted,"import math + +x = int(input()) +if 1 <= x%11 <= 6: + print(math.ceil(x/11)*2 - 1) +else: + print(math.ceil(x/11)*2)" +p03472,s529610373,Wrong Answer,"#!/usr/bin/env python3 +#%% for atcoder uniittest use +import sys +input= lambda: sys.stdin.readline().rstrip() +def pin(type=int):return map(type,input().split()) +def tupin(t=int):return tuple(pin(t)) +#%%code +def resolve(): + N,HP=pin() + weapon=[tupin() for _ in range(N)] + weapon.sort(key=lambda x:x[0]) + a=weapon[-1][0] + + ans=0 + for w in weapon: + if w[1]>a:HP-=w[1];ans+=1 + if HP>0: + ans+=(HP-1)//a+1 + print(ans) +#%%submit! +resolve()" +p02773,s422033262,Accepted,"import collections +N = int(input()) +S = {} +for i in range(N): + value = input() + if value not in S: + S[value] = 1 + else: + S[value] += 1 +S_largest = max(S.values()) +S_sorted = sorted(S.items(), key=lambda x:x[1], reverse=True) +ans = [] +for i in range(len(S_sorted)): + if S_sorted[i][1] == S_largest: + ans.append(S_sorted[i][0]) + else: + break +ans_sorted = sorted(ans) +for a in ans_sorted: + print(a) +" +p03862,s827842223,Wrong Answer,"N,x=map(int,input().split()) +a=[int(x) for x in input().split()] +cnt=0 +if a[0]>x: + cnt += a[0] - x + a[0]=x +for i in range(N-1): + if a[i]+a[i+1]: + cnt += a[i] + a[i+1] - x + a[i+1]=x-a[i] + +print(cnt) +" +p02947,s960244431,Accepted,"from collections import Counter +print(sum([i*(i-1)//2 for i in [*Counter([''.join(sorted(input())) for _ in range(int(input()))]).values()]]))" +p02761,s684268361,Accepted,"import sys +sys.setrecursionlimit(10 ** 7) +read = sys.stdin.buffer.read +inp = sys.stdin.buffer.readline +def inpS(): return inp().rstrip().decode() +readlines = sys.stdin.buffer.readlines + +def check(n): + x = str(n) + if len(x) != N: + return False + for s, c in SC: + if x[s-1] != str(c): + return False + return True + +N, M = map(int, inp().split()) +SC = [tuple(map(int, inp().split())) for _ in range(M)] + +for i in range(1001): + if check(i): + print(i) + exit() +print(-1) + " +p02631,s054937401,Wrong Answer,"n = int(input()) +aa = map(int,input().split()) +x = 0 +for a in aa: + x^=a +print("" "".join(str(x^a) for a in aa ))" +p02993,s122723848,Accepted,"a, b, c, d = input() +print(""Bad"" if a==b or b==c or c==d else ""Good"")" +p03803,s440151847,Wrong Answer,"A,B=map(int,input().split()) +a=A%13 +b=B%13 +if A>B: + print(""Alice"") +elif B>A: + print(""Bob"") +else: + print(""Draw"")" +p03455,s438588432,Wrong Answer,"a,b = input().split() +" +p02916,s978793415,Wrong Answer,"import sys +n = int(sys.stdin.readline()) +lia = list(map(int, sys.stdin.readline().split())) +lib = list(map(int, sys.stdin.readline().split())) +lic = list(map(int, sys.stdin.readline().split())) +s = sum(lib) +li = [] +i = 0 +while i < n-1: + if lia[i+1] - lia[i] == 1: + li.append(i) + i += 1 +for i in li: + s += lic[i] +print(s) +" +p03696,s634684891,Accepted,"import sys + +sys.setrecursionlimit(10 ** 7) +f_inf = float('inf') +mod = 10 ** 9 + 7 + + +def resolve(): + n = int(input()) + S = input() + + right = 0 + left = 0 + for i in range(n): + if S[i] == ""("": + left += 1 + else: + if left: + left -= 1 + else: + right += 1 + res = ""("" * right + S + "")"" * left + print(res) + + +if __name__ == '__main__': + resolve() +" +p03774,s913656013,Accepted,"n,m = map(int,input().split()) +a = [tuple(map(int,input().split())) for i in range(n)] +b = [tuple(map(int,input().split())) for i in range(m)] +inf = float(""inf"") +for ai,bi in a: + d,num = inf,0 + for i in range(m): + ci,di = b[i] + x = abs(ai-ci)+abs(bi-di) + if d > x: + d = x + num = i+1 + print(num)" +p03711,s541705629,Accepted,"x,y =map(int,input().split()) +a = [[1,3,5,7,8,10,12],[4,6,9,11],[2]] +flag = False +for i in a: + if x in i: + if y in i: + flag =True + break +print('Yes' if flag else 'No')" +p02802,s504777036,Accepted,"n,m = map(int,input().split()) +acli = [0]*n +wali = [0]*n +acsi = 0 +wasi = 0 +for i in range(m): + p,s = map(str,input().split()) + if acli[int(p)-1] == 0: + if s == 'AC': + acli[int(p)-1] = 1 + acsi += 1 + elif s == 'WA': + wali[int(p)-1] += 1 +for j in range(n): + if acli[j] == 1 and wali[j] != 0: + wasi += wali[j] +print(acsi,wasi)" +p02862,s646936021,Accepted,"X, Y = map(int,input().split()) + +if (X+Y)%3 != 0 or X+Y == 0: + print(0) + exit() + +n = int((2*Y-X)/3) +m = int((2*X-Y)/3) + +if n < 0 or m < 0: + print(0) + exit() + +mod = 10**9+7 + + +def comb(n, r, mod): + x=y=1 + for i in range(r): + x *= n; y *= r + x %= mod; y %= mod + n -= 1; r -= 1 + return x * pow(y, mod - 2, mod) % mod + +print(comb(n+m, n, mod)) +" +p02678,s269850039,Wrong Answer,"n,m=map(int,input().split()) +l=[[]]*n +for i in range(m): + a,b=map(int,input().split()) + l[a-1].append(b) + l[b-1].append(a) +ans=[-1]*n +x=[1] +y=[] +count=1 +while count0: + for i in x: + for j in l[i-1]: + if ans[j-1]==-1: + ans[j-1]=i + y.append(j) + count+=1 + x=y + y=[] +if count 10**18: + flg = 1 + break + +# A_len = len(str(A_multi)) +# if A_len > 19: +# flg = 1 + +# if A_len == 19: +# if A_multi > 10**18: +# flg = 1 + +if flg == 1: + print(""-1"") +else: + print(A_multi) +" +p02630,s232057901,Accepted,"n=int(input()) +a=list(map(int,input().split())) +b=[0] +b*=10**5+1 +for i in a: + b[i]+=1 +ans=sum(a) +q=int(input()) +for i in range(q): + bi,ci=map(int,input().split()) + d=b[bi] + b[ci]+=d + b[bi]=0 + ans=ans+d*(ci-bi) + print(ans)" +p02584,s337344331,Accepted,"x, k, d = map(int,input().split()) +max_length = k * d +xx = abs(x) +answer = 0 +if xx >= max_length: + answer = xx - max_length +else: + if (k - xx // d) % 2 == 0: + answer = xx - xx // d * d + else: + answer = xx - (xx // d + 1) * d +print(abs(answer))" +p03565,s928025527,Wrong Answer,"import sys + +s = input() +t = input() + +for i in range(len(s)-len(t)+1): + if i == 0: + sub = s[-i-len(t):] + else: + sub = s[-i-len(t):-i] + for j in range(len(t)): + if sub[j]!=t[j] and sub[j]!=""?"": + break + else: + if i == 0: + s = s[:-i-len(t)]+t + else: + s = s[:-i-len(t)]+t+s[-i:] + s = s.replace(""?"",""a"") + print(s) + sys.exit() + break + +print(""UNRESTORABLE"")" +p03035,s720312546,Accepted,"N, M = map(int, input().split()) + +if N <= 5: + print(0) +elif 6 <= N <= 12: + print(M // 2) +else: + print(M) +" +p02743,s183481171,Accepted,"a, b, c = map(int, input().split()) +s, t = a + b, a * b +print(""No"" if c - s < 0 else ""Yes"" if (c - s) ** 2 - 4 * t > 0 else ""No"")" +p03557,s654311980,Accepted,"from bisect import bisect_left +from bisect import bisect_right + +N = int(input()) + +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) + +A.sort() +B.sort() +C.sort() +ans = 0 +for b in B: + a_left = min(len(A), bisect_left(A, b)) + c_right = min(len(C), bisect_right(C, b)) + ans += (a_left) * (len(C) - c_right) +print(ans) +" +p03472,s256165896,Accepted,"import math +import copy +N, H = map(int, input().split()) +a_max = [list(map(int, input().split())) for _ in range(N)] +b_max = copy.deepcopy(a_max) +b_max.sort(key=lambda x:-x[1]) +a_max.sort(key=lambda x:-x[0]) +damage = 0 +cnt_damage = 0 +for i in range(N): + if damage >= H: + print(cnt_damage) + exit() + + if b_max[i][1] >= a_max[0][0]: + damage += b_max[i][1] + cnt_damage += 1 + else: + break + +cnt_damage += math.ceil((H-damage)/a_max[0][0]) + +print(cnt_damage)" +p03408,s740636537,Wrong Answer,"n = int(input()) +s = [input() for i in range(n)] +m = int(input()) +t = [input() for i in range(m)] + +dicts = {} +small = 0 +for i in s: + if i not in dicts.values(): + dicts[i] = 1 + else: + dicts[i] += 1 + +for i in t: + if i not in dicts.values(): + dicts[i] = -1 + else: + dicts[i] -= 1 + +tmp = max(dicts.values()) +print(max(tmp, small)) +" +p03339,s435357134,Wrong Answer,"N = int(input()) +S = str(input()) + +WtoE=0 +EtoW=S[1:N+1].count('E') +min_ans = WtoE + EtoW + +for i in range(1, N+1): + if S[i-1] == 'W': + WtoE += 1 + if S[i-1] == 'E': + EtoW -= 1 + ans = WtoE + EtoW + + if min_ans > ans: + min_ans = ans + +print(min_ans)" +p03041,s050192534,Accepted,"N, K = map(int, input().split()) +S = input() + +ans = """" +for i in range(N): + if i == K - 1: + ans += S[i].lower() + else: + ans += S[i] +print(ans)" +p03435,s774563357,Accepted,"L = [list(map(int, input().split())) for _ in range(3)] +T = sum([sum(i) for i in L]) +print('Yes' if L[0][0] + L[1][1] + L[2][2] == (T / 3) else 'No')" +p02779,s646530884,Accepted,"# -*- coding: utf-8 -*- +n = int(input()) +a = [int(i) for i in input().split()] + +if len(set(a)) == n: + print(""YES"") +else: + print(""NO"") +" +p03971,s263818972,Accepted,"N, A, B = map(int, input().split()) +S = input() +cnt=cnt2=0 +for s in S: + if s=='c': + print('No') + elif s=='a' and cnt < A+B: + print('Yes') + cnt+=1 + elif s=='b' and cnt < A+B and cnt2 < B: + print('Yes') + cnt+=1 + cnt2+=1 + else: + print('No')" +p02860,s312866177,Accepted,"N = input() +N = int(N) +S = input() + +center = int(N / 2) +if S[:center] == S[center:]: + print('Yes') +else: + print('No')" +p02848,s627578057,Wrong Answer,"N = int(input()) +S = input() +for i in range(len(S)): + moji = S[i] + S = S.replace(moji, chr(ord(moji)+N)) +print(S)" +p02814,s357259042,Wrong Answer,"n,m=map(int,input().split()) +a=list(map(int,input().split())) +import math +print(math.floor(m/max(a)-0.5)+1) +" +p03803,s918565792,Accepted,"# AtCoder Beginner Contest 054 +# A - One Card Poker +A, B = map(int, input().split()) +if A == 1: + A = 14 +if B == 1: + B = 14 +if A > B: + print('Alice') +elif A < B: + print('Bob') +else: + print('Draw')" +p03815,s557295805,Wrong Answer,"n = int(input()) +if n%11 == 0: + print((n//11)*2) +elif n%11 < 6: + print((n//11)*2+1) +else: + print((n//11)*2+2)" +p04031,s414975232,Accepted,"n=int(input()) +A=list(map(int,input().split())) +ans = [0]*201 +for a in A: + for i in range(-100,101): + ans[i+100] += (a-i)**2 +print(min(ans))" +p03379,s196597039,Accepted,"n=int(input()) +x=list(map(int,input().split())) +lr,rr=sorted(x)[n//2-1:n//2+1] +print('\n'.join([str(lr) if lr abs(x - b)])" +p02911,s808925491,Accepted,"n,k,q = map(int,input().split()) +player = [0] * n +for i in range(q): + player[int(input())-1] += 1 +result = ['Yes' if k - q + player[i] > 0 else 'No' for i in range(n)] +for i in result: + print(i) +" +p02729,s548305963,Accepted,"import math +n,m=map(int,input().split()) +print( math.factorial(n+m) // (math.factorial(n+m-2) * math.factorial(2))-n*m)" +p03038,s606110152,Wrong Answer,"import heapq + +N, M = list(map(int,input().split())) +A = list(map(int,input().split())) +B = sorted([list(map(int,input().split())) for i in range(M)], key = lambda x: x[1]) + +heapq.heapify(A) +cnt = 0 +for i in range(M): + for _ in range(B[i][0]): heapq.heappush(A, max(heapq.heappop(A), B[i][1])) + cnt += B[i][0] + if cnt >= N: break +print(sum(A))" +p02677,s465568143,Accepted,"from math import pi, cos, sqrt +A, B, H, M = map(int, input().split()) +w_a = 2*pi/(12*60.0) +w_b = 2*pi/(60.0) +theta_a = w_a*(H*60+M) +theta_b = w_b*M +ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b)) +print(""{:.20f}"".format(ans))" +p02768,s432042039,Accepted,"from functools import reduce + +n, a, b = map(int, input().split()) +mod = 10 ** 9 + 7 + + +def cmb(r): + numerator = reduce(lambda x, y: x * y % mod, range(n, n - r, -1)) + denominator = reduce(lambda x, y: x * y % mod, range(1, r + 1)) + return numerator * pow(denominator, mod - 2, mod) % mod + + +ans = pow(2, n, mod) - 1 - cmb(a) - cmb(b) +print(ans % mod) +" +p03146,s160936792,Accepted,"n = int(input()) +s = {n} +flg = 1 +i = 1 +while flg: + if n % 2 == 0: + n //= 2 + else: + n = 3*n + 1 + if n in s: + print(i+1) + flg = 0 + else: + s.add(n) + i += 1" +p02747,s687697183,Accepted,"S = input() + +for i in range(0,len(S),2): + if not S[i:i+2] == 'hi': + print('No') + exit(0) + +print('Yes')" +p03544,s200681218,Wrong Answer,"t=[1,0] +for i in range(2,90): + t.append(t[i-1]+t[i-2]) +print(t[int(input())])" +p03438,s465421358,Accepted,"n = int(input()) +a = list(map(int, input().split())) +b = list(map(int, input().split())) + +cnt = sum(b) - sum(a) +ans = 0 +for ai, bi in zip(a, b): + ans += max(0, (bi - ai + 1) // 2) +print('Yes' if ans <= cnt else 'No') +" +p02640,s066974103,Wrong Answer,"import sys + +x, y = map(int, input().split()) + +#鶴a匹、亀x-a匹とする +for a in range(1, x + 1): + if y == 4 * x - 2 * a: + print('YES') + sys.exit() + +print('NO')" +p02817,s713604562,Wrong Answer,"S,T = input().split() + +print(T,S) +" +p03160,s522802463,Accepted,"def input_li(): + return list(map(int, input().split())) + +def input_int(): + return int(input()) + +N = input_int() +h_li = input_li() +dp = [0] * N +dp[0] = 0 +dp[1] = abs(h_li[1] - h_li[0]) +for i in range(2, N): + dp[i] = min( + dp[i - 1] + abs(h_li[i] - h_li[i - 1]), + dp[i - 2] + abs(h_li[i] - h_li[i - 2]) + ) +print(dp[-1]) +" +p03351,s299229214,Accepted,"a,b,c,d = map(int,input().split()) +if abs(a-c) <= d: + print(""Yes"") +elif abs(a-b)<= d and abs(b-c)<=d: + print(""Yes"") +else: + print(""No"")" +p03494,s287298705,Accepted,"N = int(input()) +A = list(map(int,input().split())) + +cnt = 0 +while True: + check = sum([n % 2 for n in A]) + if check == 0: + A = [n/2 for n in A] + cnt += 1 + else: + break + +print(cnt)" +p03345,s433207231,Accepted,"a,b,c,k=map(int,input().split()) +if k%2==0: + ans=a-b +else: + ans=b-a +if ans<=10**18: + print(ans) +else: + print(""Unfair"") +" +p03943,s403538282,Accepted,"a = list(map(int,input().split())) +a.sort() + +if sum(a[:2]) == a[2]: + print('Yes') +else: + print('No') +" +p03545,s194162209,Wrong Answer,"n_str = list(input()) +n = [int(i) for i in n_str] +l = len(n) +for i in range(2 ** l): + sum = 0 + op_list = [] + for j in range(l): + if (i >> j) & 1: + sum += n[j] + op_list.append('+') + else: + sum -= n[j] + op_list.append('-') + if sum == 7: + print(n_str[0]+op_list[0]+n_str[1]+op_list[1]+n_str[2]+op_list[2]+n_str[3]+'=7') + exit()" +p03472,s932403732,Accepted,"import sys +readline = sys.stdin.readline + +N,H = map(int,readline().split()) +maxA = 0 +B = [0] * N +for i in range(N): + a,b = map(int,readline().split()) + B[i] = b + if maxA < a: + maxA = a + +usefulB = [] +for i in range(N): + if B[i] > maxA: + usefulB += [B[i]] + +usefulB = sorted(usefulB,reverse = True) + +cnt = 0 +for b in usefulB: + H -= b + cnt += 1 + if H <= 0: + print(cnt) + break +else: + cnt += (H + maxA - 1) // maxA + print(cnt)" +p03835,s129362357,Wrong Answer,"K, S = map(int, input().split()) +ans = 0 +for x in range(K+1): + for y in range(K+1): + z = K - x - y + if 0 <= z <= K: + ans += 1 +print(ans) +" +p03637,s550162648,Wrong Answer,"N = int(input()) +A = [int(x) for x in input().split()] + +m1 = 0 +m2 = 0 +m4 = 0 + +for a in A: + if a%4==0: + m4 += 1 + elif a%2==0: + m2 += 1 + else: + m1 += 1 + +m1 = m1 + m2%2 +if 2*m4>=m1: + print('Yes') +else: + print('No')" +p02933,s005106499,Accepted,"a = int(input()) +s = input() +print(s if a>=3200 else 'red')" +p03767,s401341374,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +A.sort() +print(sum(A[N:2*N]))" +p02989,s220318719,Wrong Answer,"N = int(input()) +D = list(map(int, input().split())) + +ans = 0 +for i in range(min(D)+1, max(D)): + RC = [r for r in D if r >= i] + BC = [b for b in D if b < i] + if len(RC) == len(BC): + ans += 1 + +print(ans)" +p02658,s815914993,Accepted,"import sys + +sys.setrecursionlimit(10**6) +readline = sys.stdin.readline +#read = sys.stdin.buffer.read + +def main(): + N = int(input()) + A = list(map(int, readline().split())) + ans = 1 + if 0 in set(A): + print(0) + return + for a in A: + ans *= a + if ans > pow(10,18): + print(-1) + return + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03449,s867322985,Accepted,"N = int(input()) +A = [list(map(int, input().split())) for _ in range(2)] +res = 0 +for i in range(N): + t = 0 + for j in range(i + 1): + t += A[0][j] + for j in range(i, N): + t += A[1][j] + res = max(res, t) +print(res) +" +p02718,s801273564,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +A.sort(reverse=True) +bound = (1 / (4*M))*sum(A) + +for i in range(M): + if A[i] < bound: + print(""No"") + break +else: + print(""Yes"") + +" +p04031,s529500623,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +ans=1e5 +for i in range(-100,101): + now=0 + for k in a: + now+=(i-k)*(i-k) + ans=min(ans,now) +print(ans)" +p03720,s978115211,Accepted,"if __name__ == '__main__': + a,b = map(int,input().split()) + + list = [0]*a + + for i in range(b): + n,m=map(int, input().split()) + list[n-1]+=1 + list[m-1]+=1 + for i in list: + print(i)" +p03000,s192334612,Accepted,"n, x = map(int, input().split()) +L = list(map(int, input().split())) + +ans = 1 +d = 0 +for l in L: + d = d + l + if d <= x: + ans += 1 + else: + break + +print(ans)" +p02629,s784760589,Accepted,"def num2alpha(num): + if num<=26: + return chr(64+num) + elif num%26==0: + return num2alpha(num//26-1)+chr(90) + else: + return num2alpha(num//26)+chr(64+num%26) + +N = int(input()) +ans = (num2alpha(N)).lower() +print(ans)" +p02911,s114629397,Accepted,"n,k,q=map(int,input().split()) +a=[] +for _ in range(q): + a.append(int(input())) + +points = [k]*(n+1) +plus = [0]*(n+1) +for i in range(q): + plus[a[i]] += 1 + +for i in range(1,n+1): + points[i] = points[i] - q + plus[i] + if points[i] >= 1: + print('Yes') + else: + print('No') +" +p02658,s527476691,Accepted,"def cal(): + n = int(input()) + lst = list(map(int,input().split())) + if 0 in lst: + return 0 + else: + prod = 1 + for a in lst: + prod *= a + if prod > 1000000000000000000: + return -1 + return prod +print(cal()) +" +p03778,s508316880,Accepted,"W, a, b = map(int, input().split()) +if a <= b <= a + W or a <= b + W <= a + W: + print(0) +else: + print(b - (a + W) if b > a + W else a - (b + W))" +p03778,s469314780,Wrong Answer,"w, a, b = map(int, input().split()) +if a + w < b: + print(b-a-w) +elif a <= b and b <= a+w: + print(0) +elif b <= a+w and a <= b: + print(0) +elif b + w < a: + print(a-b-w)" +p03095,s992246348,Accepted,"from collections import Counter +MOD = 10**9 + 7 +N = int(input()) +S = input() +count_si = Counter(S) +ans = 1 +for v in count_si.values(): + ans = (ans * (v+1)) % MOD + +print((ans-1)%MOD)" +p02711,s522900345,Accepted,"N = input() +for n in N: + if n == '7': + print('Yes') + exit(0) +print('No')" +p02615,s577359390,Accepted,"N = int(input()) +A = list(map(int, input().split())) +A.sort(reverse=True) +S = 0 +for i in range(N-1): + S += A[(i+1)//2] +print(S) +" +p03126,s800610871,Accepted,"n,m=map(int,input().split()) +f=[0]*(m+1) +count=0 +for i in range(n): + a=list(map(int,input().split())) + k=a[0] + a=a[1:] + for i in range(k): + f[a[i]]+=1 + +for i in range(1,m+1): + if f[i]==n: + count+=1 + +print(count)" +p03061,s451765009,Accepted,"import sys +input = sys.stdin.readline +from math import gcd + +N = int(input()) +a = list(map(int, input().split())) +l = [0] + +for ai in a: + l.append(gcd(l[-1], ai)) + +r = [0] + +for ai in a[::-1]: + r.append(gcd(r[-1], ai)) + +ans = 0 + +for i in range(N): + ans = max(ans, gcd(l[i], r[N-1-i])) + +print(ans)" +p02860,s587351769,Accepted,"N = int(input()) +S = input() +N = int(N//2) +if S[:N] == S[N:]: + print('Yes') +else: + print('No')" +p03067,s165466555,Accepted,"a, b, c = map(int, input().split()) +print(""Yes"" if a <= c <= b or b <= c <= a else ""No"")" +p03261,s952745771,Wrong Answer,"import sys +n = int(input()) +w = input() +words=[] + +words.append(w) + +for i in range(1,n): + w = input() + words.append(w) + if w not in words: + if words[i-1][-1]==sords[i][0]: + continue + else: + print(""No"") + sys.exit() + else: + print(""No"") + sys.exit() +print(""Yes"")" +p02818,s847517493,Accepted,"a, b, k = map(int, input().split()) +if a >= 1 and a <= k: + k -= a + a = 0 + +elif a >= 1 and a > k: + a -= k + k -= a + +if b >= 1 and k > 0 and b <= k: + k -= b + b = 0 +elif b >= 1 and k > 0 and b > k: + b -= k + k -= b + + +print(a, b)" +p03380,s569792132,Accepted,"#!/usr/bin/env python3 + + +def solve(n,a): + a = list(sorted(a,reverse=True)) + first = a[0] + b = a[1:] + delta = [abs(x-first//2) for x in b] + second = b[delta.index(min(delta))] + return first,second + +def main(): + N = int(input()) + a = list(map(int,input().split())) + print(*solve(N,a)) + +if __name__ == '__main__': + main()" +p02912,s693704814,Accepted,"import heapq +n,m=map(int,input().split()) +a=list(map(int,input().split())) + +for i in range(n): + a[i]*=-1 + +heapq.heapify(a) +for _ in range(m): + x=heapq.heappop(a)*(-1) + x=x//2 + heapq.heappush(a,-x) + +print(sum(a)*(-1))" +p03136,s880663719,Accepted,"n=input() +l=list(map(int,input().split())) +print(""Yes"" if max(l)kyori: + goal=j+1 + ans.append(goal) +for i in range(len(ans)): + print(ans[i])" +p03037,s612665260,Wrong Answer,"n, m = map(int, input().split()) +l_r = [ list(map(int, input().split())) for _ in range(m) ] + +ans = 0 +l_ans = 0 +r_ans = float('inf') +for l, r in l_r: + l_ans = max(l_ans, l) + r_ans = min(r_ans, r) +print(r_ans-l_ans+1) " +p03720,s886990777,Accepted,"n,m=map(int,input().split()) +c=[0]*n +for _ in range(m): + a,b=[int(j) for j in input().split()] + c[a-1]+=1 + c[b-1]+=1 +for i in c: + print(i)" +p02911,s906795827,Accepted,"import sys +from io import StringIO +import unittest + +def yn(b): + print(""Yes"" if b==1 else ""No"") + return + +def resolve(): + readline=sys.stdin.readline + + n,k,q=map(int, readline().rstrip().split()) + score=[k-q]*n + for i in range(q): + x=int(readline())-1 + score[x]+=1 + + for i in range(n): + if score[i]>0: + print(""Yes"") + else: + print(""No"") + + return + +if 'doTest' not in globals(): + resolve() + sys.exit()" +p02899,s460203908,Wrong Answer,"N = int(input()) +S = list(map(int,input().split())) +m = [0 for _ in range(N)] +for i in range(N): + m[S[i]-1] = i+1 +print(m) +" +p03243,s107762825,Wrong Answer,l=[x for x in input()];print(max(l)*3) +p02693,s717491486,Wrong Answer,"import sys +input = sys.stdin.readline + + +def readstr(): + return input().strip() + + +def readint(): + return int(input()) + + +def readnums(): + return map(int, input().split()) + + +def readstrs(): + return input().split() + + +K = readint() +A, B = readnums() + +if B - A < K and A % K < B % K: + print('NG') +else: + print('OK') +" +p02623,s375272098,Accepted,"import numpy as np +import bisect +n,m,k=map(int,input().split()) +a=list(map(int, input().split())) +b=list(map(int, input().split())) +A=np.cumsum(np.array([0]+a)) +B=np.cumsum(np.array(b)) +ans=0 +for i in range(n+1): + if A[i]>k: + break + t=k-A[i] + tmp=bisect.bisect_right(B,t) + ans=max(ans, i+tmp) +print(ans)" +p03673,s448426575,Wrong Answer,"N = int(input()) +Ai = input().split() +b = """" + +for n, A in enumerate(Ai): + if n%2 == 0: + b = A + b + else: + b = b + A +if N%2 == 0: b = b[::-1] +print(*[bb for bb in b], sep="" "") +" +p02628,s418903833,Accepted,"n,k,*p = map(int, open(0).read().split()) +p.sort() +print(sum(p[:k])) + " +p03767,s235620925,Accepted,"n=int(input()) +a=sorted(list(map(int,input().split())),reverse=True) +print(sum(a[1:2*n:2]))" +p02777,s772623752,Accepted,"s, t = input().split() +a, b = map(int, input().split()) +u = input() +if u == s: + print(a-1, b) +elif u == t: + print(a, b-1)" +p03210,s066366295,Wrong Answer,"S = int(input()) +if S == 7 or S == 5 or S == 3: + print(""Yes"") +else: + print(""No"")" +p02939,s187413794,Wrong Answer,"# A - Dividing a String +def count_substrings(first_substring): + + arr = [first_substring] + i = len(first_substring) + + while i < len(S): + s = S[i] + + if s == arr[-1]: + if i + 1 < len(S): + i += 1 + s += S[i] + else: + arr[-1] += s + break + + arr.append(s) + i += 1 + + ans = len(arr) + + if arr[-1] == arr[-2]: + ans -= 1 + + return ans + + +S = input() + +ans1 = count_substrings(S[:1]) +ans2 = count_substrings(S[:2]) + +print(max(ans1, ans2))" +p03719,s863259847,Wrong Answer,"a,b,c = map(int,input().split()) +print('Yes' if a<=b<=c else 'No') +" +p03107,s057875836,Wrong Answer,"s = input() +#11011010001011 +c = max(s.count(""1"") - s.count(""0""),s.count(""1"") - s.count(""0"")) + +if len(s) == 1: + print(0) +else: + print(len(s)-c) + + +" +p02831,s734120503,Accepted," + +def gcd(a, b): + if b == 0: + return a + return gcd(b, a % b) + + +def lcm(a, b): + return a * b // gcd(a, b) + + +def submit(): + a, b = map(int, input().split()) + print(lcm(a, b)) + + +if __name__ == ""__main__"": + submit()" +p03127,s482010769,Accepted,"from functools import reduce +from fractions import gcd +n = int(input()) +a = list(map(int,input().split())) +print(reduce(gcd,a)) +" +p03759,s789511403,Wrong Answer,"a,b,c=map(int,input().split()) +if abs(b-a)==abs(c-b): + print('YES') +else: + print('NO') +" +p02879,s690651079,Wrong Answer,"a,b=map(int,input().split()) +if a<=9 or b<=9: + print(a*b) +else: + print(-1)" +p03293,s227596214,Accepted,"S =input() +T =input() +#print(S) +s = len(S)-1 +S = list(S) + +#print(S) +flag = 0 +for i in range(len(S)): + h = [S[0]] + S.remove(S[0]) + S = S + h + str_ = ''.join(S) + #print(str_) + if str_ == T: + flag = 1 + break + #print(S) + +if flag == 1: + print(""Yes"") +else : + print(""No"")" +p04043,s352307190,Wrong Answer,"a,b,c = map(int,input().split())#標準入力を行う +if (a == 5 or a== 7): + if(b == 5 or b == 7): + if(c == 5 or c == 7): + if(a + b + c == 17): + print(""YES"") +print(""NO"") +" +p03814,s865288015,Accepted,"s = input() +temp = s.rindex('Z') - s.index('A') + 1 +print(temp)" +p02866,s482605270,Wrong Answer,"N=int(input()) +import collections +l=list(map(int,input().split())) +cnt=collections.Counter(l) +if cnt[0] > 1 or l[0] != 0: + print(0) + exit() +ans=1 +mod=998244353 +for i in range(1,max(cnt)): + ans*=pow(i,cnt[i],mod) + ans%=mod +print(ans)" +p02723,s943239132,Wrong Answer,"S=input() +if (S[2] == S[3])and(S[2] == S[3]) : + print('Yes') +else: + print('No') +" +p02601,s324783964,Accepted,"a,b,c=map(int,input().split()) +k=int(input()) +while k>0: + if a0: + if b= 0 and s == ""WA"": + count[int(p) - 1] += 1 + elif count[int(p)-1] >= 0 and s == ""AC"": + ans += count[int(p)-1] + count[int(p)-1] = -1 + ok += 1 +print(ok, ans)" +p03264,s959626059,Accepted,"k=int(input()) +if k%2==0: + print((k//2)**2) +else: + print((k//2)*(k//2+1))" +p04012,s417826565,Wrong Answer,"w=sorted(list(input())) +temp=0 +ans=""Yes"" +for i in range(len(w)): + if i>0 and w[i]!=w[i-1]: + if temp%2==1: + ans=""No"" + break + temp=0 + temp+=1 +print(ans) +#print([[""NA"",""YYMM""],[""MMYY"",""AMBIGUOUS""]][cMMYY][cYYMM])" +p02578,s226508433,Accepted,"n=int(input()) +a=list(map(int,input().split())) +mx=0 +s=0 +for i in a: + if mxx: + count+=a[i]-(x-a[i-1]) + if x"" else 0 + ans+=( max(f,g)-min(f,g)+d*(d+1)//2-g ) + f=d+1 if k==""<"" else 0 +print(ans) " +p02729,s007058100,Wrong Answer,"N,M=map(int,input().split()) + +print('{}'.format((N*(N-1)/2+(M*(M-1))/2))) +" +p03632,s971620743,Wrong Answer,"a, b, c, d = map(int, input().split()) + +start = max(a, c) +finish = min(b, d) + +print(start - finish)" +p02947,s576607460,Wrong Answer,"import math +import collections +n = int(input()) +ans = 0 +s = collections.Counter([''.join(sorted(list(input()))) for x in range(n)]) + +for v in s.values(): + if 1 < v: + ans += math.factorial(v) // math.factorial(2) +print(ans)" +p02783,s161929063,Accepted,"H, A = map(int, input().split()) + +i = 0 + +while H > 0: + H -= A + i += 1 + +print(i)" +p02766,s792866757,Accepted,"n,k = map(int,input().split()) +i = 0 +while n > 0: + n = n//k + i += 1 +print(i) +" +p03854,s848619344,Accepted,"s=input() +ans=s.replace(""eraser"", """").replace(""erase"", """").replace(""dreamer"", """").replace(""dream"", """") +print(""YES"" if not ans else ""NO"") +" +p03137,s527765816,Wrong Answer,"N, M = map(int, input().split()) +X = list(map(int, input().split())) +X.sort() +dif = [] + +for i in range(1, M): + dif.append(abs(X[i] - X[i-1])) + +dif.sort() +difLen = len(dif) +# M - N = (M-1) - (N-1) +e = M - N +ans = sum(dif[0:e]) + +print(ans)" +p03067,s379326856,Wrong Answer,"a, b, c = sorted(map(int, input().split())) + +print('Yes' if a <= c and c <= b else ""No"")" +p03494,s210035644,Accepted,"n = int(input()) +arr = list(map(int, input().split())) +count = 0 +while all(a % 2 == 0 for a in arr): + arr = [i / 2 for i in arr] + count += 1 + +print(count)" +p02693,s375299792,Accepted,"k = int(input()) +a, b = map(int, input().split()) + +for x in range(a, b+1): + if x % k == 0: + print('OK') + break +else: + print('NG') +" +p02888,s674919491,Wrong Answer,"N = int(input()) +L = list(map(int,input().split())) +L.sort() +cnt = 0 +for i in range(N-2): + for j in range(i+1,N-1): + h_min = j + h_max = N + while h_max - h_min != 1: + h_mid = (h_max + h_min) // 2 + if L[i] + L[j] > L[h_mid]: + h_min = h_mid + else: + h_max = h_mid + cnt += h_mid - j +print(cnt)" +p02882,s570701062,Accepted,"import numpy as np +a,b,x = map(int,input().split()) +water = x/a +bottle = a*b +if water >= bottle * 0.5: + margin = bottle - water + tate = margin * 2 / a + ans = np.degrees(np.arctan2(tate, a)) +else: + height = 2 * water / b + beta = np.degrees(np.arctan2(height, b)) + ans = 2*(45 - beta/2) +print(ans) +" +p02659,s116366626,Accepted,"A, B = input().split() +B1, B2 = B.split('.') +ans = int(A) * (int(B1) * 100 + int(B2)) +print(ans // 100) +" +p02795,s458479031,Wrong Answer,"H = int(input()) +W = int(input()) +N = int(input()) + +if H >= W: + if N%H == 0: + count = N/H + else: + count = int(N/H) + 1 +else: + if N%H == 0: + count = N/W + else: + count = int(N/W) + 1 +print(int(count)) + +" +p02627,s077425165,Accepted,"a = input() +if a in ""abcdefghijklmnopqrstuvwxyz"": + print(""a"") +else: + print(""A"")" +p02723,s811850148,Wrong Answer,"S = input() +list_S = list(S) +if list_S[2] == list_S[3] or list_S[4] == list_S[5]: + print(""Yes"") +else: + print(""No"")" +p02730,s828964087,Accepted,"import sys +input = sys.stdin.readline + +s = input().replace(""\n"","""") + +reverse_s = s[::-1] + +s1len = int((len(s)/2)) + +s1 = s[:s1len] +reverse_s1 = s1[::-1] +# print(s1) + +s2len = int((len(s)/2) + 1) +s2 = s[s2len:] +reverse_s2 = s2[::-1] +# print(s2) + + +if (s == reverse_s) and (s1 == reverse_s1) and (s2 == reverse_s2): + print(""Yes"") +else: + print(""No"")" +p02708,s424671408,Accepted,"import numpy as np + +n, k = map(int, input().split()) + +a = np.arange(n+1, dtype='int') + +b = np.cumsum(a) + +s = 0 + +for i in range(k, n+1): + s += (b[n] - b[n-i]) - b[i-1] + 1 + s = s % 1000000007 + +s += 1 +s = s % 1000000007 +print(s) +" +p02972,s075555081,Wrong Answer,"n = int(input()) +a = [int(i) for i in input().split()] + +ans = [0] * n +for i in range(n, 0, -1): + if sum(ans[i - 1:n + 1:i]) % 2 != a[i - 1]: + ans[i - 1] = 1 + +print(*ans)" +p03797,s890775986,Accepted,"# -*- coding: utf-8 -*- +"""""" +Created on Wed Sep 30 00:56:12 2020 + +@author: liang +"""""" + +N, M = map(int, input().split()) + +if N*2 >= M: + print(M//2) +else: + print( N + (M-2*N)//4)" +p03377,s285462751,Accepted,"a,b,x = map(int,input().split()) +print(""YES"" if a + b >= x and a <= x else ""NO"")" +p03696,s276920158,Accepted,"import sys + +readline = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + + +def main(): + n = int(readline()) + s = input() + + l = 0 + r = 0 + + for char in s: + if char == ""("": + l += 1 + else: + if l > 0: + l -= 1 + else: + r += 1 + print(""("" * r + s + "")"" * l) + + +if __name__ == '__main__': + main() +" +p03106,s609348451,Accepted,"a,b,k = map(int,input().split()) +ans = [] +ab = [a,b] +for i in range(1,max(ab)+1): + if(a%i == 0 and b%i == 0): + ans.append(i) + +print(ans[-k])" +p03779,s619155605,Accepted,"x = int(input()) +i = 1 +tmp = 0 +while tmp < x: + tmp += i + i += 1 +print(i-1)" +p02602,s393352968,Wrong Answer,"n,k=map(int,input().split()) +a=list(map(int,input().split())) +cnt=a[k-1] +for i in range(n): + if i<=k-1: + continue + else: + if a[i]>cnt: + print('Yes') + cnt=a[i-k+1] + else: + print('No') + cnt=a[i-k+1]" +p03163,s264388888,Accepted,"N,W = map(int, input().split()) +wv = [[int(x) for x in input().split()] for _ in range(N)] +dp = [[0]*(W+1) for _ in range(N+1)] +for i in range(N): + for j in range(W+1): + if j - wv[i][0] >= 0: + dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1]) + else: + dp[i+1][j] = dp[i][j] +print(dp[N][W])" +p03162,s989694225,Accepted,"n = int(input()) +a = [list(map(int,input().split())) for _ in range(n)] +dp = [[0, 0, 0] for _ in range(n+1)] +for i in range(n): + for j in range(3): + for k in range(3): + if j != k: + dp[i+1][j] = max(dp[i+1][j], dp[i][k]+a[i][j]) +print(max(dp[n]))" +p02578,s483930719,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) + +ans = 0 +for i in range(n-1): + if a[i+1] > a[i]: + ans += a[i+1] - a[i] +print(ans) +" +p03759,s200810385,Wrong Answer,"a, b, c = map(int, input().split()) + +print(""YES"" if abs(b-a) == abs(c-b) else ""NO"")" +p03479,s757211478,Wrong Answer,"import math + +x,y = map(int,input().split()) +print(math.floor(math.log2(y//x))+1)" +p02952,s589636487,Accepted,"n = int(input()) +print(len(list(filter(lambda x : len(str(x)) % 2 & 1, range(1, n+1))))) +" +p03210,s457492915,Wrong Answer,"n=input() + +if ""9"" in n: + print(""Yes"") +else: + print(""No"")" +p02607,s970428782,Accepted,"N=int(input()) +A=list(map(int,input().split())) +count=0 +for i in range(0,N,2): + if i%2==0 and A[i]%2==1: + count+=1 +print(count)" +p02755,s590612643,Accepted,"a,b=map(int, input().split()) + +A = int(a/0.08) +B = int((b+1)/0.1) +l =['-1'] + +for i in range(A,B+1): + if int(i*0.08) == a and int(i*0.1) == b: + l.append(i) + break + +print(l[-1])" +p02791,s097000790,Accepted,"def low_element(p): + min = 2*10**5+1 + c = 0 + for p_i in p: + if p_i <= min: + min = p_i + c += 1 + return c + +n = input() +p = [int(i) for i in input().split()] + +print(low_element(p))" +p03360,s571446785,Wrong Answer,"num_list = list(map(int, input().split())) +k = int(input()) + +max = 0 +index = 0 +for i in num_list: + if max < i: + max = i + index = num_list.index(i) + +maximize = max * (2*k) +num_list[index] = maximize +sum = 0 +for j in num_list: + sum += j + +print(sum)" +p03289,s347719482,Wrong Answer,"s = input() + +if(s[0] == ""A"" and s.count(""A"") == 1): + if(s[2:len(s)-1].count(""C"") == 1 and s.count(""C"") == 1): + s.strip(""C"") + s.strip(""A"") + if(s.islower): + print(""AC"") + else: + print(""WA"") + else: + print(""WA"") +else: + print(""WA"")" +p02578,s726206899,Accepted,"N = int(input()) +A = list(map(int,input().split())) +B = A[0] +ans = 0 +for i in range(N): + if B > A[i]: + ans += abs(A[i] - B) + B = max(A[i],B) +print(ans)" +p03730,s449475795,Accepted,"a,b,c =input().split() +a=int(a) +b=int(b) +c=int(c) +f=0 +for num in range(1,b): + d=a*num + d%=b + if d==c : + f=1 +if f: + print(""YES"") +else: + print(""NO"") +" +p03487,s236107881,Wrong Answer,"from collections import Counter +n = int(input()) +a = [int(x) for x in input().split()] +A = Counter(a) +ans = 0 +for x in A: + ans += min(abs(x-A[x]), A[x]) +print(ans)" +p03061,s675626821,Wrong Answer,"#全体のgcdをとる際に最小にしてくるものを、他の全てのgcdに入れ替えてやる +import math +n = int(input()) +a_lis = list(map(int, input().split())) +a_lis.sort() +ans = a_lis[0] +ans_list = [] + +for i in a_lis[1:]: + an = math.gcd(ans, i) + ans_list.append(an) + ans = an + +#print(ans_list) +ts = ans_list.index(ans_list[-1]) +1 +a_lis.pop(ts) +ans_0 = a_lis[0] +for i in a_lis[1:]: + ans_0 = math.gcd(i,ans_0) +print(ans_0)" +p03385,s440620235,Accepted,"S = input() +A = sorted(S) +hantei = """".join(A) +#print(hantei) + +if hantei == ""abc"" : + result = ""Yes"" +else: + result =""No"" +print(result)" +p03705,s650358710,Wrong Answer,"N, A, B = map(int, input().split()) +if A > B: + print(0) +elif A == B: + print(1) +elif B-A >=N: + print(0) +else: + X = N-B+A + print((B-A)*X+1) + " +p03994,s957981754,Wrong Answer,"s = input() +n = len(s) +k = int(input()) + +d = [0] * n +for i in range(n): + if s[i] != 'a': + d[i] = ord('z') - ord(s[i]) + 1 + +ans = list(s) +for i in range(n): + if d[i] != 0 and d[i] <= k: + k -= d[i] + ans[i] = 'a' + if k == 0: break + if i == n-1: + ans[i] = chr(ord(s[i]) + k % 26) + +print(''.join(ans)) +" +p02690,s215105860,Accepted,"import sys +sys.setrecursionlimit(10**9) +X = int(input()) +for i in range(-300, 300): + for j in range(-300, 300): + if i**5 - j**5 == X: + print(i, j) + sys.exit() +" +p03385,s075294048,Accepted,"n = list(input()) +if n.count('a')==1 and n.count('b')==1: + print('Yes') +else: + print('No')" +p03659,s807804534,Wrong Answer,"import numpy as np +n = int(input()) +A = list(map(int, input().split())) +a = list(np.cumsum(A)) +r = sum(A)-A[0] +l = A[0] +ans = abs(r-l) +for i in range(1,len(a)): + r -= a[i] + l += a[i] + ans = min(ans, abs(l-r)) +print(ans)" +p03910,s814670321,Accepted,"n = int(input()) +ans = set([0]) +for i in range(1, n+1): + ans.add(i) + n -= i + if n<=0: + break + +ans = list(ans) +ans.remove(0) +if n!=0: + ans.remove(-n) + +for a in ans: + print(a)" +p02761,s166593751,Accepted,"n, m = map(int, input().split()) +number = [0] * n +cou = [0] * n +#logging.debug(number)# + +for i in range(m): + s, c = map(int, input().split()) + s -= 1 + if cou[s] > 0 and c != number[s]: + print(-1) + exit() + else: + cou[s] += 1 + number[s] = c + #logging.debug(""number = {}, cou = {}"".format(number, cou)) + +if n > 1 and number[0] == 0 and cou[0] >= 1: + print(-1) + exit() +elif n > 1 and number[0] == 0: + number[0] = 1 + +number = map(str, number) +print(''.join(number))" +p02951,s927444433,Wrong Answer,"A,B,C =map(int,input().split()) +print(C - (A-B))" +p02796,s981466103,Accepted,"N = int(input()) +Robot = [] +for i in range(N): + a, b = map(int, input().split()) + Robot.append((a - b, a + b)) +now = -10000000000 +Robot.sort(key=lambda x: x[1]) +ans = 0 + +for i in range(N): + if Robot[i][0] >= now: + ans +=1 + now = Robot[i][1] + +print(ans)" +p03644,s724041070,Accepted,"n = int(input()) +for i in range(1,8): + if n == i: + ans = 1 + break + if 2**i > n: + ans =2**(i-1) + break +print(ans)" +p02820,s067376390,Wrong Answer,"n, k = (int(x) for x in input().split()) +r, s, p = (int(x) for x in input().split()) +t_ch = input() +t=[] +for i in range(n): + t.append(t_ch[i]) + + +for i in range(k-1, n): + if t[i] == t[i-k]: + t[i]=0 +print(t) +for i in range(0,n): + if t[i]==""r"": + t[i]=p + elif t[i]==""p"": + t[i]=s + elif t[i]==""s"": + t[i]=r +print(sum(t)) +" +p03219,s192448137,Accepted,"a,s=map(int,input().split()) +print(a+s//2)" +p02623,s074904557,Accepted,"import sys +input = sys.stdin.readline + +def main(): + N, M, K = map(int, input().split()) + A = list(map(int, input().split())) + B = list(map(int, input().split())) + + import itertools + ac = [0] + list(itertools.accumulate(A)) + bc = [0] + list(itertools.accumulate(B)) + ans, j = 0, M + for i, a in enumerate(ac): + if a > K: + break + while a + bc[j] > K: + j -= 1 + ans = max(ans, i+j) + print(ans) + +if __name__ == '__main__': + main() +" +p02789,s058042173,Accepted,"a,b = map(int, input().split()) + +if a == b: + print('Yes') +else: + print('No')" +p02933,s033401923,Accepted,"def resolve(): + a = int(input()) + s = input() + if a >= 3200: + print(s) + else: + print(""red"") + + +resolve() +" +p03254,s087990025,Wrong Answer,"n,x = map(int,input().split()) +a_list = list(map(int,input().split())) +a_list.sort() +count = 0 +for i in range(n): + if a_list[i] <= x: + count += 1 + x = x-a_list[i] + else: + break +if x > 0: + if count == 0: + print(0) + else: + print(count-1) +else: + print(count) +" +p02917,s969038840,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +n, *b = map(int, read().split()) + +a = [b[0]] +for i in range(1, n-1): + a.append(min(b[i - 1], b[i])) +a.append(b[-1]) +print(sum(a)) +" +p02952,s426651545,Accepted,"n = int(input()) +count = 0 +for i in range(1, n+1): + if len(str(i)) % 2 == 1: + count += 1 +print(count)" +p03799,s826025368,Accepted,"n,m=map(int,input().split()) +print(m//2 if m<=2*n else(2*n+m)//4)" +p02720,s008730643,Wrong Answer,"K = int(input()) +a = [[1], [1, 2], [1, 2, 3], [2, 3, 4], [ + 3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9]] +result = [] +stack = list(range(0, 10)) +i = -1 +while len(result) < K: + i += 1 + l = [] + for j in stack: + for k in a[j // (10**i)]: + l.append((10**(1+i))*k+j) + + result += stack[:] + stack = l[:] +l = sorted(result) +print(l[K]) +" +p02881,s393789231,Accepted,"N = int(input()) +count = 1+N +for i in range(1,int(N**0.5)+1): + if N % i == 0 and i + N/i < count: + count = i+ N/i +count = int(count) +print(count-2) +" +p02792,s480057778,Accepted,"from collections import defaultdict + +n = int(input()) +d = defaultdict(int) + +for x in range(n+1): + s = str(x) + a = s[0] + b = s[-1] + if int(a) and int(b): + d[(a, b)] += 1 + +num = '123456789' +res = 0 +for i in num: + for j in num: + res += d[(i, j)] * d[(j, i)] + +print(res) +" +p03485,s368896182,Accepted,"a, b = map(int, input().split()) + +if (a+b) % 2 == 0: + print((a+b) // 2) +else: + print((a+b+1) // 2)" +p02705,s670807962,Accepted,"import math + +r = int(input()) +print(2*r*math.pi)" +p03835,s160726791,Wrong Answer,"if __name__ == '__main__': + b, c = map(int, input().split()) + num = b*3 -c + if num == 0 or c ==0: + num =1 + else: + if num > b: + num = b*3 + else: + num = num*3 + print(num) + + +" +p03069,s671832892,Accepted,"n = int(input()) +s = input() + +b_cnt = [0] * (n + 1) +for i in range(n): + if s[i] == '#': + b_cnt[i + 1] = b_cnt[i] + 1 + else: + b_cnt[i + 1] = b_cnt[i] + +ans = n +for i in range(n + 1): + ans = min(ans, ((n - i) - (b_cnt[n] - b_cnt[i])) + b_cnt[i]) + +print(ans) +" +p03556,s801972374,Accepted,"#!/usr/bin/env python3 +N = int(input()) + +ans = 0 +for i in range(1, 10**5): + n = i ** 2 + if n <= N: + ans = n + else: + break +print(ans) +" +p02664,s134510852,Wrong Answer,"T = list(str(input())) +X = '' +for i in range(len(T)): + if T[i] == 'P' : + X += 'P' + elif T[i] == 'D' : + X += 'D' + elif T[i] == '?' : + if T[i-1] == 'D' : + X += 'P' + elif T[i-1] == 'P' : + X += 'D' + elif T[i-1] == '?': + X += 'D' + +print(X)" +p02608,s198241360,Accepted,"n=int(input()) +ans = [0 for _ in range(n+1)] +for i in range(1,int((n+1)**0.5)): + for j in range(1,n+1): + for k in range(1,n+1): + v = i*i+j*j+k*k+i*j+j*k+k*i + if v > n: + break + ans[v]+=1 +for i in range(n): + print(ans[i+1])" +p03804,s706508673,Wrong Answer,"n,m = map(int,input().split()) +a = [input() for _ in range(n)] +b = [input() for _ in range(m)] +for i in range(n-m+1): + for j in range(n-m+1): + cnt = 0 + for k in range(m): + if a[i+k][j:j+m] == b[k]: + cnt += 1 + if cnt == m: + print(""YES"") + exit() +print(""NO"")" +p03000,s685855636,Accepted,"n, x = map(int, input().split()) +l = [int(i) for i in input().split()] +b = 0 +c = 1 +for i in range(n): + if b + l[i] <= x: + b += l[i] + c += 1 + else: + break +print(c)" +p03408,s319553334,Accepted,"r1=[input() for _ in range(int(input()))];r2=[input() for _ in range(int(input()))];ans=0 +for i in set(r1): ans=max(ans,r1.count(i)-r2.count(i)) +print(ans)" +p02959,s179597406,Wrong Answer,"# ABC136 C-City Savers +n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +ans=0 + +for i in range(n): + ans+=min(b[i],a[i+1]) + b[i]-=min(b[i],a[i+1]) + ans+=min(b[i],a[i]) + b[i]-=min(b[i],a[i]) +print(ans)" +p03328,s711168353,Wrong Answer,"a, b = map(int, input().split()) + +sm = 0 + +for x in range(1, 1000): + sm += x + if sm > a: + print(sm-a) + break +" +p02725,s629335699,Accepted,"from sys import stdin + +k,n = [int(x) for x in stdin.readline().strip().split()] +a_lst = [int(x) for x in stdin.readline().strip().split()] +diff_lst = [a_lst[i+1] - a_lst[i] for i in range(len(a_lst)-1)] + [k - a_lst[-1] + a_lst[0]] + +print(k - max(diff_lst))" +p03730,s231107063,Wrong Answer,"a,b,c=map(int,input().split()) +num = a +if (a % 2 == 1 and c % 2 == 0) or (a % 2 == 0 and c % 2 == 1): + print('NO') +else: + while True: + if a % b == c: + print('YES') + break + a += num" +p02836,s476097882,Accepted,"def main(): + s = list(input()) + ans = 0 + + for i in range(len(s)): + if s[i] != s[-i - 1]: + s[i] = s[-i - 1] + ans += 1 + + print(ans) + + +if __name__ == ""__main__"": + main() +" +p03471,s270368809,Wrong Answer,"N, Y = map(int, input().split()) +for i in range(N+1): + for j in range(N-i-1): + k = N- i - j + if k >= 0 and 10000*i + 5000*j + 1000*k == Y: + print(i, j, k) + exit() +print('-1 -1 -1') +" +p03427,s969291536,Accepted,"f, *n = str(int(input())+1) +print(int(f) + 9*len(n) - 1)" +p03696,s431126405,Wrong Answer,"n=int(input()) +s=input() +S=s.split(""()"") +L,R=0,0 +for i in S: + for j in i: + if j=="")"":L +=1 + else:R +=1 + +print(""(""*L+s+"")""*R)" +p03487,s543117228,Accepted,"import sys +from collections import Counter + + +input = sys.stdin.readline + + +def main(): + N = int(input()) + A = [int(x) for x in input().split()] + + C = Counter(A) + + ans = 0 + for k in C.keys(): + if k > C[k]: + ans += C[k] + else: + ans += C[k] - k + print(ans) + + + + + +if __name__ == '__main__': + main() + +" +p02707,s943004796,Wrong Answer,"N = int(input()) +A = list(map(int, input().split())) +for r in {A.count(i) for i in range(1, N + 1)}: + print(r)" +p03835,s342536233,Accepted," +def resolve(): + ks = input().split("" "") + k = int(ks[0]) + s = int(ks[1]) + + n = 0 + + for zz in range(k+1): + for yy in range (k+1): + if (0 <= s-(yy+zz) <= k): + n += 1 + + print(n) + +if __name__ == ""__main__"": + resolve()" +p03075,s660812592,Accepted,"a=[int(input()) for i in range(6)] +for i in range(5): + for j in range(4): + if abs(a[i]-a[j+1])>a[5]: + print("":("") + exit() +print(""Yay!"")" +p03145,s014911146,Accepted,"a,b,c=map(int,input().split()) +print((a*b)//2)" +p03773,s461665546,Accepted,"a, b = map(int, input().split()) +print((a+b)%24)" +p02725,s595682916,Wrong Answer,"K, N = [int(i) for i in input().split()] +A = [int(i) for i in input().split()] +Ar = [i for i in A] +for i,a in enumerate(A): + if K - a < a: + Ar[i] = a - K +print(min(max(A) - min(A), max(Ar) - min(Ar))) +" +p03043,s255869800,Accepted,"n, k = map(int, input().split()) +ans = 0 +for i in range(1, n+1): + x = 0 + while i < k: + i *= 2 + x += 1 + ans += 1/n*(1/2)**x +print(ans) +" +p02963,s839057369,Wrong Answer,"s = int(input()) +print(0,0,int(s**0.5),0,s//int(s**0.5),0)" +p03607,s779593343,Accepted,"import collections + +N = int(input()) + +l = list() +for i in range(N): + l.append(int(input())) + +c = collections.Counter(l) + +la = list(c.values()) +M = len(la) +ans = 0 +for i in range(M): + if la[i] % 2 == 1: + ans += 1 + +print(ans)" +p02829,s908516809,Accepted,"#A +A=int(input()) +B=int(input()) +K=[A,B] +for i in range(1,4): + if not i in K: + print(i)" +p03524,s283221486,Accepted,"from itertools import permutations + +S=input() +a,b,c=""a"",""b"",""c"" +D={a:0,b:0,c:0} + +for s in S: + D[s]+=1 + +X=min(D.values()) +Y=max(D.values()) + +if Y-X<=1: + print(""YES"") +else: + print(""NO"") +" +p03146,s948564326,Accepted,"def collatz(n): + if n%2==0: + return int(n/2) + else: + return 3*n+1 + +a=int(input()) +cnt=1 +if a==1 or a==2: + ans=cnt+3 +else: + while a !=4: + a=collatz(a) + cnt+=1 + ans=cnt+3 + +print(ans)" +p03487,s332119644,Accepted,"from collections import Counter +N = int(input()) +a = [int(i) for i in input().split()] + +ans = 0 +m = Counter(a) +for x, y in m.items(): + if x == y: + continue + elif x < y: + ans += abs(y-x) + else: + ans += y +print(ans)" +p03030,s978967715,Wrong Answer,"N=int(input()) +A=[list((input().split())) for i in range(N)] +for num in range(N): + A[num][1]=int(A[num][1]) +for num in range(N): + A[num].append(num+1) +from operator import itemgetter +A.sort(key=itemgetter(0,1)) +for num in range(N): + A[num].append(num+1) +A.sort(key=itemgetter(2)) +for num in range(N): + print(A[num][3])" +p02707,s636837253,Accepted,"import collections +N = int(input()) +# 社員番号1以外のN-1人分担当上司番号を入力する +A = list(map(int, input().split())) +# 出現回数を数えてくれる +count = collections.Counter(A) +for n in range(N): +# 数が足りないから+1する。 + print(count[n+1])" +p03041,s541853327,Accepted,"N, K = list(map(int, input().split())) +s = input() + +for i in range(N): + if i != K-1: + print(s[i], end='') + else: + print(str.swapcase(s[i]), end='') + +" +p03625,s450645109,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=sorted(A)[::-1] +cnt=1 +a=0 +C=[] +for i in B: + if a==i: + cnt+=1 + if cnt==2: + cnt=0 + C.append(a) + if len(C)==2: + print(C[0]*C[1]) + exit() + else: + a=i + cnt=1 +print(0) + " +p03719,s642354119,Accepted,"import sys +import os + +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) + +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + A, B, C = il() + print('Yes' if A <= C <= B else 'No') + + +if __name__ == '__main__': + main() +" +p03730,s607721623,Wrong Answer,"a,b,c=map(int,input().split()) +flag = False +for i in range(10000): + if (i*b+c)%a==0: + flag = True + break +if flag: + print('Yes') +else: + print('No') + + " +p02693,s711498945,Accepted,"k=int(input()) +a,b=map(int,input().split()) + +if a%k==0: + print((""OK"")) +else: + if b//k-a//k>=1: + print(""OK"") + else: + print(""NG"") +" +p03759,s571516450,Wrong Answer,"a, b, c = map(int, input().split()) +print('Yes' if b - a == c - a else 'No')" +p02899,s091518921,Wrong Answer,"N=int(input()) +A=list(map(int,input().split())) +ans = 1 +X = [] +for i in range(N): + for j in range(i): + if A[i] == ans: + ans += 1 + X.append(i+1) +print(''.join(map(str,X))) +" +p04005,s067475255,Accepted,"A = list(map(int, input().split())) +A.sort() +if A[0] % 2 == 0 or A[1] % 2 == 0 or A[2] % 2 == 0: + ans = 0 +else: + ans = A[0] * A[1] +print(ans)" +p03944,s324830308,Accepted,"import numpy as np + +W,H,N = map(int,input().split()) +l = np.zeros((H,W)) # 要素0のH×W配列 + +for i in range(N): + x,y,a = map(int,input().split()) + + if a==1: + l[:,:x] = 1 + #print(l[:,x:]) + elif a==2: + l[:,x:] = 1 + elif a==3: + l[:y,:] = 1 + elif a==4: + l[y:,:] = 1 +#print(H*W-int(l.sum().sum())) +print(H*W-int(l.sum()))" +p03779,s904545997,Wrong Answer,"a = int(input()) +s = 0 +for i in range(1,a): + s+=i + if s>=a: + print(i) + break" +p02720,s716760249,Accepted,"from heapq import heappop, heappush + +k = int(input()) + +q = [] + +for i in range(9): + heappush(q, i+1) + +for _ in range(k - 1): + x = heappop(q) + if x % 10 != 0: + heappush(q, 10 * x + (x % 10) - 1) + if x % 10 != 9: + heappush(q, 10 * x + (x % 10) + 1) + heappush(q, 10 * x + (x % 10)) + +print(heappop(q))" +p03126,s450753739,Accepted,"n,m = map(int,input().split()) +L = [i for i in range(1,m+1)] +for j in range(n): + l = list(map(int,input().split())) + del l[0] + L = set(l) & set(L) +print(len(L))" +p02768,s386851815,Wrong Answer,"n, a, b = map(int, input().split()) +MOD = 10**9+7 + + +def modcmb(n, k, mod): + rtn = n + for i in range(1, k): + rtn = (rtn * (n-i) * pow(i+1, mod-2, mod)) % mod + + return rtn + + +ans = pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD) +print(ans if ans >= 0 else ans + MOD) +" +p02663,s927040288,Wrong Answer,"a,b,c,d,e=map(int,input().split()) + +x=((c*60-d)-(a*60+b))-e + +if x<0: + x=x+1440 +print(x) +" +p02813,s698104709,Accepted,"N=int(input()) + +P=list(map(int,input().split())) +Q=list(map(int,input().split())) + +import itertools +itertools.permutations(P) +l=list(itertools.permutations(P)) +l.sort() +P=tuple(P) +Q=tuple(Q) + +p=l.index(P) +q=l.index(Q) + +print(abs(p-q)) +" +p02747,s173828040,Accepted,"print('YNeos'[input().replace('hi','')!=''::2])" +p03281,s183595656,Wrong Answer,"n = int(input()) +import itertools + +a = [3,5,7,11] +ax = 3*5*7*11 +b = [] +for i in range(4): + b.append(ax//a[i]) +c = list(itertools.combinations([0, 1, 2, 3], 2)) +for j in range(len(c)): + b.append(a[c[j][0]]**3 * a[c[j][1]]) + +ans = 0 +for i in b: + if n >= i: + ans += 1 +print(ans)" +p03627,s783962237,Accepted,"n = int(input()) +li = list(map(int, input().split())) + +li.sort(reverse=True) + +check = -1 +flag = 0 +ans = [] + +for i in li: + if len(ans) == 2: + break + + if flag == 0: + check = i + flag = 1 + continue + + if check == i: + ans.append(i) + flag = 0 + else: + check = i + +if len(ans) < 2: + print(0) +else: + print(ans[0] * ans[1])" +p03086,s276157671,Accepted,"ss=['A','G','C','T'] +s=list(input()) +ans=0 +for i in range(len(s)): + if s[i] in ss: + j=i + cnt=0 + while j 2000000: + ans = -1 + break + print(ans) + + +if __name__ == ""__main__"": + main()" +p03478,s744524201,Accepted,"n,a,b=map(int,input().split()) +ans=0 +for i in range(1,n+1): + s=str(i) + t=0 + for ss in s: + t+=int(ss) + if a<=t<=b: + ans+=int(i) +print(ans) + +" +p02795,s774568331,Accepted,"h = int(input()) +w = int(input()) +n = int(input()) +a = max(h,w) +b = a +count = 0 +if h*w == n: + print(h) +elif b >= n: + print(1) +else: + while b*count < n: + count += 1 + print(count)" +p02760,s430568310,Accepted,"# Bingo +A = [] +for _ in range(3): + A += list(map(int, input().split())) +N = int(input()) +for _ in range(N): + b = int(input()) + if b in A: + A[A.index(b)] = -1 + +# check +diag = (sum(A[0::4]) == -3) | (sum(A[2:8:2]) == -3) +rows = (sum(A[:3]) == -3) | (sum(A[3:6]) == -3) | (sum(A[6:]) == -3) +cols = (sum(A[:7:3]) == -3) | (sum(A[1:8:3]) == -3) | (sum(A[2::3]) == -3) +ans = diag | rows | cols +print(['No', 'Yes'][ans])" +p03145,s754073809,Accepted,"a,b,c=map(int,input().split()) +print(a*b//2)" +p02778,s235717173,Accepted,"s = input() +print('x' * len(s))" +p02595,s136636319,Accepted,"N, D = map(int, input().split()) +X = [0]*N +Y = [0]*N +for i in range(N): + X[i], Y[i] = map(int, input().split()) + +count = 0 +D2 = D**2 + +for i in range(N): + temp = X[i]**2 + Y[i]**2 + if temp<=D2: + count += 1 + +print(count)" +p02909,s007620063,Accepted,"a = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'} +print(a[input()])" +p03239,s702989099,Accepted,"import math +import string + + +def readints(): + return list(map(int, input().split())) + + +def nCr(n, r): + return math.factorial(n)//math.factorial(n-r)*math.factorial(r) + + +N, T = map(int, input().split()) +a = 10000 +for i in range(N): + c, t = map(int, input().split()) + if t <= T: + a = min(a, c) +if a == 10000: + print('TLE') +else: + print(a) +" +p03699,s258334358,Wrong Answer,"n = int(input()) + +s = [] + +for i in range(n): + s.append(int(input())) + +s = sorted(s) + +total = 0 +for i in range(n): + total += s[i] + +i = 0 +while total > 0 and total%10 == 0: + total -= s[i] + i += 1 + +print(total)" +p02594,s116480925,Accepted,"x = int(input()) +print('Yes' if x >= 30 else 'No')" +p02624,s033260708,Wrong Answer,"import numpy as np + +N = int(input()) + +count = 0 +for i in range(1, (N+1)//2+1): + count += int(np.ceil((N+1)/i)) * (N - (N)%i) // 2 + + +print(count)" +p02663,s306202225,Accepted,"h, m, h2, m2, k = map(int, input().split()) +ans = (h2 * 60 + m2) - (h * 60 + m) - k +print(ans)" +p03427,s637775705,Accepted,"n = int(input()) +d = len(str(n)) +n_sum = 0 +for i in range(d): + n_sum += int(str(n)[i]) +def judge(n): + for i in range(1, len(n)): + if n[i] != ""9"": + return True + return False +print(n // (10 ** (d - 1)) - 1 + 9 * (d - 1) if judge(str(n)) else n_sum)" +p02683,s262397668,Accepted,"n, m, x = map(int, input().split()) +ca_list = [[int(i) for i in input().split()] for _ in range(n)] +ans = 999999999999999 +flag = 0 + +for i in range(2**n): + bin_str = format(i, '0'+str(n)+'b') + skill_list = [0]*m + cost = 0 + for j, ca in enumerate(ca_list): + if bin_str[j] == ""1"": + cost += ca[0] + for k in range(m): + skill_list[k] += ca[k+1] + if all([i >= x for i in skill_list]): + ans = min(ans, cost) + flag = 1 +print(ans if flag == 1 else -1)" +p03997,s024870282,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +print((a+b)*c//2)" +p02628,s739841404,Accepted,"N,K = map(int, input().split()) +p = list(map(int, input().split())) + +p.sort() +total = 0 + +for i in range(K): + total += p[i] + +print(total)" +p02725,s438024420,Wrong Answer,"k=int(input().split("" "")[0]) +a = list(map(lambda x: int(x), input().split(""\n"")[0].split("" ""))) +df = max(a) - min(a) +print(min(df, k - df))" +p02971,s479339590,Accepted,"n = int(input()) +a = [int(input()) for _ in range(n)] + +maximum = max(a) +ans = [maximum]*n +if a.count(maximum) ==1: + maximum_index = a.index(maximum) + ans[maximum_index] = max( + a[:maximum_index]+a[maximum_index+1:] + ) +for i in range(n): + print(ans[i])" +p03289,s577985428,Wrong Answer,"s = input() +cnt = 0 +if (s[2:-2].count('C') != 1): + print('WA') + exit(0) +for i in range(len(s)): + if (s[i] >= 'A' and s[i] <= 'Z'): + cnt += 1 + if (cnt >= 3): + print('WA') + exit(0) +print('AC') +" +p03380,s604143380,Wrong Answer,"import bisect + +N = 5 +ARR = [6, 9, 4, 2, 11] + + +N = 2 +ARR = [100, 0] + +N = int(input()) +ARR = list(map(int, input().split())) + + +def calculate(n, arr): + arr = sorted(arr) + + mid = arr[n - 1] / 2 + + a1 = bisect.bisect_left(arr, mid) + + return arr[n - 1],arr[a1] + + + +n, a = calculate(N, ARR) +print(n, a) +" +p04019,s565730842,Accepted,"import sys, math +from functools import lru_cache +from collections import deque +sys.setrecursionlimit(10**9) +MOD = 10**9+7 + +def input(): + return sys.stdin.readline()[:-1] + +def mi(): + return map(int, input().split()) + +def ii(): + return int(input()) + +def i2(n): + tmp = [list(mi()) for i in range(n)] + return [list(i) for i in zip(*tmp)] + +S = set(input()) +if S == {'N', 'S'} or S == {'W', 'E'} or S == {'W', 'E', 'N', 'S'}: + print('Yes') +else: + print('No')" +p02899,s700812190,Accepted,"def main(): + N = int(input()) + A = list(map(int,input().split())) + d = {} + for i,a in enumerate(A): + d[a]=i + for i in range(1,N+1): + print(d[i]+1,end="" "") + print() + +if __name__=='__main__': + main() +" +p03821,s247870764,Accepted,"n = int(input()) +abl = [list(map(int,input().split())) for nesya in range(n)] +c = 0 +abl = abl[::-1] +for ab in abl: + a = ab[0] + c + b = ab[1] + if a%b == 0: + continue + c += (b - a%b) +print(c) +" +p02607,s821600868,Accepted,"def main(): + N = int(input()) + a = list(map(int,input().split())) + + res = 0 + for i in range(N): + if (i+1) % 2 == 1 and a[i] % 2 == 1: + res += 1 + print(res) + +if __name__ == ""__main__"": + main() +" +p03293,s026096020,Wrong Answer,"import sys +import os + +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) + +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] + + +def main(): + if os.getenv(""LOCAL""): + sys.stdin = open(""input.txt"", ""r"") + + S = list(iss()) + T = list(iss()) + for s in S: + if s not in T: + print('No') + exit() + + print('Yes') + + +if __name__ == '__main__': + main() +" +p02848,s691179691,Accepted,"n = int(input()) +s = input() +for i in range(len(s)): + if ord(s[i])+n <= ord(""Z""): + print(chr(ord(s[i])+n), end="""") + else: + print(chr(ord(s[i])+n-26), end="""") +print()" +p04012,s137640308,Accepted,"from collections import Counter +w = input() +cnt = Counter(w) + +ans = ""Yes"" +for r in cnt.values(): + if r % 2 == 0: + continue + ans = ""No"" + break + +print(ans)" +p04011,s251633892,Wrong Answer,"n = int(input()) +k = int(input()) +x = int(input()) +y = int(input()) + +print(k*x + (n-k)*y)" +p02598,s773850971,Accepted,"n, k = map(int, input().split()) +a = list(map(int, input().split())) + +l = 0 +r = 10**9+1 + +def ok(x): + cnt = 0 + for b in a: + cnt += (b//x) + if b%x == 0: + cnt -= 1 + return cnt <= k + +while r-l > 1: + md = (l+r)//2 + if ok(md): + r = md + else: + l = md +print(r)" +p02829,s708310226,Accepted,"a=int(input()) +b=int(input()) +if a+b==3: + print(""3"") +if a+b==4: + print(""2"") +if a+b==5: + print(""1"")" +p03067,s376429359,Accepted,"a,b,c = map(int, input().split()) +if a < c < b or b < c < a: + print('Yes') +else: + print('No')" +p03254,s528756896,Wrong Answer,"from itertools import accumulate +N, X = [int(x) for x in input().split()] +a = sorted([int(x) for x in input().split()]) +p = list(accumulate(a)) + +result = 0 +break_idx = 0 +for i, x in enumerate(p): + if X < x: + break_idx = i + break + result += 1 + +if result != 0 and p[break_idx-1] != X: + result -= 1 + +print(result)" +p03095,s764580090,Wrong Answer,"n = int(input()) +s = list(input()) + +from collections import Counter + +c = Counter(s) + +ans = 1 +for k,v in c.items(): + ans *=(v+1) + +ans -=1 +print(ans) + +" +p03077,s890731285,Accepted,"import math +n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +l = min([a,b,c,d,e]) +print(5 + math.ceil(n/l) - 1) +" +p02801,s380089405,Accepted,"import string +C=input() +for i in range(len(string.ascii_lowercase)): + if(string.ascii_lowercase[i]==C): + print(string.ascii_lowercase[i+1])" +p03087,s285275553,Wrong Answer,"N, Q = map(int, input().split()) +S=list(input()) +list=[] +for i in range(0, N-1): + if S[i] == ""A"" and S[i+1] == ""C"": + list.append(i) +count=0 +for i in range(Q): + l, r = map(int, input().split()) + for j in list: + if l-1 <= j < r-1: + count+=1 + else: + count+=0 + print(count)" +p03427,s917368195,Accepted,"N = int(input()) + +n = str(N) + +res = 0 + +if len(n) == 1: + res = N + +else: + nine = True + for i in range(1, len(n)): + if n[i] != ""9"": + nine = False + break + + if nine: + res = int(n[0]) + 9 * (len(n) - 1) + else: + res = (int(n[0]) - 1) + 9 * (len(n) - 1) + +print(res)" +p02612,s011655526,Accepted,"n=int(input()) +if n%1000 == 0:print(0) +else:print(1000-(n%1000)) +" +p02861,s924803623,Accepted,"import itertools +import math +N=int(input()) +lis=[] +for i in range(N): + [x,y]=[int(j)+1000 for j in input().split()] + lis+=[x+y*10000] +A=list(itertools.permutations(lis)) +add=0 +cnt=0 +for i in range(len(A)): + for j in range(len(A[i])-1): + add+=(((A[i][j]//10000)-(A[i][j+1]//10000))**2+((A[i][j]%10000)-(A[i][j+1]%10000))**2)**0.5 + cnt+=1 +print(add/math.factorial(N))" +p02912,s470842060,Accepted,"import heapq + +N, M = tuple(map(int, input().split())) +A = list(map(int, input().split())) +A = list(map(lambda x: x*(-1), A)) +heapq.heapify(A) +for i in range(M): + tmp = heapq.heappop(A) * (-1) // 2 + heapq.heappush(A, tmp * (-1)) +print(sum(A) * (-1))" +p02909,s801813820,Accepted,"S = input() +List = [""Sunny"", ""Cloudy"", ""Rainy""] +if List.index(S) == 2: + print(List[0]) +else: + T = List.index(S)+1 + print(List[T])" +p02546,s786813674,Wrong Answer,"s = input() +ret = s +if s[::-1] == ""s"": + ret += ""es"" +else: + ret += ""s"" + +print(ret)" +p02742,s599547066,Accepted,"h,w=map(int,input().split()) +if h<2 or w<2: + print(1) +elif h%2==0 or w%2==0: + print(int(h*w/2)) +else: + print(int(h*w/2)+1)" +p02948,s180615351,Accepted,"import heapq as hq +n,m = map(int,input().split()) +ab = [] +for i in range(n): + a,b = map(int,input().split()) + ab.append((a,-b)) +ab.sort() +ans = 0 +idx = 0 +q = [] +for i in range(1,m+1): + while idx=b: + print(""delicious"") +elif b<=(a+x+1): + print(""safe"") +else: + print(""dangerous"")" +p02708,s086850486,Wrong Answer,"import itertools +n, k = map(int, input().split()) +data = list(x for x in range(n+1)) +ans = 0 +if n <= k : + ans +=1 +else: + for i in range(k, n+1): + j = list(itertools.combinations(data, i)) + ans += len(j) + +print(ans)" +p02786,s705635126,Accepted,"import sys + +if sys.platform =='ios': + sys.stdin=open('input_file.txt') + + +H=int(input()) + +cnt=0 +p=0 + +while H>0: + H=H//2 + cnt+=1 + + +for i in range(cnt): + p=1+p*2 + +print(p) + " +p02854,s593433217,Wrong Answer,"import sys +n=int(input()) +a=list(map(int,input().split())) +tmp=0 +for i in range(n): + tmp+=a[i] + if tmp*2==sum(a): + print(0) + sys.exit() + if tmp*2>sum(a): + l=i + continue +if abs(tmp*2-sum(a))>abs((tmp-a[l])*2-sum(a)): + print(abs((tmp-a[l-1])*2-sum(a))) +else: + print(abs(tmp*2-sum(a)))" +p03495,s815865328,Wrong Answer,"# arc086_a.py +import collections +N, K = map(int, input().split()) +A = list(map(int, input().split())) +C = collections.Counter(A) +C = sorted(C.values()) + +lenght = len(C) +print(lenght, K, C) +print(sum(C[:(lenght-K)])) +" +p03161,s355253664,Accepted,"import numpy as np + + +N, K = map(int, input().split()) +h = np.array([int(i) for i in input().split()]) +dp = np.full(N, 10 ** 10) + +# 初期条件 +dp[0] = 0 +dp[1] = abs(h[1] - h[0]) + +for i in range(2, N): + ik = max(0, i - K) + dp[i] = np.min(dp[ik:i] + np.abs(h[i] - h[ik:i])) + +print(int(dp[-1])) + +" +p03017,s316389050,Wrong Answer,"n,a,b,c,d=map(int,input().split()) +s=str(input()) + +if c w[1]: + f = False + break +if f: + print(""Yes"") +else: + print(""No"")" +p02628,s948687302,Wrong Answer,"N, K = list(map(int, input().split())) +p = list(map(int, input().split())) + +p = sorted(p) + +print(sum(p[:N]))" +p03773,s769619902,Accepted,"A,B = (int(x) for x in input().split()) +x = (A+B)%24 +print (x) +" +p02596,s283017950,Wrong Answer,"k = int(input()) +answer = -1 +cou = 7 +for i in range(k+1): + if cou%k == 0: + answer = cou + else: + cou = cou*10 + 7 +print(answer)" +p02783,s553538249,Accepted,"H, A = list(map(int, input().split())) + +cnt = 0 +while H > 0: + cnt += 1 + H -= A +print(cnt) +" +p03835,s677182918,Wrong Answer,"import itertools +ans = 0 +k, s = map(int, input().split()) +sa = [int(i) for i in range(k+1)] +tt = [int(i) for i in range(k+1)] +c = itertools.product(sa,repeat=2) + +for i in c: + if i[0] + i[1] - s in tt: + ans+=1 + +print(ans)" +p02801,s372697052,Accepted,"s=[chr(i) for i in range(97,123)] +c=raw_input() +ans= s.index(c) +print s[ans+1]" +p02608,s536814627,Accepted,"N = int(input()) + +A = [0 for _ in range(N+1)] +n = int(N ** 0.5) + 1 +for x in range(1, n): + for y in range(1, n): + for z in range(1, n): + v = x*x + y*y + z*z + x*y + y*z + z*x + if v <= N: + A[v] += 1 +for i in range(1, N+1): + print(A[i]) +" +p03565,s613506710,Wrong Answer,"s = input() +t = input() + +flag = 0 +for i in range(0, len(t)): + if (t[:i] + '?' * (len(t) - i)) in s: + s = s.replace(t[:i] + '?' * (len(t) - i), t) + s = s.replace('?', 'a') + print(s) + flag = 1 + break + +if flag == 0: + print('UNRESTORABLE')" +p03695,s725471196,Accepted,"N = int(input()) +A = list(map(int, input().split())) +S = set() +sa = 0 +for i in A: + a = i // 400 + if a < 8: + S.add(a) + else: + sa += 1 +ans1 = max(len(S), 1) +ans2 = len(S) + sa +print(ans1, ans2)" +p02970,s684828416,Accepted,"import math +n, d = map(int,input().split()) +ans = math.ceil(n / (2 * d + 1)) +print(ans)" +p03438,s837797067,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +b=list(map(int,input().split())) +c=sum(b)-sum(a) +co=0 +for i in range(n): + if a[i]>b[i]: + co+=a[i]-b[i] + else: + co+=(b[i]-a[i])//2 +print('Yes' if c==co else 'No')" +p03041,s881064812,Accepted,"import io + +n,k=map(int,input().split()) +a=input() +a=a[:k-1]+a[k-1].lower()+a[k:] +print(a)" +p02973,s485440977,Accepted,"import sys +input = sys.stdin.readline +from bisect import bisect_left +from collections import deque + +def main(): + N = int(input()) + counter = deque([]) + for _ in range(N): + a = int(input()) + ind = bisect_left(counter, a) + if ind == 0: + counter.appendleft(a) + else: + counter[ind-1] = a + print(len(counter)) + + +if __name__ == '__main__': + main()" +p03419,s841250720,Accepted,"N, M = map(int, input().split()) + +if (N==1) & (M > 1): + ans = M - 2 +elif (M==1) & (N > 1): + ans = N - 2 +elif (N==1) & (M==1): + ans = 1 +else: + ans = ((N - 2) * (M - 2)) + +print(ans)" +p03681,s253596181,Accepted,"import collections +import itertools +import math + +n,m = map(int,input().split()) +ans = 0 +if abs(n-m)>1: + ans = 0 +elif n - m == 0: + tmp = math.factorial(n) + ans = tmp**2*2 +else: + ans = math.factorial(m)*math.factorial(n) +print(ans%(10**9+7))" +p02831,s000847501,Accepted,"from math import gcd +a,b=map(int,input().split()) +print(a*b//gcd(a,b))" +p03282,s153546872,Accepted,"s=list(input()) +k=int(input()) + +for i in range(k): + if s[i] != ""1"": + print(s[i]) + break +else: + print(1)" +p03042,s218909037,Accepted,"S = input() +ans = [0,0] + +if 1<=int(S[:2]) and int(S[:2]) <= 12 : + ans[0] = 1 +if 1 <=int(S[2:]) and int(S[2:]) <= 12 : + ans[1] = 1 + +if ans == [1,1] : + print('AMBIGUOUS') +elif ans == [0,0] : + print('NA') +elif ans == [0,1] : + print('YYMM') +elif ans == [1,0] : + print('MMYY')" +p03854,s772966828,Accepted,"S=input() +S=S.replace(""eraser"","""") +S=S.replace(""erase"","""") +S=S.replace(""dreamer"","""") +S=S.replace(""dream"","""") +if len(S)==0: + print(""YES"") +else: + print(""NO"")" +p02701,s884187098,Wrong Answer,"n = int(input()) + +import sys +S = set(sys.stdin.buffer.readlines()) + +print(len(S))" +p03971,s370398028,Wrong Answer,"N,A,B = map(int,input().split()) +S = input() + +pass_num = 0 + +for i in S: + if i == 'a': + if (A + B)-1 >= pass_num: + print('Yes') + pass_num += 1 + else: + print('No') + elif i == 'b': + if B >= pass_num: + print('Yes') + pass_num += 1 + else: + print('No') + else:# i == 'c' + print('No')" +p02854,s362449902,Accepted,"n=int(input()) +a=list(map(int,input().split())) +temp=sum(a) +ans=0 +t=9999999999999999 +tsum=0 +ta=0 +for i in range(n): + tsum=tsum+a[i] + if abs(tsum-temp/2)=A[i]: + x -= A[i] + i += 1 +if x>0 and i==N: + i -= 1 +print(i)" +p02730,s935959066,Accepted,"S = input() +answer = 'Yes' +if S != S[::-1]: + answer = 'No' +first = S[:len(S) // 2] +last = S[len(S) // 2 + 1:] +if first != first[::-1]: + answer = 'No' +if last != last[::-1]: + answer = 'No' +print(answer)" +p02946,s018019061,Accepted,"k,x=map(int,input().split()) +for i in range(x-k+1,x+k): + print(i,end=' ')" +p03077,s184389974,Accepted,"n = int(input()) +a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) + +m = min([a,b,c,d,e]) +t = 4 +if n%m==0: + t += n//m +else: + t += n//m + 1 +print(t)" +p03351,s888438359,Accepted,"a,b,c,d = (int(T) for T in input().split()) +if abs(a-c)<=d: + print('Yes') +else: + if abs(a-b)<=d and abs(b-c)<=d: + print('Yes') + else: + print('No')" +p03644,s579465588,Accepted,"N = int(input()) + +if N < 2: + ans = 1 +elif N < 4: + ans = 2 +elif N < 8: + ans = 4 +elif N < 16: + ans = 8 +elif N < 32: + ans = 16 +elif N < 64: + ans = 32 +else: + ans = 64 + +print(ans)" +p02678,s754414215,Accepted,"from collections import deque +N, M = map(int, input().split()) +B = [[] for i in range(N)] +C = [0 for i in range(N)] +for i in range(M): + a, b = map(int, input().split()) + B[a-1].append(b) + B[b-1].append(a) +d = deque([1]) +while len(d): + p = d.pop() + for q in B[p-1]: + if C[q-1] == 0: + C[q-1] = p + d.appendleft(q) +print(""Yes"") +for i in range(1, N): + print(C[i])" +p02972,s960554585,Accepted,"N = int(input()) +A = list(map(int,input().split())) +A = [0] + A +res = [0]*(N+1) +M = 0 + +for i in range(N,0,-1): + if sum(res[j] for j in range(i,N+1,i)) % 2 != A[i]: + res[i] = 1 + M += 1 + +print(M) +print(*[k for k, r in enumerate(res) if r])" +p02594,s099391451,Accepted,"X = int(input()) + +if 30 <= X: + print('Yes') +else: + print('No')" +p02724,s426615610,Accepted,"X = int(input()) +yen500, yen5 = divmod(X, 500) +yen5 = yen5 // 5 +print(yen500 * 1000 + yen5 * 5)" +p02957,s539739976,Accepted,"A,B=map(int, input().split()) +if A % 2 == B % 2 : print((A+B)//2) +else : print(""IMPOSSIBLE"")" +p02939,s303048655,Accepted,"s = list(input()) +i = len(s) +ans = 0 +while i >= 3: + if s[i-1] != s[i-2]: + i -= 1 + ans += 1 + else: + i -= 3 + ans += 2 +if i <= 1: + print(ans+i) +else: + if s[i-1] != s[i-2]: + print(ans+2) + else: + print(ans+1) +" +p03109,s272694503,Accepted,"s = input() + +d = s.split(""/"") +if int(d[0]) > 2019: + print(""TBD"") +elif int(d[0]) < 2019: + print(""Heisei"") +elif int(d[1]) < 5: + print(""Heisei"") +else: + print(""TBD"")" +p03136,s106044330,Accepted,"N = int(input()) +L = list(map(int,input().split())) +a = max(L) +L.remove(a) +s = 0 +for i in L: + s += i + +if a < s: + print('Yes') +else: + print('No')" +p03163,s951422330,Wrong Answer,"import numpy as np + +N, W = map(int, input().split()) +wv = np.array([list(map(int, input().split())) for _ in range(N)], dtype=""int64"") +dp = np.zeros(W + 1, dtype=""int64"") + +for w, v in wv: + dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v) + print(dp) + +print(dp[-1])" +p03264,s425799583,Wrong Answer,"k = int(input()) +print(k/2**2 if k % 2 == 0 else (k**2 - 1)/4) + " +p03760,s437063656,Accepted,"O = input() +E = input() + +res = """" +for i in range(len(O) - 1): + res += O[i] + E[i] + +res += O[len(O) - 1] +if len(E) == len(O): + res += E[len(E) - 1] + +print(res) +" +p02606,s963594838,Wrong Answer,"l,r,d = map(int, input().split()) +print(r//d-l//d)" +p03951,s500558381,Accepted,"n=int(input()) +s=input() +t=input() +yn=0 +for i in range(n): + if s[i:]==t[:n-i]: + yn=1 + break +if yn==0: + print(n*2) +else: + print(n+i) +" +p02642,s593027320,Wrong Answer,"from collections import Counter +N = int(input()) +A = list(map(int,input().split())) +C = Counter(A).most_common() + +MAXN = pow(10,6) +B = [False]*(MAXN+1) +for c in C: + if c[1] == 1: + B[c[0]] = True + +ans = 0 +for i in range(MAXN + 1): + if B[i]: + ans += 1 + B[i::i] = [False]*(MAXN//i) +print(ans)" +p03659,s372849033,Accepted,"import sys +n=int(input()) +a=list(map(int,sys.stdin.readline().strip().split())) +snk=a[0] +rac=sum(a[1:]) + +s=sum(list(map(abs,a))) +for i in range(1,n-1): + snk+=a[i] + rac-=a[i] + s=min(s,abs(snk-rac)) + +print(s)" +p02554,s942011084,Wrong Answer,"N = int(input()) +mod = 10**9+7 +print(pow(10, N, mod) - (pow(9, N, mod) * 2 - pow(8, N, mod)))" +p03239,s416446735,Accepted,"n,T = map(int, input().split()) +m=1001 +for i in range(n): + c,t=map(int, input().split()) + if T>=t : + m=min(m,c) +print(""TLE"" if m==1001 else m) " +p02732,s768068320,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +cnt = [0] * (N+1) +for i in range(N): + cnt[A[i]] += 1 + +nsum = [cnt[n]*(cnt[n]-1)//2 for n in range(N+1)] +SUM = sum(nsum) + +for k in range(N): + kadd = cnt[A[k]] - 1 + print(SUM - nsum[A[k]] + kadd*(kadd-1)//2)" +p02664,s202491710,Accepted,"T = input() +print(T.replace('?', 'D')) +" +p03705,s238686239,Accepted,"n,a,b=map(int,input().split()) +n-=2;print(max(b*n-a*n+1,0))" +p02792,s154010140,Accepted,"n = int(input()) +count = 0 +l = [[0 for _ in range(10)] for _ in range(10)] +for i in range(1,n+1): + ii = str(i) + s = int(ii[0]) + t = int(ii[-1]) + l[s][t] += 1 +for i in range(1,9): + for j in range(i+1,10): + count += l[i][j]*l[j][i]*2 +for i in range(1,10): + count += l[i][i]*l[i][i] +print(count)" +p03150,s440037558,Accepted,"S = input() +l = len(S) +out = l - 7 +ans = 'NO' +for i in range(7): + s = S[:i] + S[i+out:] + if s == 'keyence': + ans = 'YES' +print(ans)" +p02786,s787542594,Accepted,"h = int(input()) +i = 1 +ans = 0 +while True: + if h==1: + ans += i + break + h = h//2 + ans += i + i *= 2 +print(ans)" +p02720,s276455502,Accepted,"K = int(input()) +table = [1,2,3,4,5,6,7,8,9] +for i in table: + if len(table) > K: + break + x = i % 10 + for j in range(max(0, x - 1), min(x + 2, 10)): + table.append(i * 10 + j) +print(table[K-1]) +" +p02682,s552659389,Accepted,"a,b,c,k=map(int, input().split()) +ans=0 +if a>=k: + print(k) + exit() +if b>=k-a: + print(a) + exit() +else: + print(a-(k-b-a)) + exit()" +p02922,s023189678,Accepted,"import math +a, b = list(map(int,input().split())) +x = math.ceil((b-1)/(a-1)) +print(x)" +p02595,s121529297,Wrong Answer,"n, d = map(int, input().split()) +count = 0 + +for i in range(n): + x, y = map(int, input(). split()) + if d^2 > x^2 + y^2: + count += 1 + +print(count) +" +p03059,s852581530,Accepted,"A,B,T=map(int,input().split()) +i=1 +result=0 +while A*i = B[i]: + a += B[i] + else: + a += A[i] + if (B[i] - A[i]) <= A[i + 1]: + A[i + 1] -= B[i] - A[i] + a += (B[i] - A[i]) + else: + a += A[i + 1] +print(a)" +p02677,s440642279,Accepted,"from math import pi, cos, sqrt + +a, b, h, m = map(int, input().split()) + +rad = abs((h+(m/60))/12 - m/60)*pi*2 +c = sqrt(a**2 + b**2 - 2*a*b*cos(rad)) + +print(c)" +p03605,s715558968,Accepted,"N = input() +if ""9"" in N: + print(""Yes"") +else: + print(""No"")" +p03293,s872558614,Accepted,"s = list(str(input())) +t = list(str(input())) +l = len(s) +for i in range(l): + if s == t: + print('Yes') + exit() + tmp = s[l-1] + s = s[:l-1] + s.insert(0, tmp) +print('No') +" +p02765,s606356973,Wrong Answer,"a,b = map(int,input().split()) + +c = a*b + +if c % 2 ==0: + print(""Even"") +else: + print(""Odd"") + +" +p02759,s811241890,Accepted,"import sys +import math +input = sys.stdin.readline + +#N, M, L = (int(i) for i in input().split()) +#ABC = [[int(i) for i in input().split()] for i in range(N)] +N = int(input()) + +print(math.ceil(N/2)) +" +p04045,s226734653,Accepted,"n, k = map(int, input().split()) +d = set(list(map(str, input().split()))) +for i in range(n, 10**6): + w = True + idx = 0 + i = str(i) + while idx < len(str(i)): + if i[idx] in d: + w = False + break + idx += 1 + if w: + print(i) + exit()" +p02987,s772754120,Accepted,"S = input() +A = 'Yes' +for i in range(4): + C = S.count(S[i]) + if C != 2: + A = 'No' + +print(A)" +p02731,s762426128,Accepted,"N = int(input()) +print((N / 3) ** 3) +" +p02618,s725376470,Accepted,"dur=int(input()) +c=list(map(int,input().split())) +d=[0]*26 +r=5 +for i in range(dur): + t=0 + s=list(map(int,input().split())) + m=-1<<64 + for j in range(26): + alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)]) + if alt>m: + m=alt + t=j + print(t+1) + d[t]=i+1 +" +p03627,s590057376,Wrong Answer,"N = int(input()) +ls = list(map(int,input().split())) + +unique_ls = list(reversed(list(set(ls)))) + +rectan_a = 0 +rectan_b =0 + +for i in range(len(unique_ls)): + if ls.count(unique_ls[i]) >=4: + rectan_a = unique_ls[i] + rectan_b = unique_ls[i] + break + elif (ls.count(unique_ls[i]) == 2) or (ls.count(unique_ls[i]) == 3): + if rectan_a ==0: + rectan_a = unique_ls[i] + else: + rectan_b = unique_ls[i] + break + else: + pass +print(rectan_a * rectan_b)" +p02555,s759613220,Accepted,"s = int(input()) +mod = 10**9 + 7 + +dp = [0]*(s+1) +dp[0] = 1 + +x = 0 +for i in range(1,s+1): + if i-3 >= 0: + x += dp[i-3] + x %= mod + dp[i] = x + +print(dp[s])" +p03438,s203392459,Wrong Answer,"N = int(input()) +a = list(map(int, input().split("" ""))) +b = list(map(int, input().split("" ""))) +plus_one, plus_two = 0, 0 +op_num = sum(b) - sum(a) + +for i in range(N): + if a[i] > b[i]: + plus_one = a[i] - b[i] + elif a[i] < b[i]: + plus_two += (b[i] - a[i] + 1) // 2 + plus_one += 1 if (b[i] - a[i]) % 2 == 1 else 0 + +if plus_one < op_num and plus_two < op_num: + print('Yes') +else: + print('No')" +p02882,s789925186,Wrong Answer,"import math +a, b, x = map(int, input().split()) +if a**2*b == x: + s = 0 +elif (a**2)*b/2 < x: + s = math.degrees(math.atan(2*a/(3*(b-(x/(a**2)))))) +else: + s = math.degrees(math.atan(2*x/(a*b**2))) +print(90-s)" +p02601,s215418098,Accepted,"def s(): return input() +def i(): return int(input()) +def S(): return input().split() +def I(): return map(int,input().split()) +def X(): return list(input()) +def L(): return list(input().split()) +def l(): return list(map(int,input().split())) +count = 0 +ans = ""No"" + +A,B,C = I() +K = i() + +while True: + if B > A or K == 0: + break + else: + B *= 2 + K -= 1 +while True: + if C > B or K == 0: + break + else: + C *= 2 + K -= 1 +if A < B and B < C: + ans = ""Yes"" +print(ans) + + + +" +p04012,s038761652,Accepted,"w=input() +ans=""Yes"" +for i in w: + if w.count(i)%2!=0: + ans=""No"" + break +print(ans)" +p02597,s672256552,Accepted,"import math +import sys +from itertools import permutations +input = sys.stdin.readline + +n=int(input()) +arr=list(input()) +if arr[-1]=='\n': + arr.pop() + +countW=0 +for i in range(n): + if arr[i]=='W': + countW+=1 + +ans=0 +for i in range(n-countW): + if arr[i]=='W': + ans+=1 + +print(ans)" +p02572,s537353796,Wrong Answer,"import itertools + +N = int(input()) +A = list(map(int,input().split())) + +sum=0 +mod = 1000000007 +for v in itertools.combinations(A, 2): + v0 = v[0]%mod + v1 = v[1]%mod + sum += v0*v1%mod +print(sum) +" +p02766,s871874186,Wrong Answer,"def resolve(): + n, k = map(int, input().split()) + div_val = k + i = 1 + while True: + if n / div_val <= 1: + print(i) + return + else: + div_val *= k + i += 1 + +resolve()" +p04020,s030801118,Accepted,"n = int(input()) +a = [0]*n +res = 0 +tmp = 0 +zero = False +for i in range(n): + s = int(input()) + a[i] = s + if s==0: + zero = True +if not zero: + print(sum(a)//2) + exit() + +for i in range(n): + if a[i]!=0: + tmp+=a[i] + else: + res+=tmp//2 + tmp = 0 + if i==n-1 and tmp>1: + res+=tmp//2 +print(res) +" +p02623,s538532502,Accepted,"N, M, K = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) + +a, b = [0], [0] +for i in range(N): + a.append(a[i] + A[i]) +for i in range(M): + b.append(b[i] + B[i]) + +ans, j = 0, M +for i in range(N + 1): + if a[i] > K: + break + while b[j] > K - a[i]: + j -= 1 + ans = max(ans, i + j) + +print(ans)" +p03665,s493724612,Accepted,"n, p = map(int, input().split()) +a = list(map(int, input().split())) + +odd = [i for i in a if i % 2 == 1] +even = [i for i in a if i % 2 == 0] +ecnt = pow(2, len(even)) +ocnt = pow(2, max(len(odd)-1,0)) +print(0 if (len(odd )== 0 and p == 1) else ecnt * ocnt) +" +p02766,s072141030,Accepted,"# coding:utf-8 + +import sys +import math +import time +#import numpy as np +import collections +from collections import deque +import queue +import copy + + +#X = str(input()).split() +#a = [int(x) for x in input().split()] + + +NK = str(input()).split() +N = int(NK[0]) +K = int(NK[1]) +ans = 1 + +for i in range(N): + if(N k: + break + while c[i] + d[j] > k: + j -= 1 + ans = max(ans, i + j) + +print(ans) +" +p03659,s213598013,Accepted,"N = int(input()) +A = list(map(int, input().split())) + +sum_A = sum(A) +tot = 0 +ans = float(""inf"") + +for i in range(N - 1): + tot += A[i] + ans = min(ans, abs(sum_A - tot - tot)) + +print(ans)" +p02695,s502883727,Accepted,"import itertools + +def main(): + n,m,q = tuple([int(t)for t in input().split()]) + + a = [[int(t)for t in input().split()]for _ in [0]*q] + + ans = [] + for lst in itertools.combinations_with_replacement(range(1,m+1),n): + t = 0 + for a_i,b_i,c_i,d_i in a: + t += d_i if lst[b_i-1]-lst[a_i-1]==c_i else 0 + ans.append(t) + + print(max(ans)) + + +if __name__ == ""__main__"": + main()" +p03455,s168089130,Accepted,"input = list(map(int, input().split())) + +a = input[0] * input[1] + +if (a%2 == 0): + print(""Even"") +else: + print(""Odd"") +" +p03136,s097790919,Accepted,"n = int(input()) +l = list(map(int,input().split())) +#print(l) +z = max(l) +#print(z) +if sum(l) - max(l) > max(l): + print('Yes') +else: + print('No') +" +p03284,s819184373,Wrong Answer,"a, b = map(int, input().split()) +if a/b ==0: + print(0) +else: + print(1)" +p03210,s599340107,Wrong Answer,"n=input() +if n in ""753"": + print(""Yes"") +else: + print(""No"") +" +p03759,s949508260,Accepted,"a,b,c = map(int,input().split()) + +if b-a == c-b: + print(""YES"") +else: + print(""NO"")" +p02838,s953510381,Wrong Answer,"N = int(input()) +C = {i:0 for i in range(60)} +A = input().split() +for i in range(N): + a = bin(int(A[i]))[2:] + n = len(a) + for j in range(n): + if a[j]==""1"": + C[n-1-j] += 1 +cnt = 0 +for i in range(20): + if C[i]>0: + cnt += C[i]*(N-C[i])*2**i +print(cnt)" +p03211,s548241497,Accepted,"s = list(input()) +n = len(s) +ans = 10**19 +for i in range(1, n-1): + a = int("""".join([s[i-1], s[i], s[i+1]])) + ans = min(abs(753-a), ans) +print(ans) +" +p03387,s442964758,Wrong Answer,"#coding: utf-8 +import math +import heapq +import bisect +import numpy as np +from collections import Counter +#from scipy.misc import comb + +A = list(map(int, input().split())) +A.sort() + +ans = (A[2]-A[1]) + (A[1]-A[0])//2 + (A[1]-A[0])%2 +print(ans)" +p03254,s498729257,Accepted,"n,x=map(int,input().split()) +a=list(map(int,input().split())) + +res=0 +i=0 +a.sort() + +while 0= x: + print(i+1) + break +" +p03262,s016018791,Accepted,"N, X = map(int, input().split()) +x_list=list(int(x)-X for x in input().split()) + +def gcd(a, b): + while b: + a, b = b, a%b + return a + +ans=0 +for x in x_list: + ans=gcd(ans, x) +print(abs(ans)) + + +" +p03417,s890121612,Wrong Answer,"def resolve(): + N,M=map(int,input().split()) + if N==1 or M==1: + print(N*M-2) + else: + print((N-2)*(M-2)) + +resolve()" +p04045,s490687046,Accepted,"a,n=map(int,input().split()) +b=input() +c=[] +for i in range(n): + c.append(int(b[2*i])) +flag=""F"" +while flag==""F"": + k=a + fflag=""T"" + while k>=1: + l=int(k%10) + for i in range(n): + if c[i]==l: + fflag=""F"" + break + k=int(k/10) + if fflag==""F"": + break + if fflag==""T"": + flag=""T"" + else: + a+=1 +print(a)" +p03693,s867465752,Wrong Answer,"r,g,b = map(int,input().split()) +print('Yes' if (10*g+b)%4==0 else 'No')" +p03745,s628138653,Accepted,"_, *A = map(int, open(0).read().split()) +ans = 1 +is_add = False +is_minus = False +tmp = A[0] +for a in A[1:]: + if tmp > a: + if is_add: + ans += 1 + is_add = False + else: + is_minus = True + elif tmp < a: + if is_minus: + ans += 1 + is_minus = False + else: + is_add = True + tmp = a +print(ans)" +p02847,s373306198,Accepted,"S=str(input()) +a=['SUN','MON','TUE','WED','THU','FRI','SAT'] +a=['SAT','FRI','THU','WED','TUE','MON','SUN'] +print(a.index(S)+1)" +p02831,s907992517,Wrong Answer,"A,B=map(int,input().split()) +num=1 +for i in range(1,min(A,B)//2): + if A%i==0 and B%i==0: + num*=i +print(num) +print(int(A*B/num))" +p02630,s566500889,Wrong Answer,"import sys +input = sys.stdin.readline + +N = int(input()) + +AAA = list(map(int, input().split())) + +Q = int(input()) + +goukei_AAA = sum(AAA) + +for i in range(0, Q): + BC = list(map(int, input().split())) + if not BC[0] in AAA: + print(goukei_AAA) + pass + else: + AAA = [BC[1] if m == BC[0] else m for m in AAA] + goukei_AAA = goukei_AAA + (AAA.count(BC[0]) * (BC[1] - BC[0])) + print(goukei_AAA) +" +p02973,s224677440,Accepted,"from collections import deque +from bisect import bisect_left + +n=int(input()) +a=[int(input()) for i in range(n)] + +d=deque() +for i in range(n): + b=bisect_left(d,a[i]) + if b==0: + d.appendleft(a[i]) + else: + d[b-1]=a[i] + +print(len(d)) +" +p03479,s831758965,Wrong Answer,"a,b=input().split() +a=int(a) +b=int(b) +c=b/a +i=1 +x=0 +while i= p[i]: + ans+=1 + x=min(x,p[i]) +print(ans)" +p02862,s805310958,Accepted,"x,y=map(int,input().split()) + +if (2*y-x)%3!=0 or (2*x-y)%3!=0 or 2*x-y<0 or 2*y-x<0: + ans=0 +else: + a=(2*y-x)//3 + b=(2*x-y)//3 + n=a+b + ans=1 + for i in range(min(a,b)): + ans*=(n-i) + ans%=(10**9+7) + ans*=pow(i+1,10**9+5,10**9+7) +print(ans%(10**9+7))" +p03457,s488472852,Accepted,"N = int(input()) +x = 0 +y = 0 +t = 0 +for _ in range(N): + ti, xi, yi = map(int, input().split()) + dist = abs(x-xi) + abs(y-yi) + flag = False + if dist % 2 == 0 and not t % 2 == ti % 2: + flag = True + elif not dist % 2 == 0 and t % 2 == ti % 2: + flag = True + if dist > ti - t or flag: + print('No') + exit() + x = xi + y = yi + t = ti + +print('Yes') +" +p02831,s183410189,Accepted,"import fractions + +a,b=map(int,input().split()) +print(int(a*b/fractions.gcd(a,b)))" +p03076,s009497223,Accepted,"last = 0 +answer = 0 +dishes = [] +dishes.append(int(input())) + +for i in range(1,5): + dish = int(input()) + dishes.append(dish) + if dish % 10 != 0 and dishes[last] % 10 > dish % 10: + last = i + + +for i in range(5): + if i == last: + answer += dishes[i] + else: + if dishes[i] % 10 == 0: + answer += dishes[i] + else: + answer += ((dishes[i]//10)+1)*10 + +print(answer)" +p02948,s775788160,Wrong Answer,"from heapq import heapify, heappop, heappush +N,M = map(int,input().split()) +A = [[] for _ in range(M+1)] +#HQ = [] +for i in range(N): + a,b = map(int,input().split()) + if a < M: + A[a].append(b) +#print(A) +ans = 0 +L = [] +for day in range(1,M+1): + for t in A[day]: + heappush(L,-t) + #print(L) + if not L: + continue + temp = heappop(L) + ans += -temp +print(ans) " +p03309,s949389970,Accepted,"n=int(input()) +a=list(map(int,input().split())) + +arr=sorted([a[i]-i-1 for i in range(n)]) + +if len(arr)%2==0: + tmp=[arr[len(arr)//2-1],arr[len(arr)//2]] +else: + tmp=[arr[len(arr)//2]] + +ans=10**20 +for b in tmp: + ans=min(ans,sum([abs(a[i]-b-i-1) for i in range(n)])) +print(ans)" +p03951,s617415527,Accepted,"n = int(input()) +s = input() +t = input() + +match_count = 0 +for i in range(n): + if s[i:] == t[:n-i]: + match_count = n-i + break +print(2*n - match_count)" +p02615,s428858796,Wrong Answer,"N = int(raw_input()) +A = (map(int, raw_input().split())) +A.sort(reverse=True) +ans = 0 +for i, x in enumerate(A): + if i: + ans += A[i-1] +print ans" +p03838,s110488097,Accepted,"x, y = map(int, input().split()) + +if 0 <= x and 0 <= y: + if x <= y: + res = abs(x - y) + elif y == 0: + res = abs(x - y) + 1 + else: + res = abs(x - y) + 2 +elif x < 0 and y <= 0: + if x <= y: + res = abs(x - y) + else: + res = abs(x - y) + 2 +else: + res = abs(abs(x) - abs(y)) + 1 + +print(res) +" +p03767,s513591974,Wrong Answer,"N = int(input()) +a = list(map(int,input().split())) + +a.sort() +ans = 0 +for i in range(N, 2 * N): + ans += a[i] +print(ans)" +p02726,s669682868,Accepted,"N, X, Y = list(map(int, input().split())) + +dist_cnt = [0]*N + +for i in range(1, N): + for j in range(i+1, N+1): + dist = min([j-i, abs(i - X) + abs(j - Y) + 1]) + dist_cnt[dist] += 1 + +for i in range(1, N): + print(dist_cnt[i])" +p03836,s744606092,Wrong Answer,"sx, sy, tx, ty = list(map(int, input().split())) + +dx = tx - sx +dy = ty - sy +d1 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D']*1 +d2 = ['L']*dx + ['D']*dy +d3 = ['D']*1 + ['R']*(dx+1) + ['U']*(dy+1) + ['L']*1 +d4 = ['U']*dy + ['R']*dx + +print(''.join(d1+d2+d3+d4)) +" +p02823,s406419415,Accepted,"import sys + +def I(): return int(sys.stdin.readline()) +def MI(): return map(int, sys.stdin.readline().split()) +def LI(): return list(map(int, sys.stdin.readline().split())) +def main(): + n, a, b = MI() + d = b - a + ans = 0 + if d%2: + temp = min(a-1, n-b) + ans = (d-1)//2 + temp + 1 + else: + ans = d//2 + print(ans) + +if __name__ == '__main__': + main()" +p02873,s081660431,Accepted,"s = input() + +right = [0]*(len(s)+1) +for i in range(len(s)): + if s[i] == '<': + right[i+1] = right[i] + 1 + +left = [0]*(len(s)+1) +for i in range(len(s)-1, -1, -1): + if s[i] == '>': + left[i] = left[i+1] + 1 + +ans = 0 +for i in range(len(s)+1): + ans += max(right[i], left[i]) + +print(ans)" +p02730,s519508146,Accepted,"def isstrong(s): + n = len(s) + if s != s[::-1]: return False + s1 = s[0:(n - 1)//2] + s2 = s[(n + 1) // 2:] + #print(s1) + #print(s2) + if s1 != s1[::-1]: return False + if s2 != s2[::-1]: return False + return True + +s = input() +if isstrong(s): + print('Yes') +else: + print('No') +" +p02695,s627678705,Accepted,"from itertools import combinations_with_replacement as cwd + +N, M, Q = map(int, input().split()) +A = list(cwd(range(1, M + 1), N)) +ABCD = [] + +for i in range(Q): + a, b, c, d = map(int, input().split()) + a, b = a - 1, b - 1 + ABCD.append([a, b, c, d]) + +res = 0 +for i in A: + tmp = 0 + for j in ABCD: + if i[j[1]] - i[j[0]] == j[2]: + tmp += j[3] + res = max(res, tmp) + +print(res) +" +p02552,s548615019,Wrong Answer,print(0) if input == '1' else print(1) +p04030,s715741234,Accepted,"S = input() + +ret = """" +for i in S: + if i != ""B"": + ret += i + else: + ret = ret[:-1] + +print(ret)" +p02712,s213907369,Wrong Answer,"N = int(input()) +list = [] +for i in range(N+1): + if i % 3 == 0 and i % 5 == 0: + list.append(i) + elif i % 3 == 0: + list.append(i) + elif i % 5 == 0: + list.append(i) +print(sum(list))" +p03761,s802403249,Accepted,"from collections import defaultdict + +n=int(input()) +d=[defaultdict(int) for i in range(n)] + +for i in range(n): + s=input() + for g in range(len(s)): + d[i][s[g]]+=1 + + +ans="""" +char=[chr(i) for i in range(97, 97+26)] + +for c in char: + MIN=10**10 + for i in range(n): + MIN=min(d[i][c],MIN) + ans+=c*MIN +print(ans) +" +p03323,s819473031,Accepted,"arr = input().split() +arr = list(map(int, arr)) + +if arr[0] <= 8 and arr[1] <= 8: + print('Yay!') +else: + print(':(') +" +p03861,s105160691,Accepted,"a, b, x = map(int, input().split()) + +B = b//x +A = (a-1)//x +print(B-A)" +p02802,s181767980,Wrong Answer,"n,m=map(int,input().split()) +acf,waf=[0]*n,[0]*n +ac,wa=0,0 +for i in range(m): + x,y=input().split() + x=int(x) + if y=='AC': + ac+=1 + wa+=waf[x-1] + acf[x-1]+=1 + else: + waf[x-1]+=1 +print(ac,wa) +" +p03475,s125444207,Wrong Answer,"N = int(input()) +CSF = [list(map(int, input().split())) for _ in range(N-1)] + +ans = 0 +memo = {} +memoset = set() +def dfs(i, time): + if i==N-1: + return time + c, s, f = CSF[i] + if time= 3200 else ""red"")" +p02661,s996001989,Wrong Answer,"N = int(input()) +A = [] +B = [] +for i in range (0,N): + a, b = map(int, input().split()) + A.append(a) + B.append(b) + +A = sorted(A) +B = sorted(B) + +if N%2 ==1: + print(B[int((N+1)/2)-1]-A[int((N+1)/2)-1]+1) +else: + print(B[int(N/2)]+A[int(N/2)]-B[int(N/2)-1]-A[int(N/2)-1]+1)" +p03943,s692487907,Accepted,"a, b, c = map(int, input().split()) + +if a+b==c or b+c==a or a+c==b: + print('Yes') +else: + print('No')" +p03494,s272688993,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +ans = 0 +for i in range(200): + for j in range(n): + if a[j] %2 != 0: + print(ans) + exit() + ans += 1 +print(ans)" +p03761,s889784474,Accepted,"N = int(input()) +char_dict = {} +s_li = [] +ans = '' +for i in range(N): + s_li.append(input()) +for s in s_li: + for c in [chr(ord('a') + i) for i in range(26)]: + cnt = s.count(c) + if c not in char_dict: + char_dict[c] = cnt + else: + char_dict[c] = min(cnt, char_dict[c]) +for k, v in char_dict.items(): + ans += k * v +print(ans) +" +p02993,s102372668,Accepted,"s = input() + +ans = 'Bad' if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else 'Good' +print(ans) +" +p02996,s221982543,Accepted,"n = int(input()) +l = [] +for i in range(n): + a, b = map(int, input().split()) + l.append((a,b)) +nl = sorted(l,key=lambda x: x[1]) +t = 0 +for a, b in nl: + t += a + if t > b: + print('No') + exit() +print('Yes')" +p02831,s394360077,Wrong Answer,"A, B = list(map(int, input().split())) + +print(A*B)" +p02628,s092538272,Accepted,"N, K = map(int, input().split()) +p = list(map(int, input().split())) + +p = sorted(p) + +ans = 0 + +for i in range(K): + ans += p[i] + +print(ans)" +p02697,s706246025,Accepted,"def main(): + N, M = map(int, input().split()) + + pairs = [] + a = 1 + for d in range(M, 0, -2): + pairs.append((a, a + d)) + a += 1 + + a = 1 + M + 1 + for d in range(M - 1, 0, -2): + pairs.append((a, a + d)) + a += 1 + + for pair in pairs: + print(*pair) + + +if __name__ == '__main__': + main() +" +p03494,s179676369,Wrong Answer,"n = int(input()) +a = list(map(int, input().split())) +cnt = 0 + +for i in range(n): + for j in range(len(a)): + if(a[j] % 2 == 0): + a[j] = a[j] //2 + else: + quit() + cnt += 1 +print(cnt)" +p02748,s200974999,Accepted,"a, b, m = map(int, input().split()) +al = list(map(int, input().split())) +bl = list(map(int, input().split())) +ansl = [] +for i in range(m): + x, y, c = map(int, input().split()) + ansl.append(al[x-1] + bl[y-1] - c) +ansl.append(min(al) + min(al)) +print(min(ansl))" +p03145,s954125489,Accepted,"a,b,c=map(int,input().split()) +print(int(a*b/2))" +p03605,s411304321,Wrong Answer,"import random +a=input() +kekka=['Yes','No'] +print(random.choice(kekka))" +p03106,s322849631,Wrong Answer,"A, B, K = map(int, input().split()) + +k = 0 +for i in range(1, 100): + if A%i == B%i == 0: + k += 1 + if k == K: + print(i) + quit()" +p03962,s870468199,Accepted,"arr =list(map(int,input().split())) + +b = set(arr) + +print(len(b)) + +#if a!=b and a!=c: + #print(3) +#elif a==b and a!=c: + #print(2) +#elif a==c and a!=b: + #print(2) +#elif b==c and b!=a: + #print(2) +#else: + #print(1)" +p02744,s424203842,Wrong Answer,"#!/usr/bin/env python + + +def plse1(s, i): + if i == 0: + return s + if s[i] > s[i - 1]: + s = plse1(s, i - 1) + s[i] = 0 + else: + s[i] += 1 + return s + + +n = int(input()) +ss = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] + +s = [0] * n +while True: + string = '' + for i in range(n): + string += ss[s[i]] + print(string) + s = plse1(s, n - 1) + if s == [0] * n: + break +" +p02833,s613914435,Wrong Answer,"N = int(input()) +if N % 2 == 1: + print(0) + quit() +N /= 2 +res = 0 +while N: + print(N) + res += int(N / 5) + N = int(N / 5) +print(res)" +p03835,s248201557,Accepted,"import sys +def S(): return sys.stdin.readline().rstrip() + + +K,S = map(int,S().split()) + +ans = 0 +for i in range(K+1): + for j in range(K+1): + if 0 <= S-i-j <= K: + ans += 1 + +print(ans)" +p02918,s938787434,Accepted,"import copy + +n, k = map(int,input().split()) +s = ['R'] + list(input()) + ['L'] + +cnt = 0 +for i in range(1,n+1): + if s[i] == 'L' and s[i-1] == 'L': + cnt += 1 + if s[i] == 'R' and s[i+1] == 'R': + cnt += 1 +# print(cnt) +while k > 0 and cnt < n-1: + if n- 1 - cnt > 1: + cnt += 2 + elif n- 1 - cnt > 0: + cnt += 1 + k -= 1 +print(cnt) +" +p02689,s816865296,Accepted,"n,*t=map(int,open(0).read().split()) +r=[0]+[1]*n +for a,b in zip(t[n+1::2],t[n+2::2]):r[a]&=t[a]>t[b];r[b]&=t[b]>t[a] +print(sum(r))" +p03817,s573345142,Accepted,"x=int(input()) +ans=2*(x//11) +x-=11*(x//11) +if x==0: + print(ans) +elif x<=6: + print(ans+1) +else: + print(ans+2)" +p03427,s141385553,Wrong Answer,"# https://atcoder.jp/contests/agc021/tasks/agc021_a + +n = input() +if int(n) >= int(n[0] + '9' * (len(n) - 1)): + ans = 9 * len(n) +else: + ans = int(n[0]) - 1 + 9 * (len(n) - 1) +print(ans)" +p03360,s563147245,Accepted,"a,b,c = map(int,input().split()) +k = int(input()) +for i in range(k): + if(a >= b and a >= c): a *= 2 + elif (b >= a and b >= c): b *= 2 + elif (c >= a and c >= b): c *= 2 +print(a + b + c)" +p04020,s962116832,Accepted,"N = int(input()) +A = [int(input()) for _ in range(N)] +ans = 0 +for i in range(N-1): + ans += A[i] // 2 + if A[i] % 2 != 0: + if 0 < A[i+1]: + ans += 1 + A[i+1] -= 1 +ans += A[N-1] // 2 +print(ans)" +p02570,s430148536,Wrong Answer,"D,T,S = map(int,input().split()) + +print(""Yes"" if D-T*S < 0 else ""No"") +" +p03785,s006946037,Accepted,"N, C, K = map(int,input().split()) +T = [] +ans = 0 #バス内の人数 +num = 1 #バスの台数 +for i in range(N): + ans = int(input()) + T.append(ans) +T = sorted(T) +ans = 0 +S = T[0] + K #バスの発車時刻 +for i in T: + if i <= S and ans < C: + ans += 1 + else: + num += 1 + S = i + K + ans = 1 +print(num) +" +p02795,s735731418,Accepted,"H = int(input()) +W = int(input()) +N = int(input()) +if H >= W: + if N % H == 0: + print(N // H) + else: + print(N // H + 1) +else: + if N % W == 0: + print(N // W) + else: + print(N // W + 1)" +p02933,s055708083,Accepted,"a = int(input()) +s = input() + +if a >= 3200: + print(s) +else: + print('red')" +p03041,s890765444,Accepted,"N, K = map(int,input().split()) +S = list(input()) +S[K-1] = S[K-1].lower() + +print(''.join(S))" +p03274,s492934019,Accepted,"n, k = map(int, input().split()) +x = list(map(int, input().split())) + +ans = [] +for i in range(n - k + 1): + left = x[i] + right = x[i + k - 1] + if abs(left) > abs(right): + ans.append(abs(right) + abs(left - right)) + else: + ans.append(abs(left) + abs(right - left)) + +print(min(ans))" +p03281,s111871259,Accepted,"import bisect,collections,copy,heapq,itertools,math,string +import sys +def I(): return int(sys.stdin.readline().rstrip()) +def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) +def S(): return sys.stdin.readline().rstrip() +def LS(): return list(sys.stdin.readline().rstrip().split()) + +n = I() +cnt = 0 +for i in range(1, n+1, 2): + divcnt = 0 + for j in range(1, i+1, 2): + if i % j == 0: + divcnt += 1 + if divcnt == 8: + cnt += 1 +print(cnt)" +p02677,s410073809,Accepted,"import numpy as np +a, b, h, m = map(int, input().split()) +h_a = ((h % 12) + m / 60)*360 / 12 +m_b = ((m % 60)*360/60)%360 +angle = min(np.abs(h_a - m_b), 360 - np.abs(h_a - m_b)) +print(np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.radians(angle))))" +p02847,s925311135,Wrong Answer,"input_date_list = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] +S = input() +today_date_list = ['日', '月', '火', '水', '木', '金', '土'] +s1 = input_date_list.index(S) +today_date = (today_date_list[s1]) +s2 = 7 - s1 +print(""今日は{0}曜日です。"".format(today_date)+""次の日曜日は{0}日後です"".format(s2)) +" +p04045,s356924720,Accepted,"N, _ = list(map(int, input().split())) +d = set(list(input().replace("" "", """"))) + +for i in range(N,10*N+1): + n = str(i) + ns = set(list(n)) + flg = False + for t in ns: + if t in d: + flg = True + break + if flg == False: + print(n) + exit() +print(0)" +p02702,s206732957,Accepted,"import sys +input = sys.stdin.readline +from collections import * + +S = input()[:-1] +cnt = defaultdict(int) +cnt[0] = 1 +ans = 0 +now = 0 + +for i in range(len(S)-1, -1, -1): + now = (int(S[i])*pow(10, len(S)-1-i, 2019)+now)%2019 + ans += cnt[now] + cnt[now] += 1 + +print(ans)" +p03059,s869889437,Wrong Answer,"A,B,T=map(int,input().split());print(T/A*B)" +p02952,s515560680,Wrong Answer,"n = int(input()) +cnt = 0 +for i in range(1, n + 1): + if len(str(n)) % 2: + cnt += 1 +print(cnt)" +p02684,s371855295,Accepted,"N, K = map(int, input().split()) +A = [1] + list(map(int, input().split())) + +p = 1 +points = [p] +visited = set([p]) + +for _ in range(N): + p = A[p] + if p in visited: + break + points.append(p) + visited.add(p) + +idx = points.index(p) + +if idx > K: + print(points[K]) + exit() + +cycle = points[idx:] + +print(cycle[(K - idx) % len(cycle)])" +p02731,s368763265,Accepted,"import sys + +stdin = sys.stdin + +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(stdin.readline().rstrip()) +nm = lambda: map(int, stdin.readline().split()) +nl = lambda: list(map(int, stdin.readline().split())) + +l = ni() + +print(l**3/27) +" +p03345,s661863092,Accepted,"a,b,c,k =map(int,input().split()) +ans = 0 +if k % 2 == 1: + ans = b-a +else: + ans = a-b + +if abs(ans)>10**18: + print(""Unfair"") +else: + print(ans)" +p02678,s012662363,Accepted,"from collections import deque +N,M = map(int,input().split()) +cnct = [[] for i in range(N+1)] +for _ in range(M): + A,B = map(int,input().split()) + cnct[A].append(B) + cnct[B].append(A) +Q = deque() +Q.append(1) +ans = [0]*(N+1) +vstd = [0]*(N+1) +while Q: + temp = Q.popleft() + for a in cnct[temp]: + if vstd[a] == 0: + ans[a] = temp + vstd[a] = 1 + Q.append(a) +print('Yes') +for a in ans[2:]: + print(a)" +p02665,s464220809,Accepted,"n=int(input()) +a=list(map(int,input().split())) +k=sum(a) +if n==0: + print(1 if a[0]==1 else -1) + exit() +ans=1 +e=1 +for i in range(n): + e-=a[i] + k-=a[i] + if e<0: + print(-1) + exit() + elif e==0 and k>0: + print(-1) + exit() + if 2*e b: + cb += a - b + +if c < max(ca, cb): + print('No') +else: + print('Yes') +" +p03774,s770963443,Wrong Answer,"n,m=map(int,input().split()) +a=[list(map(int,input().split())) for i in range(n)] +b=[list(map(int,input().split())) for i in range(m)] +for i in a: + cnt=2*(10**16) + ans=0 + for j in range(len(b)): + if abs(i[0]*b[j][0])+ abs(i[1]*b[j][1]) w[1]: + print(""No"") + exit() + now+=w[0] +print(""Yes"")" +p03814,s403008888,Accepted,"s = input() +a = 0 +z = 0 +for i in range(len(s)): + if s[i]==""A"": + a = i + break +for i in range(len(s)-1,-1,-1): + if s[i]==""Z"": + z = i + break +print(z-a+1)" +p02683,s532075726,Accepted,"def MI(): return map(int, input().split()) +def LI(): return list(map(int, input().split())) +N,M,X=MI() +List=[] +for i in range(N): + CA=LI() + List.append(CA) +ans=-1 +for i in range(1<>j): + cost+=List[j][0] + for k in range(M): + tmp[k]+=List[j][k+1] + if min(tmp)>=X: + if ans==-1: + ans=cost + else: + ans=min(ans,cost) +print(ans) " +p03105,s984868478,Accepted,"A, B, C = map(int, raw_input().split()) + +sum = B/A +if sum > C: + print C +else: + print sum +" +p02555,s663462577,Accepted,"S = int(input()) +MOD = 1_000_000_007 + +t = [0, 0, 1] +f = 0 if S <= 2 else 1 +for i in range(S - 3): + f = t[0] + 1 + f %= MOD + t = t[1:3] + [(t[2] + f) % MOD] +print(f) +" +p03221,s112430810,Wrong Answer,"n,m = map(int,input().split()) +py = [list(map(int,input().split()))+[_] for _ in range(m)] +py.sort(key = lambda py:py[1]) +flag = py[0][0] +flag_2 = 1 +for i in range(m): + if flag != py[i][0]: + flag = py[i][0] + flag_2 = 1 + py[i][0] = (6-len(str(py[i][0])))*""0""+str(py[i][0]) + py[i][1] = (6-len(str(flag_2)))*""0""+str(flag_2) + flag_2 += 1 +py.sort(key = lambda py:py[2]) +for j in range(m): + print("""".join(py[j][:2]))" +p02729,s902175496,Accepted,"N, M = [int(x) for x in input().split("" "")] +print(int((N*(N-1)+M*(M-1))/2))" +p03254,s343898198,Accepted,"N,X = list(map(int, input().split())) +a = list(map(int, input().split())) +a = sorted(a) +m = sum(a) +count = 0 +S=0 +if m == X: + print(N) +elif m < X: + print(N-1) +elif a[0] > X: + print(0) +else: + for i in a: + if S <= X: + S = S + i + count = count + 1 + else: + print(count-1)" +p02700,s486843572,Accepted,"a, b, c, d = map(int, input().split()) + +while a>0 and c>0: + c-=b + a-=d + +if c<=0: + print('Yes') +else: + print('No') " +p02820,s787714206,Accepted,"N, K = map(int, input().split()) +R, S, P = map(int, input().split()) +T = list(input()) + + +ans = 0 +commands = [''] * N +for i, t in enumerate(T): + if t == 'r': + command = 'p' + point = P + + elif t == 's': + command = 'r' + point = R + + elif t == 'p': + command = 's' + point = S + + if (i - K >= 0) and (commands[i - K] == command): + command = '' + point = 0 + + ans += point + commands[i] = command + +print(ans) +" +p03385,s545438721,Wrong Answer,"arr=str(input()) +a = len([1 for x in arr if x=='a']) +b = len([1 for x in arr if x=='b']) +c = len([1 for x in arr if x=='c']) +if a+b+c == 3: + print('Yes') +else: + print('No') +" +p02811,s315638757,Wrong Answer,"k,x = map(int,input().split()) +print(""Yes"" if k * 500 <= x else ""No"")" +p03773,s633966012,Accepted,"a, b = map(int, input().split()) +print((a + b) % 24)" +p02555,s046628533,Wrong Answer,"S = int(input()) +MOD = 10**9+7 +fact = [1] +for i in range(1, S+1): + fact.append(fact[-1]*i % MOD) +ifact = [None]*(S+1) +ifact[-1] = pow(fact[-1], MOD-2, MOD) +for i in range(S, 0, -1): + ifact[i-1] = ifact[i]*i % MOD +def comb(n, k): + if n <= 0: + return 0 + return (fact[n]*ifact[n-k]*ifact[k]) % MOD +ans = 0 +for i in range(1, S): + if S<3*i: + break + ans = (ans+comb(S-2*i-1, i-1)) % MOD +print(ans)" +p02771,s619391692,Wrong Answer,"x,y,z = map(int, input().split()) + +if (x == y and y != z) or (x==z and y !=z): + print(""Yes"") +else: + print(""No"")" +p02866,s477185945,Accepted,"import collections +N=int(input()) +D=list(map(int,input().split())) +mod=998244353 +if D[0]!=0: + print(0);exit() + +D=collections.Counter(D) +if D[0]!=1: + print(0);exit() +ans=1 +for i in range(1,len(D)): + ans*=pow(D[i-1],D[i],mod) + ans%=mod +print(ans)" +p02933,s674299322,Accepted,"def main(): + # n,m = map(int,input().split()) + # n,k = map(int,input().split()) + # n = int(input()) + # a = list(map(int,input().split())) + # rsp = list(str(input())) + # l = [list(map(int, input().split())) for _ in range(n)] + # s = list(s) + + a = int(input()) + s = str(input()) + + if a >= 3200: + print(s) + else: + print(""red"") + + + +if __name__ == '__main__': + main()" +p03495,s256854339,Accepted,"import collections + +n,k = map(int, input().split()) +a = list(map(int, input().split())) + +c=collections.Counter(a) + +ans=0 + +all_balls = list(c.values()) +all_balls.sort() + +for i in range(len(c)-k): + ans += all_balls[i] +print(ans)" +p02957,s561421809,Wrong Answer,"a,b=map(int,input().split()) +print((a+b)/2 if (a+b)%2==0 else ""IMPOSSIBLE"")" +p03695,s984367341,Accepted,"import sys + +n, *a = map(int, sys.stdin.read().split()) + +def main(): + cnt = [0] * 9 + for x in a: + cnt[min(x, 3200) // 400] += 1 + mi = 0 + for x in cnt[:8]: + if x: mi += 1 + ma = mi + cnt[8] + mi = max(1, mi) + print(mi, ma) + +if __name__ == '__main__': + main()" +p02664,s180386139,Accepted,"t = input() +n = len(t) + +print(t.replace('?', 'D'))" +p02899,s581644132,Accepted,"N=int(input()) +arr=list(map(int,input().split())) +brr=[] + +for i in enumerate(arr): + brr.append(i) +#print(brr) + +brr.sort(key=lambda x:x[1]) + +for i in brr: + print(i[0]+1) +" +p02909,s738365283,Wrong Answer,"a=input() +n=['Sunny','Cloudy','Rainy'] +print(2-n.index(a))" +p03797,s501003656,Wrong Answer,"#!/usr/bin/env pytHon3 +# -*- coding: utf-8 -*- + + +def main(): + N, M = map(int, input().split()) + + if M >= N * 2: + result = N + M -= N * 2 + else: + result = 0 + + print(M // 4 + result) + + +if __name__ == ""__main__"": + main() +" +p03035,s427513610,Wrong Answer,"a,b = map(int,input().split()) +if a <= 5: + print(0) +elif a <= 12: + print(b/2) +else: + print(b)" +p04030,s277246909,Accepted,"def main(): + s = input() + + ans = '' + b = 0 + for c in reversed(s): + if c == 'B': + b += 1 + else: + if b: + b -= 1 + continue + ans = c + ans + print(ans) + + +if __name__ == '__main__': + main() +" +p02959,s478350229,Accepted,"N=int(input()) +A=list(map(int,input().split())) +B=list(map(int,input().split())) +Max=0 +for i in range(N): + if A[i]>=B[i]: + Max+=B[i] + else: + B[i]-=A[i] + if A[i+1]>=B[i]: + A[i+1]-=B[i] + Max+=(A[i]+B[i]) + else: + Max+=(A[i]+A[i+1]) + A[i+1]=0 +print(Max)" +p03282,s511005216,Wrong Answer,"s = input() +k = int(input()) +m = 0 +for i in s: + if i==1: + m += 1 + else: + break +if m>=k: + print(1) +else: + for i in s: + if i!=1: + print(i) + break" +p02608,s321733242,Accepted,"from sys import stdin +import sys +import math +import random +from decimal import Decimal +import itertools as it + +N = int(input()) +# for i in range(1,N+1): +f = [0 for i in range(N)] +# print(f) +for x in range(1, 101): + x2 = x**2 + for y in range(1, 101): + y2 = y**2 + for z in range(1, 101): + a = x2+y2+z**2+x*y+y*z+x*z + if a <= N: + f[a-1] += 1 + else: + break +for i in f: + print(i) +" +p02847,s219802776,Accepted,"week = ['','SAT','FRI','THU','WED','TUE','MON','SUN'] + +S = input() + +print(week.index(S))" +p03962,s968775399,Accepted,"l=input().split() +print(len(set(l)))" +p03617,s210092625,Accepted,"Q, H, S, D = map(int, input().split()) +N = int(input()) +n = N // 2 * 2 +ans = min(n * Q * 4, n * H * 2, n * S, n * D // 2) +if N % 2 == 1: + ans += min(Q * 4, H * 2, S) +print(ans)" +p02601,s737492639,Wrong Answer,"R, G, B = list(map(int, input().split())) +K = int(input()) + +def f(R,G,B): + if RB: + return 2 + else: + return 3 + +c = 0 +fl = 0 + +while c <= K: + c +=1 + if f(R,G,B)==1: + fl = 1 + c = K+1 + elif f(R,G,B)==2: + B = B*2 + else: + G = G*2 + +if fl == 0: + print(""No"") +else: + print(""Yes"")" +p03760,s583511857,Wrong Answer,"o = input() +e = input() +p = """" +for o, e in zip(o, e): + p += (o + e) + +print(p)" +p03721,s233721759,Wrong Answer,"n,k = map(int,input().split()) +for i in range(n): + a,b = map(int,input().split()) + k -= b + if k <= 0: + print(a) + break" +p02779,s563300659,Accepted,"N=int(input()) +A=input().split() +A = [int(a) for a in A] + +A.sort() + +count=True + +for i in range(N-1): + if A[i]==A[i+1]: + count=False + break + +if count: + print(""YES"") +else: + print(""NO"")" +p02661,s254228187,Accepted,"from statistics import median as m +n=int(input()) +a=[0]*n +b=[0]*n +for i in range(n): + x,y=map(int,input().split()) + a[i]=x + b[i]=y +x=m(a) +y=m(b) +if n%2==0: + x*=2 + y*=2 +print(int(y-x+1))" +p03127,s587253119,Accepted,"import fractions +N = int(input()) +A = list(map(int,input().split())) +gcd = fractions.gcd(A[0],A[1]) +for i in range(1,N): + gcd = fractions.gcd(gcd,A[i]) +print(gcd)" +p03162,s798144581,Accepted,"n=int(input()) +a=[0]*n +b=[0]*n +c=[0]*n +for i in range(n): + a[i],b[i],c[i]=map(int,input().split()) + +dp=[[0,0,0] for _ in range(n+1)] +for i in range(1,n+1): + dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i-1] + dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i-1] + dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i-1] + +print(max(dp[n]))" +p03797,s755775030,Accepted,"n, m = map(int,input().split()) + +#sがあればcを可能な限り使う + +if n == 0: #sが無かったら + ans = m//4 #c4個につき1個作れる + +elif m == 0: #cが無かったら + ans = 0 #1個も作れない + +elif n*2 <= m: #cを全部使ってもcが余るもしくはぴったりの場合 + ans = n + (m-2*n)//4 #sを使い切り、余ったcで何個か作る + +elif n*2 > m: #Sが余る場合 + ans = m//2 + +print(ans)" +p02773,s442014052,Accepted,"Nu=int(input()) +dic={} +ls=[] +maxd=0 +for i in range(Nu): + tmp=input() + if tmp in dic: + dic[tmp]=dic[tmp]+1 + maxd=max(dic[tmp],maxd) + else: + dic[tmp]=0 +for k,v in dic.items(): + if v==maxd: + ls.append(k) +ls.sort() +for x in ls: + print(x)" +p02639,s273231339,Wrong Answer,"n = map(int,input().split()) + +for i,num in enumerate(n): + if num == 0: + print(i)" +p03038,s832778433,Accepted,"from sys import exit + +N, M = map(int, input().split()) +A = list(map(int, input().split())) +BC = [] +for _ in range(M): + BC.append(tuple(map(int, input().split()))) +BC.sort(key=lambda x: -x[1]) +A.sort() + +i = 0 +for b, c in BC: + for x in range(b): + if i < N and A[i] < c: + A[i] = c + i += 1 + else: + print(sum(A)) + exit() +print(sum(A)) +" +p02678,s516747936,Accepted,"from collections import deque + +n,m = list(map(int, input().split())) +put = [1]*(n+1) + +ab = [[] for i in range(n+1)] +for i in range(m): + a,b = map(int, input().split()) + ab[a].append(b) + ab[b].append(a) + +q = deque([1]) +flg = [-1]*n +flg[0] = 0 + +while q: + item = q.popleft() + for i in ab[item]: + if put[i]: + flg[i-1]=item + q.append(i) + put[i]=0 + +if -1 in flg: + print(""No"") + exit() + +print(""Yes"") +for i in range(1,len(flg)): + print(flg[i])" +p02909,s431798179,Accepted,"import sys + +# S = input() +# N, M = map(int, input().split()) +# nums = list(map(int, input().split())) +# nums_2d = [list(map(int, input().split())) for _ in range(N)] + + +def main(): + S = input() + + weathers = [""Sunny"", ""Cloudy"", ""Rainy"", ""Sunny""] + + idx = weathers.index(S) + + print(weathers[idx+1]) + + +if __name__ == '__main__': + main() +" +p02783,s061870120,Accepted,"import math + +i, j = map(int, input().split()) + +print(math.ceil(i / j))" +p02759,s026038014,Wrong Answer,"import sys +import math + +for line in sys.stdin.readline(): + n = float(line.rstrip()) + ans = math.ceil(n / 2) + print(ans, end="""") + break +" +p02647,s561331407,Accepted,"n,k,*l=map(int,open(0).read().split()) +for _ in range(min(k,99)): + s=[0]*(n+1) + for i in range(n): + s[max(i-l[i],0)]+=1 + s[min(i+l[i]+1,n)]-=1 + l[0]=min(s[0],n) + for i in range(1,n): + l[i]=min(l[i-1]+s[i],n) +print(*l)" +p03835,s072747893,Accepted,"import sys +input = sys.stdin.readline + +K, S = map(int, input().split()) + +# X + Y = A +# Z = S - A +ans = 0 +for A in range(2*K+1): + Z = S - A + if 0 <= Z and Z <= K: + for X in range(K+1): + Y = A - X + if 0 <= Y and Y <= K: + ans += 1 +print(ans)" +p03796,s822858934,Accepted,"M = 1000000007 +n=int(input()) +f = 1 +for i in range(1, n + 1): + f = (f * i) % M +print(f)" +p03254,s689074902,Accepted,"n,x=map(int,input().split()) +a=sorted([int(i)for i in input().split()]) +res=0 +if sum(a)==x: + res=n +else: + for i in range(n): + if sum(a[:i])<=x:res=i +print(res)" +p02687,s503834205,Wrong Answer,"S = input() + +if S is ""ABC"": + print(""ARC"") +else: + print(""ABC"")" +p02600,s860401862,Accepted,"X = int(input()) +print(10 - X // 200) +" +p02780,s541186172,Wrong Answer,"import numpy as np +N, K = map(int, input().split("" "")) +p = np.array(list(map(int, input().split("" "")))) +ex = np.array([(i + 1) / 2 for i in p]) +ans = np.sum(ex[0: K]) +max_ans = ans +for i in range(K, N): + diff = ex[i] - ex[i - K] + ans += diff + if diff > 0: + max_ans = ans +print(max_ans)" +p02823,s617556824,Accepted,"N, A, B = map(int, input().split()) + +if (B - A) % 2 == 0: + print((B - A) // 2) +else: + # Aが左に到着 + ans1 = 0 + ans1 += A - 1 + 1 + a = 1 + b = B - A + ans1 += (b - a) // 2 + + # Bが右に到着 + ans2 = 0 + ans2 += N - B + 1 + a = A + (N - B + 1) + b = N + ans2 += (b - a) // 2 + + ans = min(ans1, ans2) + print(ans) +" +p02933,s717667979,Accepted,"a=int(input()) +s=input() +if a>=3200:print(s) +else:print(""red"")" +p02935,s324792640,Accepted,"n = int(input()) +v = list(map(int, input().split())) + +v.sort() + +res = (v[0] + v[1]) / 2 +for i in range(2, n): + res = (res + v[i]) / 2 + +print(res)" +p03379,s633093924,Accepted,"n = int(input()) +li = list(map(int,input().split())) +lee = len(li) +sorted_li = sorted(li) +mid = sorted_li[lee//2] +mid_mae = sorted_li[lee//2-1] +tmp = mid +for l in li: + if l < mid: + print(mid) + else: + print(mid_mae)" +p03161,s728502709,Wrong Answer,"N,K = [int(x) for x in input().split()] +h = [int(x) for x in input().split()] +DP = [100000000]*N +DP[0] = 0 +DP[1] = abs(h[0] - h[1]) +for i in range(2,N): + for j in range(1,min(K+1,i+1)): + DP[i] = min(DP[i],DP[i-j] + abs(h[i]-h[i-j])) +print(DP[N-1])" +p03456,s029628485,Accepted,"import math +def main(): + a,b = list(map(str,input().split())) + num=int(a+b) + if math.sqrt(num)%1==0: + print(""Yes"") + else: + print(""No"") +main() +" +p02959,s016709735,Accepted,"n = int(input()) +a_lst = list(map(int,input().split())) +b_lst = list(map(int,input().split())) +monster = 0 + +for i in range(n): + a1 = a_lst[i] + a2 = a_lst[i+1] + b1 = b_lst[i] + tmp = b1-a1 + + monster += min(a1,b1) + if tmp>0: + if a2-tmp<=0: + monster += a2 + a_lst[i+1] = 0 + else: + monster += tmp + a_lst[i+1] -= tmp + +print(monster)" +p03680,s785046801,Wrong Answer,"n = int(input()) +a = [int(input()) for i in range(n)] + +b = a[0] +cnt = 1 + +while b != 2 and cnt <= 1: + b = a[b-1] + cnt += 1 +if b == 2: + print(cnt) +else: + print(-1) +" +p03062,s589111579,Wrong Answer,"n=int(input()) +a=[int(i) for i in input().split()] +for i in range(3): + for j in range(n-1): + x=a[j]+a[j+1] + if x<0: + a[j]*=-1 + a[j+1]*=-1 +print(sum(a))" +p03944,s364172167,Accepted,"W, H, N = map(int, input().split()) +p = 0 +q = W +r = 0 +s = H +for i in range(N): + x, y, a = map(int, input().split()) + if a == 1: + p = max(p, x) + elif a == 2: + q = min(q, x) + elif a == 3: + r = max(r, y) + else: + s = min(s, y) +print(max(q - p, 0) * max(s - r, 0))" +p02639,s111064503,Accepted,"x= map(int,input().split()) +a = 1 +for i in x: + if i == 0: + print(a) + a+=1" +p03145,s052206633,Accepted,"x, y, z = map(int, input().split()) +print(x * y // 2) " +p03624,s669285502,Accepted,"S = input() +for s in [chr(ord(""a"")+i) for i in range(26)]: + if not s in S: + print(s) + exit() + +print(""None"")" +p03778,s857561223,Wrong Answer,"#!/usr/bin/env python3 +w,a,b=map(int,input().split()) +if b>a: + if b-w-a>0: + print(b-w-a) + else:print(0) +if a>b: + if a-w-b>0: + print(a-w-b) + else: + print(0) +" +p02939,s471464271,Accepted,"S=input() +pre=""#"" +cur="""" +cnt=0 + +for s in S: + cur+=s + if pre!=cur: + cnt+=1 + pre=cur + cur="""" +print(cnt)" +p03605,s023477241,Wrong Answer,"s=input() +ans=False +for i in s: + if i=='9': + ans=False + +if ans: + print('Yes') +else : + print('No')" +p03481,s641655588,Wrong Answer,"a = list(map(float,input().split())) +x = a[0] +y = a[1] + +n = a[0] * 2 +count = 1 + +while n <= y: + n = n * 2 + count += 1 + +print(str(count))" +p02663,s431060381,Accepted,"a,b,c,d,k=map(int,input().split()) +print((c-a)*60-b+d-k)" +p02922,s412504138,Accepted,"a, b = map(int, input().split()) + +if b == 1: + print(0) +elif b <= a: + print(1) +else: + print((b - 2)//(a - 1) +1)" +p04043,s754213358,Accepted,"a,b,c=map(int,input().split()) +if a+b+c==17 and a*b*c==175: + print(""YES"") +else: + print(""NO"") +" +p04043,s815103888,Wrong Answer,"A = list(map(int, input().split())) +A.sort() + +print(""Yes"" if A == [5,5,7] else ""No"")" +p02775,s471363603,Accepted,"s=[int(i) for i in input()] +n=len(s) +ans=0 +f=0 +for i in range(n-1,-1,-1): + j=s[i]+f + if j<5: + ans+=j + f=0 + elif j>5: + ans+=10-j + f=1 + elif i and s[i-1]>=5: + ans+=10-j + f=1 + else: + ans+=j + f=0 +print(ans+f)" +p02718,s037461495,Accepted,"N, M = map(int, input().split()) +A = list(map(int, input().split())) +A.sort(reverse=True) + +n = M - 1 +K = sum(A) + +if A[n] < K / (4 *M): + print('No') +else: + print('Yes')" +p03730,s898891523,Accepted,"import fractions +n,m,a=map(int,input().split()) +if a%fractions.gcd(n,m)==0: + print(""YES"") +else: + print(""NO"")" +p03486,s041456225,Accepted,"s = input() +t = input() +S = [] +T = [] +for i in range(len(s)): + S.append(s[i]) +for j in range(len(t)): + T.append(t[j]) +S.sort() +T.sort() +T.reverse() +a = '' +b = '' +for i in range(len(s)): + a += S[i] +for j in range(len(t)): + b += T[j] +if a < b: + print('Yes') +else: + print('No') +" +p03693,s189709571,Wrong Answer,"print('YES' if int(input().replace(' ', '')) % 4 == 0 else 'No') +" +p03673,s637906678,Accepted,"# -*- coding: utf-8 -*- +from collections import deque +import sys +#input = sys.stdin.readline +def inpl(): return list(map(int, input().split())) + +N = int(input()) +A = inpl() + +L = deque() + +for i in range(N): + if i%2: + L.append(A[i]) + else: + L.appendleft(A[i]) + +if (N%2): + print(*L) +else: + print(*list(L)[::-1])" +p02970,s555688954,Accepted,"import math +N,D=map(int,input().split()) +see=2*D+1 +ans=math.ceil(N/see) +print(ans)" +p02748,s042175705,Wrong Answer,"# -*- coding: utf-8 -*- + +a, b, m = map(int, input().split()) +A = [int(i) for i in input().split()] +B = [int(i) for i in input().split()] +res = A[0] + B[0] +for j in range(m): + x, y, c = map(int, input().split()) + summ = A[x-1] + B[y-1] - c + if summ < res: + res = summ + +print(res)" +p03778,s046211741,Accepted,"W, a, b = map(int, input().split()) +result = 0 +if ((a <= b) and (b <= a + W)) or ((a <= b + W) and (b + W <= a + W)): + result = 0 +elif (b + W < a): + result = a - (b + W) +elif (a + W < b): + result = b - (a + W) +print(result) +" +p03495,s601634881,Accepted,"from collections import Counter + +N, K = map(int, input().split()) +A = list(map(int, input().split())) +A = Counter(A) +key, value = zip(*A.most_common()) +# 数が少ないものを変更する +print(sum(value[K:]))" +p03043,s908923725,Wrong Answer,"n, k = map(int, input().split()) +ans = 0 +for i in range(n): + g = 1 / n + now = i+1 + while (True): + if (now > k): + break + now*=2 + g/=2 + ans += g +print(ans)" +p02623,s686189652,Accepted,"n,m,k = map(int, input().split()) +a = [int(_) for _ in input().split()] +b = [int(_) for _ in input().split()] + +t = sum(b) +j = m +ans = 0 +for i in range(n+1): + while j > 0 and t > k: + j -= 1 + t -= b[j] + if t > k: break + ans = max(ans, i + j) + if i==n:break + t+=a[i] + +print(ans)" +p02838,s357797541,Accepted,"n = int(input()) +a = [int(i) for i in input().split()] +mod = 10**9+7 +ans = 0 +m = max(a) +x = 0 +while m > 0: + m >>= 1 + x += 1 + +for i in range(x): + cnt = 0 + for j in range(n): + if a[j]>>i & 1 == 0: cnt += 1 + ans = (ans+pow(2,i,mod)*cnt%mod*(n-cnt)%mod)%mod + +print(ans)" +p02755,s353814087,Accepted,"import math +A,B = map(int,input().split()) +for i in range(10000): + if math.floor(i * 1.08 -i )==A and math.floor(i * 1.1 -i)==B: + print(i) + exit() +print(-1)" +p02663,s019639890,Wrong Answer,"h1, m1, h2, m2, k = map(int, input().split()) +h = h2-h1 +if m1 > m2: + m2 += 60 +m = m2-m1 +a = h*60 +m += a +b = k +if k != m: + while k+b != m and k < m: + if k+b == m: + k = 0 + break + k += b +else: + k = 0 +print(k) + +" +p03073,s213908879,Wrong Answer,"s = str(input()) +n = len(s) +p = [0] * n +if int(s[0]) % 2 == 0: + for i in range(1, n, 2): + p[i] = 1 +elif int(s[0]) % 2 == 1: + for i in range(1, n, 2): + p[i] = 0 +q = [] +for i in range(n): + q.append(int(s[i]) ^ int(p[i])) +print(q.count(1))" +p03011,s212814470,Accepted,"PQR = list(list(input().split())) +PQR.sort() +print(int(PQR[0]) + int(PQR[1])) +" +p03163,s307973411,Accepted," +import numpy as np + +n, w = map(int, input().split()) + +dp = np.array([0] * (w+1)) + +for i in range(n): + weight, value = map(int, input().split()) + + dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value) + +print(int(dp[-1]))" +p02675,s452567759,Accepted,"N = input() +s = N[-1] + + +if s in ""24579"": + print(""hon"") +elif s in ""0168"": + print(""pon"") +else: + print(""bon"") + +" +p02973,s304143680,Accepted,"def main(): + from bisect import bisect_right + n=int(input()) + a=[int(input()) for _ in range(n)] + + color=[] + for i in range(n-1,-1,-1): + num=a[i] + idx=bisect_right(color,num) + if idx==len(color): + color.append(num) + else: + color[idx]=num + + print(len(color)) +if __name__=='__main__': + main()" +p03994,s494432486,Accepted,"s=input() +k=int(input()) + +alpha=list('abcdefghijklmnopqrstuvwxyz') + +ans=[] +for i in range(len(s)): + ki= 26-alpha.index(s[i]) if s[i]!='a' else 0 +# print(ki,k) + if(i==len(s)-1): + kn=k+alpha.index(s[i]) + kn=kn%26 + ans.append(alpha[kn]) + elif(ki<=k): + ans.append('a') + k-=ki + else: + ans.append(s[i]) +print(''.join(ans))" +p02888,s054621482,Accepted,"import bisect +n=int(input()) +l=sorted(list(map(int,input().split()))) +ans=0 +for i in range(n-1): + for j in range(i+1,n): + index=bisect.bisect_left(l,l[i]+l[j]) + if j 0): + if coin >= 500: + coin = coin - 500 + fivet_yen = fivet_yen + 1000 + else: + if coin >= 5: + coin = coin - 5 + five_yen = five_yen + 5 + + coin = coin - 1 + + +print(fivet_yen + five_yen) + + + " +p02608,s202896846,Accepted,"n = int(input()) + +a = 2 +res = dict() + +for i in range(1, 142): + for j in range(1, 142): + for k in range(1, 142): + tmp = int(((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) / 2) + res[tmp] = res.get(tmp, 0) + 1 + +for i in range(n): + print(res.get(i + 1, 0)) +" +p03241,s297534925,Wrong Answer,"N, M = map(int, input().split()) +ans = 1 +K = M//N +for i in range(1, int(M**0.5)+1): + if M%i == 0: + if i <= K: + ans = max(ans, i) + if M//i <= K: + ans = max(ans, i) + +print(ans)" +p02647,s586755426,Accepted,"N,K=map(int,input().split()) +light=list(map(int,input().split())) +for k in range(K): + imo=[0]*(N+1) + for i in range(N): + l=max(0,i-light[i]) + r=min(N-1,i+light[i])+1 + imo[l]+=1 + imo[r]-=1 + for i in range(1,N): + imo[i]+=imo[i-1] + if light==imo: + break + else: + light=imo[:] +print(*light[:-1])" +p03087,s196820044,Accepted,"def main(): + N, Q = (int(i) for i in input().split()) + S = input() + C = [0] * (len(S) + 1) + for i in range(1, len(S)): + C[i+1] = C[i] + (1 if S[i] == ""C"" and S[i-1] == ""A"" else 0) + + for q in range(Q): + le, ri = (int(i) for i in input().split()) + print(C[ri] - C[le]) + + +if __name__ == '__main__': + main() +" +p03219,s396582095,Accepted,"x, y = map(int, input().split()) +print(x+y//2)" +p02972,s041315553,Wrong Answer,"N = int(input()) +A = list(map(int,input().split())) +ball = [0] * N + +def divisors(n): + for i in range(1, int(n ** 0.5) + 1): + if n % i == 0: + ball[i - 1] += 1 + if n != 1: + ball[n - 1] += 1 + +for i in range(N - 1,-1,-1): + if A[i] != (ball[i] % 2): + divisors(i + 1) + +if sum(ball) == 0: + print(0) +else: + M = sum(ball) + ball = [i for i in ball if i >= 1] + print(M) + print(*ball)" +p02897,s019661691,Wrong Answer,"n=float(input()) +if n%2==0: + print(float(1/2)) +else: + print((n-1)/(2*n))" +p02555,s431296887,Wrong Answer,"mod=1000000007 +dp=[1]*2001 +for i in range(3,2001): + for j in range(i+3,2001): + dp[j]=(dp[j]+dp[i])%mod +n=int(input()) +print(dp[n])" +p02831,s523463216,Wrong Answer,"A, B = map(int, input().split()) +commulti = A * B +count = 1 +while True: + if commulti / A / B == 1: + break + + if count%2 == 0: + commulti /= A + else: + commulti /= B + +print(commulti)" +p03076,s668256694,Wrong Answer,"A = [int(input()) for _ in range(5)] +cnt = 0 +Max = 10 +for i in range(len(A)): + if A[i]%10 < Max: + Max = i +for i in range(len(A)): + if i != Max: + cnt += A[i] + while cnt%10 != 0: + cnt += 1 +print(cnt+A[Max])" +p03408,s585063216,Accepted,"S = [input() for _ in range(int(input()))] +T = [input() for _ in range(int(input()))] +l = list(set(S)) +print(max(0, max(S.count(l[i]) - T.count(l[i]) for i in range(len(l))))) +" +p04031,s586430448,Accepted,""""""" +kari1 = '2' +kari2 = '4 8' #8 +#kari1 = '3' +#kari2 = '1 1 3' #3 +#kari1 = '3' +#kari2 = '4 2 5' #5 +#kari1 = '4' +#kari2 = '-100 -100 -100 -100' #0 +in1 = kari1 +in2 = kari2.split() +"""""" +in1 = input() +in2 = input().split() + +AVEa = 0 +RC = 0 +for item in in2: + AVEa = AVEa + int(item) + +AVEa = round(AVEa / len(in2)) + +for item in in2: + if int(item) != AVEa: + RC = RC + ((int(item) - AVEa) ** 2) + +print(RC) +" +p03075,s414891151,Accepted,"a = int(input()) +b = int(input()) +c = int(input()) +d = int(input()) +e = int(input()) +k = int(input()) +print("":("" if max(a,b,c,d,e) - min(a,b,c,d,e) > k else ""Yay!"")" +p02584,s452830666,Wrong Answer,"X, K, D = map(int, input().split()) + +Xa = abs(X) +Xs = X // D +Xm = X % D + +if (K < Xs): + print(Xa - D*K) +elif Xm == 0 and X != 0: + if K % 2 == 0: + print(D) + else: + print(0) +elif (K-Xs) % 2 == 0: + print(Xm) +else: + print(D-Xm)" +p03145,s037767002,Accepted,"A, B, C = map(int,raw_input().split()) +area = (A*B)/2 +print area + +" +p02622,s997130583,Wrong Answer,"S=input() +T=input() +a=S.split() +b=T.split() +l=[] +for i in range(len(a)): + if a[i]!=b[i]: + l.append(1) +print(len(l))" +p02786,s006243513,Wrong Answer,"H = int(input()) + +cnt = 1 +ans = 1 +while True: + if H // 2 > 1: + H //= 2 + ans += 2 ** cnt + cnt += 1 + else: + ans += 2 ** cnt + break + +print(ans) +" +p03680,s609663831,Wrong Answer,"n=int(input()) +d={} +for i in range(1, n+1): + x=int(input()) + d[i] = x +tmp = d[1] +ans=1 +for _ in range(n): + ans+=1 + tmp = d[tmp] + #print(tmp) + if tmp == 2: + print(ans) + exit() +print(-1)" +p03274,s209713013,Accepted,"n,k = map(int,input().split()) +x = list(map(int,input().split())) +ans = 10 ** 12 +for i in range(n-k+1): + ans = min(ans,abs(x[i])+(abs(x[i+k-1]-x[i])),abs(x[i+k-1])+(abs(x[i+k-1]-x[i]))) +print(ans)" +p02881,s433194824,Accepted,"from math import sqrt, ceil + +N = int(input()) +a = 0 + +for i in range(1, ceil(sqrt(N)) + 1): + if N % i == 0: + a = i + +ans = (a - 1) + (N // a - 1) + +print(ans)" +p03485,s669681485,Accepted,"import math +a,b=map(int,input().split()) +print (math.ceil((a+b)/2))" +p03281,s978897110,Accepted,"N = int(input()) +ans = 0 +for n in range(1,N+1,2): + d = set() + m = 1 + while m*m <= n: + if n%m==0: + d.add(m) + d.add(n//m) + m += 1 + if len(d)==8: + ans += 1 +print(ans)" +p03695,s073098334,Accepted,"N = int(input()) +A = list(map(int,input().split())) +cs = [0]*9 +for a in A: + if a >= 3200: + cs[8] += 1 + else: + cs[a//400] += 1 + +fixed = 0 +for i in range(8): + if cs[i]: fixed += 1 + +if fixed: + print(fixed, fixed + cs[8]) +else: + print(1, cs[8])" +p02720,s596510000,Wrong Answer,"k = int(input()) + +ans = 1 +cnt = 0 +while cnt < k: + # print(ans, cnt) + if ans <= 9: + cnt+=1 + ans+=1 + continue + li = list(map(int, list(str(ans)))) + for i in range(len(li)-1): + if abs(li[i]-li[i+1]) > 1: + ans+=1 + break + cnt+=1 + ans += 1 +print(ans-1)" +p03386,s951258486,Wrong Answer,"a,b,k=map(int,input().split()) +if k > b-a: + k = b-a +print('\n'.join(map(str,sorted(set(range(a,a+k)) | set(range(b-k+1,b+1)))))) +" +p03817,s652890933,Accepted,"x = int(input()) +q, mod = divmod(x, 11) +if mod == 0: + ans = q * 2 +elif mod > 6: + ans = q * 2 + 2 +else: + ans = q * 2 + 1 +print(ans) +" +p02706,s108948669,Accepted,"N, M = map(int, input().split("" "")) + +li_a = list(map(int, input().split("" ""))) +days = 0 + +for i in range(M): + days += li_a[i] + +if N >= days: + print (N - days) +else: + print(-1)" +p03109,s073626476,Accepted,"y,m,d=map(int,input().split(""/"")) +if y<2019 or (y==2019 and (m<4 or (m==4 and d<=30))): + print(""Heisei"") +else:print(""TBD"")" +p02744,s255014093,Accepted,"n = int(input()) + +if n == 1: + print('a') + exit() + +def dfs(s, cmax): + if len(s) == n: + print(s) + else: + for i in range(ord(cmax)-ord('a')+2): + c = chr(i+ord('a')) + if ord(c) < ord(cmax): + dfs(s+c, cmax) + else: + dfs(s+c, c) + +dfs('a', 'a')" +p03317,s126366706,Wrong Answer,"from math import ceil + +n, k = map(int, input().split()) +a = list(map(int, input().split())) +idx = a.index(1) +if idx == 0: + print(ceil(len(a[(idx + 1):]) / (k - 1))) +elif idx == (n - 1): + print(ceil(len(a[:idx]) / (k - 1))) +else: + print((ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1)))) +" +p02996,s936510044,Wrong Answer,"nb = int(input()) +somme = 0 +mmax = 0 +for loop in range(nb): + n,m = map(int,input().split()) + somme+=n + if m>mmax: + mmax = m +if somme<=mmax: + print(""yes"") +else: + print(""no"")" +p02744,s368138707,Accepted,"import itertools + +n = int(input()) + +alpha_list = ['a','b','c','d','e','f','g','h','i','j'] +string_list = [] +count = 0 + +def extend(string,count,n): + if len(string) >= n: + string_list.append(string) + return True + else: + for i in range(count+1): + sc = string + sc += alpha_list[i] + if i == count: + count += 1 + extend(sc,count,n) + +extend('',count,n) + +string_list.sort() +for s in string_list: + print(s)" +p02993,s485805516,Wrong Answer,"S = input() +for i in range(9): + i = i +1 + hikaku = i*10+i + #print(hikaku) + if (str(hikaku) in S) == True: + result = ""Bad"" + break + else: + result = ""Good"" +print(result)" +p03627,s454219589,Wrong Answer,"n=int(input()) +a=list(map(int,input().split())) +b=list(set(a)) +b=reversed(b) +c=[] +for i in b: + if a.count(i)>=2: + c+=[i] + if len(c)==2: + break +if len(c)<=1: + print(0) +else: + print(c[0]*c[1])" +p02772,s205790267,Accepted,"n = int(input()) +flag = True +for a in map(int, input().split()): + if a % 2 == 0 and a % 3 != 0 and a % 5 != 0: + flag = False + break +if flag: + print('APPROVED') +else: + print('DENIED')" +p02963,s368984888,Accepted,"S = int(input()) + +v = 10**9 +a = (v-S%v)%v +b = (S+a)//v + +print(0, 0, 10**9, 1, a, b)" +p04031,s458952643,Accepted,"s=input();a=list(map(int,input().split()));ans=0 +mean=round(sum(a)/len(a)) + +for i in a: + p=(i-mean)**2 + ans+=p + +print(ans)" +p04033,s233154880,Accepted,"a,b = map(int,input().split()) +if a > 0: + print(""Positive"") +elif b < 0: + if abs(a-b)%2 == 0: + print(""Negative"") + else: + print(""Positive"") +else: + print(""Zero"")" +p02578,s508126291,Wrong Answer,"import math +import collections +import fractions +import itertools +import functools +import operator +import bisect + +def solve(): + n = int(input()) + a = list(map(int, input().split())) + mi = 0 + le = len(a) + cost = 0 + for i in range(le-1): + if a[i] > a[i+1]: + mi = max(a[i], mi) + cost += mi - a[i+1] + print(cost) + return 0 + +if __name__ == ""__main__"": + solve()" +p03061,s065306903,Accepted,"import math + +n=int(input()) + +a=list(map(int,input().split())) + +L=[0] + +for i in range(n): + L.append(math.gcd(L[i],a[i])) + +R=[0] +for i in range(n): + R.append(math.gcd(R[i],a[n-1-i])) + +ans=1 +for i in range(n): + ans=max(ans,math.gcd(L[i],R[n-1-i])) + +print(ans) +" +p02946,s594249474,Wrong Answer,"listA = [] +A,B = list(map(int,input().split())) +for i in range(B-A+1,B+1): + listA.append(i) +for i in range(B+1,B+A): + listA.append(i) +print(listA)" +p02910,s709151612,Wrong Answer,"S = list(input()) +for i in range(0,len(S),2): + if S[i] == 'R': + print('No') + exit() +for j in range(1,len(S),2): + if S[j] == 'L': + print('NO') + exit() +print('Yes')" +p03478,s229794855,Accepted,"N, A, B = map(int,input().split()) +lst_1 = [] +def digitSum(n): + # 数値を文字列に変換 + s = str(n) + # 1文字ずつ数値化し配列にする。 + array = list(map(int, s)) + # 合計値を返す + return sum(array) + +sub = [k for k in range(1,N+1)] + +for j in sub: + if A <= digitSum(j) <= B: + lst_1.append(j) +print(sum(lst_1))" +p02718,s405550582,Accepted,"n, m = map(int, input().split()) +a = list(map(int, input().split())) +print(""Yes"" if len([i for i in a if i/sum(a) >= 1/(4 * m)]) >= m else ""No"")" +p02688,s303849897,Accepted,"n,k= map(int, input().split()) + +li=[0]*n +for i in range(k): + d=int(input()) + lis = list(map(int,input().split())) + for j in range(len(lis)): + li[lis[j]-1]+=1 + lis.clear +cnt=0 +for i in range(len(li)): + if li[i]==0: + cnt+=1 + +print(cnt)" +p02923,s039227753,Accepted,"N=int(input()) +*H,=map(int,input().split()) + + +i=0 +cnt=0 +ans=0 +while i < N-1: + if 1<=H[i]/H[i+1]: + cnt+=1 + else: + ans=max(ans,cnt) + cnt=0 + i+=1 +ans=max(ans,cnt) +print(ans)" +p02712,s161332140,Wrong Answer,"n = (int(input())) +sum = 0 +for i in range(n): + if not((i+1)%3 == 0 or (i+1)%5 == 0): + sum += i+1 + print(i+1) +print(sum)" +p03254,s617050880,Wrong Answer,"N, X = map(int, input().split()) +A = list(map(int, input().split())) +A.sort() +res = 0 +for a in A: + if a > X: + break + res += 1 + X -= a +if X > 0: + res -= 1 +print(max(res, 0))" +p02548,s298151853,Wrong Answer,"import math +n = int(input()) +ab = [] +ans = 0 + +def prime(x): + cbn, ct = 0, 0 + l2 = int(math.sqrt(x)) + for i in range(1, l2+1): + if x % i == 0: + ab.append([i, int(x/i)]) + ct += 2 + if ab[-1][0] == ab[-1][1]: + ct -= 1 + cbn += ct + ct = 0 + return cbn + +for c in range(1, n): + print(c) + ans += prime(n-c) +print(ans) +" +p03860,s865719382,Accepted,"# import bisect +# from collections import Counter, defaultdict, deque +# import copy +# from heapq import heappush, heappop, heapify +# from fractions import gcd +# import itertools +# from operator import attrgetter, itemgetter +# import math + +import sys + +# import numpy as np + +ipti = sys.stdin.readline +MOD = 10 ** 9 + 7 +INF = float('INF') +sys.setrecursionlimit(10 ** 5) + +def main(): + s = list(map(str,input().split())) + print(""A""+s[1][0]+""C"") + +if __name__ == '__main__': + main()" +p02689,s162043940,Wrong Answer,"n, m = map(int, input().split()) +h = list(map(int, input().split())) + +flag = [True] * n +for _ in range(m): + a, b = map(int, input().split()) + if h[a-1] >= h[b-1]: + flag[b-1] = False + elif h[b-1] > h[a-1]: + flag[a-1] = False + + +cnt = 0 +for i in flag: + if i: + cnt += 1 +print(cnt)" +p02910,s298429246,Wrong Answer,"k = ['R','U','D'] +g = ['L','U','D'] + +s = input() +for i in range(len(s)): + if s[i] == 'U' or s[i] == 'D': + continue + else: + if i%2 == 0: + if s[i] != 'L': + print(""No"") + exit() + else: + if s[i] != 'R': + print(""No"") + exit() +print(""Yes"")" +p03109,s557718934,Wrong Answer,"moji = str(input()) +if int(moji[0:4]) < 2019: + print(""Heisei"") +elif int(moji[0:4]) == 2019: + if int(moji[6:7])<=4: + print(""Heisei"") + else: + print(""TBD"") +else: + print(""TBD"")" +p03345,s820729492,Accepted,"A, B, C, K = map(int, input().split()) +print(A-B if K%2 == 0 else B-A)" +p03329,s509019344,Accepted,"import itertools,sys +def I(): return int(sys.stdin.readline().rstrip()) +N = I() +dp = [float('INF')]*(N+1) +dp[0] = 0 +for i in range(N+1): + if i+1<=N: + dp[i+1] = min(dp[i+1],dp[i]+1) + num6,num9 = 6,9 + while i+num6<=N: + dp[i+num6] = min(dp[i+num6],dp[i]+1) + num6 *= 6 + while i+num9<=N: + dp[i+num9] = min(dp[i+num9],dp[i]+1) + num9 *=9 +print(dp[-1]) +" +p03001,s474184869,Wrong Answer,"W,H,x,y = map(int, input().split()) +flg = 0 +if 2*x==W or 2*y==H: + flg = 1 +res = [W*H/2, flg] +print(*res)" +p02860,s784216289,Wrong Answer,"N=int(input()) +S=input() +if S[0:N//2-1]==S[N//2:-1]: + print(""Yes"") +else: + print(""No"")" +p03943,s974228976,Accepted,"a, b, c = map(int, input().split()) +if a+b == c or b+c == a or c+a == b: + print('Yes') +else: + print('No')" +p02861,s496400066,Accepted,"import itertools +import math + +n=int(input()) +town=[0]*n +for i in range(n): + town[i]=tuple(map(int,input().split(' '))) + +sum_len=0 +now=[0,0] + +permu = itertools.permutations([i for i in range(n)]) +for case in permu: + now = town[case[0]] + for i in case[1:]: + sum_len += ((now[0]-town[i][0])**2 + (now[1]-town[i][1])**2)**(1/2) + now = town[i] +print(sum_len/math.factorial(n))" +p03434,s339377559,Wrong Answer,"n,*x=map(int,open(0).read().split());a=0;t=1 +for i in sorted(x):a+=t*i;t*=-1 +print(a)" +p02612,s648091403,Wrong Answer,"N=int(input()) +for i in range(0,11000,1000): + if N<=i: + print(int(i-N)) +" +p03328,s524276575,Accepted,"a,b=map(int, input().split()) #複数数値入力 「A B」みたいなスペース空いた入力のとき + +m=(b-a-1)*(b-a)/2 + +print(int(m-a)) +" +p03250,s912518419,Wrong Answer,"def LI(): return list(map(int, input().split())) + + +A,B,C = LI() +print(max([A,B,C])*10+B+C) + +" +p03071,s010891072,Accepted,"a,b=map(int,input().split()) +if a>b: + print(a*2-1) +elif a==b: + print(a*2) +else: + print(b*2-1) +" +p03250,s815612722,Accepted,"a, b, c = map(int, input().split()) +print(max(a*10+b+c, b*10+c+a, c*10+a+b)) +" +p03013,s186021767,Accepted,"n, m = map(int, input().split()) + +mod = 1000000007 + +from collections import deque + +d = deque() + +for _ in range(m): + d.append(int(input())) + +old = 0 +new = 1 + +for i in range(1, n+1): + if len(d): + if i != d[0]: + old, new = new, (old+new) % mod + else: + old, new = new, 0 + d.popleft() + else: + old, new = new, (old+new) % mod + + + +print(new)" +p03243,s415174802,Accepted,"N = int(input()) +ls = [] +for i in range(N,1000): + if i % 111 == 0: + ls.append(i) +print(ls[0])" +p02621,s392895012,Wrong Answer,"a = int(input()) +ans = (a+a*2+a*3)//1 +print(ans)" +p03456,s131372002,Accepted,"a, b = input().split() +s = int(a + b) + +is_ok = False +for i in range(1, 1000): + if i * i == s: + is_ok = True + break + +print(""Yes"" if is_ok else ""No"")" +p03838,s950290248,Accepted,"x, y = map(int, input().split()) + +ans = 10**18 +if x <= y: + ans = min(y - x, ans) +if -x <= y: + ans = min(y - (-x) + 1, ans) +if x <= -y: + ans = min((-y) - x + 1, ans) +if -x <= -y: + ans = min((-y) - (-x) + 2, ans) +print(ans)" +p03208,s746999035,Accepted," + +def solve(): + + N, K = map(int, input().split()) + hlist = [int(input()) for i in range(N)] + + # sortして走破? + hlist.sort() + l = [] + + for i in range(N-K+1): + l.append(hlist[i+K-1]-hlist[i]) + + print(min(l)) + + +if __name__ == ""__main__"": + solve() +" +p04034,s717873046,Accepted,"N, M = map(int, input().split()) + +red = [0]*N +red[0] = 1 + +q = [1]*N + +for _ in range(M): + x, y = map(int, input().split()) + red[y-1] |= red[x-1] + q[x-1] -= 1 + q[y-1] += 1 + if q[x-1] == 0: + red[x-1] = 0 + +print(sum([1 for i in range(N) if q[i]>0 and red[i]]))" +p03779,s229674957,Accepted,"#ABC056 + +x = int(input()) + +for i in range(10 ** 6): + if i * (i - 1) // 2 < x <= i * (i + 1) // 2: + print(i) + break" +p02621,s063295605,Accepted,"a=int(input()) + +b=a+a*a+a*a*a + +print(b)" +p03565,s517649519,Accepted,"import re +s = input().replace(""?"",""."") +t = input() +for i in range(len(s)-len(t),-1,-1): + if re.match(s[i:i+len(t)],t): + s = s.replace(""."",""a"") + print(s[:i]+t+s[i+len(t):]) + exit() +print(""UNRESTORABLE"")" +p02817,s484093789,Wrong Answer,print(''.join(input().split())) +p02554,s549920088,Accepted,"n = int(input()) + +# ぜんぶ +a = 10 ** n +# 0が存在しない +b = 9 ** n +# 9が存在しない +c = 9 ** n +# 0も9も存在しない +d = 8 ** n + +ans = a - b - c + d + +print(ans % 1000000007) +" +p02948,s719690216,Accepted,"import sys +from heapq import heappop, heappush + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) + +N, M = lr() +works = [[] for _ in range(M+1)] +# M-1日後から選んでいく, +for _ in range(N): + a, b = lr() + if a <= M: + works[a].append(-b) + +heap = [] +answer = 0 +for work in works: + for x in work: + heappush(heap, x) + if heap: + answer -= heappop(heap) # heap構造なので + +print(answer) +# 08 +" +p03073,s723358292,Accepted,"S = input() +list_S = [int(x) for x in S] + +N = len(S) +if N % 2 == 0: + op1 = [0, 1] * int(N//2) + op2 = [1, 0] * int(N//2) +else: + op1 = [0, 1] * int(N//2) + [0] + op2 = [1, 0] * int(N//2) + [1] + +cnt_op1 = 0 +cnt_op2 = 0 +for i in range(N): + if list_S[i] != op1[i]: + cnt_op1 += 1 + if list_S[i] != op2[i]: + cnt_op2 += 1 + +print(min(cnt_op1, cnt_op2)) +" +p03479,s620610420,Accepted,"x,y = map(int,input().split()) + +cand = [x] + +while(cand[-1]*2<=y) : + cand.append(cand[-1]*2) + +print(len(cand)) +" +p03254,s629844219,Accepted,"N,x = map(int,input().split()) +A = list(map(int,input().split())) +A.sort() + +cnt = 0 +sum_x = 0 +for i in range(N): + if(i == N-1): + if((x-sum_x) == A[N-1]): + cnt += 1 + break + + if(sum_x+A[i] <= x): + sum_x += A[i] + cnt += 1 + else: + break + + +print(cnt) " +p02786,s127135386,Accepted,"h = int(input()) + +def solve(n): + if n == 1: + return 1 + else: + return 1 + 2 * solve(n//2) + +print(solve(h)) +" +p03673,s468905967,Accepted,"n = int(input()) +A = list(input().split()) +if n % 2: + print("" "".join(A[::2][::-1]), "" "".join(A[1::2])) +else: + print("" "".join(A[1::2][::-1]), "" "".join(A[::2])) +" +p03797,s799760333,Accepted,"n, m = map(int,input().split()) +ans = 0 +if n*2 > m: + if m%2 == 0: + ans = m//2 + else: + ans = (m-1)//2 +else: + ans += n + m -= n*2 + ans += m//4 +print(ans)" +p02622,s884950598,Wrong Answer,"a=input() +b=input() +count=0 +for str_i in range (len(a)): + if a[str_i:] != b[str_i:]: + count+=1 +print(count)" +p02743,s388064962,Accepted,"import math +a, b, c = map(int, input().split()) + +if 4 * a * b >= (c - b - a) ** 2 or c - b - a < 0: + ans = ""No"" +else: + ans = ""Yes"" + + +print(ans) +" +p03162,s527300368,Accepted,"n=int(input()) + +dp=list(map(int,input().split())) +for day in range(1,n): + m=[0]*3 + day_points=list(map(int, input().split())) + for i in range(3): + for j in range(3): + if i!=j: + m[i]=max(m[i],day_points[i]+dp[j]) + dp=m +print(max(dp))" +p02790,s398064044,Accepted,"a,b = input().split() +a_int = int(a) +b_int = int(b) +ab = a*b_int +ba = b*a_int +if ab >= ba: + print(ba) +elif ab <= ba: + print(ab)" +p02659,s124181277,Accepted,"from math import floor +from decimal import Decimal + +A, B = map(Decimal, input().split()) +print(floor(A * B)) +" +p03557,s145919163,Wrong Answer,"from bisect import bisect +N = int(input()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +C = list(map(int, input().split())) +A_count = [0] * len(A) +B_count = [0] * len(B) +for i in range(len(B)): + B_count[i] = len(C) - bisect(C, B[i]) +for i in range(len(A)): + A_count[i] = sum(B_count[bisect(B, A[i]):]) +print(sum(A_count))" +p02748,s707271653,Accepted,"A,B,M = map(int,input().split()) +rei = list(map(int,input().split())) +ren = list(map(int,input().split())) +rrw = [] +for i in range(M): + rrw.append(list(map(int,input().split()))) +saiyasu = min(rei) + min(ren) +for j in range(M): + onedan = rei[(rrw[j][0])-1] + ren[rrw[j][1]-1] - rrw[j][2] + if onedan < saiyasu: + saiyasu = onedan + +print(saiyasu)" +p03285,s536325302,Accepted,"n = int(input()) +cmax = 100 // 4 +dmax = 100 // 7 +for i in range(0, cmax + 1): + for j in range(0, dmax + 1): + if i * 4 + j * 7 == n: + print(""Yes"") + exit() +print(""No"")" +p03943,s513213722,Wrong Answer,"a,b,c = map(int, input().split()) +if (a+b+c)%3==0: print('Yes') +else: print('No')" +p02603,s388594149,Accepted,"#D +N = int(input()) +A = list(map(int, input().split())) +A.append(0) + +cash = 1000 +stock = 0 +for i in range(N): + if A[i] < A[i+1]: + stock += cash // A[i] + cash = cash % A[i] + else: + cash += stock * A[i] + stock = 0 + +print(cash)" +p03665,s329732661,Wrong Answer,"N,P = map(int,input().split()) +A = list(map(int,input().split())) +n0=0 +n1=0 +for i in range(N): + if A[i]%2==0: + n0 += 1 +n1 = N-n0 +if n1==0: + if P==0: + print(2**n0-1) + else: + print(0) +elif P==0: + print(2**(n1-1)*2**n0-1) +elif P==1: + print(2**(n1-1)*2**n0)" +p03478,s029621879,Accepted,"n,a,b=map(int,input().split()) +ans=[0]*37 +def ssum(n): + li=list(str(n)) + ret=0 + for i in li: + ret+=int(i) + return(ret) + +while n!=0: + ans[ssum(n)]+=n + n-=1 + +print(sum(ans[a:b+1]))" +p03103,s494092057,Accepted,"N, M = map(int, input().split()) +AB = [] +for i in range(N): + AB.append(list(map(int, input().split()))) +AB = sorted(AB, key=lambda x:x[0]) + +cost, num, want = 0, M, M +for i in range(N): + num = min(want, AB[i][1]) + cost += AB[i][0] * num + want -= num + if num == 0: + break +print(cost)" +p02923,s251375799,Wrong Answer,"n = int(input()) +h = list(map(int,input().split())) +count_m = 0 +for i in range(n): + s = h[i] + count = 0 + for j in range(i+1,n): + if s >= h[j]: + count += 1 + s = h[j] + count_m = max(count_m, count) +print(count_m)" +p02994,s235119799,Accepted,"N, L = map(int,input().split()) + +l = 0 +m = 10000 +for i in range(1,N+1): + l += L+i-1 + m = min(m,abs(L+i-1)) +if L+N-1 >= 0: + l -= m +else: + l += m +print(l) +" +p03471,s020991503,Accepted,"def resolve(): + N, Y = map(int, input().split()) + + for x in range(N+1): + for y in range(N+1-x): + _sum = 10000 * x + 5000 * y + 1000 * (N-x-y) + if _sum == Y: + print(x, y, N-x-y) + exit(0) + + print(-1, -1, -1) + + +if __name__ == '__main__': + resolve() +" +p03087,s668267498,Accepted,"N, Q = map(int, input().split()) +S = input() +acList = [0 for n in range(N+1)] +for i in range(N): + if(""AC"" == S[i:i+2]): + acList[i+1] += acList[i] + 1 + else: + acList[i+1] += acList[i] +for q in range(Q): + left, right = map(int, input().split()) + print (acList[right-1] - acList[left-1])" +p02714,s301671792,Accepted,"n = int(input()) +s = input() + +r = s.count('R') +g = s.count('G') +b = s.count('B') +cnt = 0 +for j in range(n-2): + sj = s[j] + for i in range(1, (n-j)//2+1): + if n <= j+2*i: + break + sd = s[j+i] + sd2 = s[j+2*i] + if (sj != sd) and (sj != sd2) and (sd != sd2): + cnt += 1 +print(r*g*b - cnt)" +p03161,s182226234,Accepted,"n, k = [int(i) for i in input().split("" "")] +h = [int(i) for i in input().split("" "")] + +dp = [float(""inf"")] * n +dp[0] = 0 + +for i in range(len(h)): + for j in range(1, k+1, 1): + if (i+j) < len(h): + dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j] - h[i])) +print(dp[-1])" +p03698,s829204302,Accepted,"S = input() +n = len(S) +t = len(set(list(S))) +if n == t: + print('yes') +else: + print('no') +" +p03605,s328220195,Accepted,"N=input() + +if N[0]=='9' or N[1] == '9': + print('Yes') +else: + print('No') +" +p03323,s598934082,Accepted,"a, b = map(int, input().split()) +print(""Yay!"" if a<=8 and b<=8 else "":("")" +p03605,s861568954,Accepted,"n = int(input()) +n = str(n) +if ""9"" in n: + print(""Yes"") +else: + print(""No"")" +p03633,s285633272,Accepted,"#!/usr/bin/env python3 +import collections +import itertools as it +import math +import numpy as np +import functools + +# = input() +n = int(input()) +# = map(int, input().split()) +# = list(map(int, input().split())) +t = [int(input()) for i in range(n)] +# +# c = collections.Counter() + +def euclid(a, b): + if b == 0: + return a + else: + return euclid(b, a%b) + +def multiple(a, b): + return a*b // euclid(a, b) + +def gcd(nums): + return functools.reduce(euclid, nums) + +def lcm(nums): + return functools.reduce(multiple, nums) + +print(lcm(t)) +" +p03360,s033044410,Accepted,"abc = sorted(list(map(int, input().split()))) +k = int(input()) + +for i in range(k): + abc[2] *= 2 + +print(sum(abc))" +p03644,s887622894,Wrong Answer,"import math +c= 0 +n = int(raw_input()) +while(n and n % 2 == 0): + n/=2 + c+=1 +print c" +p02917,s497165384,Accepted,"N = int(input()) + +B = list(map(int,input().split())) + +A=[-1 for x in range(N)] +i=0 +j=0 +for a in B: + j=i+1 + if A[i]==-1: + A[i]=a + A[j]=a + else: + if A[i]>a: + A[i]=a + A[j]=a + i=i+1 + #print(A) +total = 0 +for num in A: + total = total + num +print(total) + +" +p03705,s995138745,Accepted,"import sys + +def solve(): + input = sys.stdin.readline + N, A, B = map(int, input().split()) + if A > B: print(0) + elif N == 1: + if B != A: print(0) + else: print(1) + else: + rem = N - 2 + minS = A + B + rem * A + maxS = A + B + rem * B + print(maxS - minS + 1) + + return 0 + +if __name__ == ""__main__"": + solve()" +p03371,s708608005,Wrong Answer,"A,B,C,X,Y=map(int,input().split()) +ans=5000*(10**5)+1 + +for i in range(max(X,Y)+1): + total=0 + total=2*C*i+A*max(X-i,0)+B*max(Y-i,0) + ans=min(total,ans) +print(ans)" +p02787,s688586110,Accepted,"import sys +input = sys.stdin.readline + +H,N = map(int, input().split()) +table = [] +dp = [10**9]*(H+1) +dp[0] = 0 + +for i in range(N): + a,b = map(int, input().split()) + table.append((a,b)) + +for i in range(1,H+1): +# print(dp) + for j in range(N): + a,b = table[j] + if i= len(B): + print(""APPROVED"") +else: + print(""DENIED"")" +p03761,s030607407,Accepted,"n = int(input()) +li = [[0]*n for i in range(26)] +for i in range(n): + S = list(input()) + for x in S: + li[ord(x)-97][i] += 1 +ans = [] +for i in range(26): + num = min(li[i]) + ans += [chr(i+97)] * num +print(''.join(ans))" +p02657,s464412676,Wrong Answer,"a,b=map(int,input().split()) +print(a*b*2/2)" +p02633,s453146885,Wrong Answer,"N = int(input()) +a=360/N +print(int(a)) +b=isinstance(a, float) +text_a = str(b) +text_b =float +c=text_a == text_b +if c!=False: + print(int(a+1))" +p03219,s421505302,Accepted,"import sys +def MI(): return map(int,sys.stdin.readline().rstrip().split()) + +X,Y = MI() +print(X + Y//2) +" +p02682,s038473124,Accepted,"# -*- coding: utf-8 -*- + +a = list(map(int,input().split())) + +A, B, C, K = a[0], a[1], a[2], a[3] + +if ( K <= A ): + print(K) +elif ( K <= A+B ): + print(A) +elif ( K <= A+B+C ): + print(2*A+B-K) +else: + print(A-C)" +p02842,s718027542,Wrong Answer,"n = int(input()) +a = n//1.08 +print(int(a+1))" +p02732,s983427145,Accepted,"import collections +n = int(input()) +a = list(map(int,input().split())) +aa = collections.Counter(a) +aakey = list(aa.keys()) +aavalue = list(aa.values()) +ans = 0 +for i in range(len(aavalue)): + ans += (aavalue[i] * (aavalue[i] - 1))//2 +for i in range(n): + val = aa[a[i]] + print(ans-(val-1)) +" +p02720,s013146411,Wrong Answer,"from collections import deque + +k = int(input()) + +que = deque([1,2,3,4,5,6,7,8,9]) + +for n in range(0, k): + x = que.popleft() + if x % 10 != 0: + que.append(x * 10 + x % 10 - 1) + que.append(10*x) + if x % 10 != 9: + que.append(x * 10 + x % 10 + 1) + +print(x)" +p02555,s448156905,Accepted,"s = int(input()) +MOD = 10 ** 9 + 7 +ans = 0 +fact = [0] * 10000 +fact[0], fact[1] = 1, 1 +for i in range(2, 10000): + fact[i] = (fact[i-1] * i) % MOD + +def f(n, r): + return fact[n] * pow(fact[n-r], -1, MOD) * pow(fact[r], -1, MOD) + +for i in range(1, s//3+1): + if i == 1: + ans += 1 + else: + m = s - i * 3 + ans += f(m+i-1, m) + ans %= MOD +print(ans%MOD)" +p03544,s041473683,Wrong Answer,"n = int(input()) +l1 = 2 +l2 = 1 +l3 = l2 + l1 + +for i in range(n - 2): + l1 = l2 + l2 = l3 + l3 = l2 + l1 + + +print(l3)" +p03419,s987099232,Accepted,"n, m = map(int,input().split()) + +if n * m == 1: + print(1) + exit() + +if n > 1 and m > 1: + temp = 2 * (n + m) - 4 + ans = n * m - temp + print(ans) +else: + print(n * m - 2)" +p02720,s114803942,Accepted,"from collections import deque + +k=int(input()) + +lunlun=deque(i for i in range(1,10)) +for _ in range(k-1): + p=lunlun.popleft() + if p%10!=0: + lunlun.append(10*p+p%10-1) + lunlun.append(10*p+p%10) + if p%10!=9: + lunlun.append(10*p+p%10+1) +print(lunlun.popleft())" +p02689,s363919553,Wrong Answer,"import sys +import collections +import itertools +import numpy as np + +n,m = map(int, input().split()) +al = np.ones(n,dtype=""int8"") +H = list(map(int, input().split())) +AB=[] + +for i in range(m): + AB.append(tuple(map(int, input().split()))) + +for t in range(m): + A = AB[t][0] + B = AB[t][1] + + bou1 = H[A-1] + bou2 = H[B-1] + if bou10))" +p03241,s569297606,Accepted,"N,M = map(int,input().split()) + +# 約数列挙 +def enum_div(N): + ret = [] + i = 1 + while True: + if i**2 > N: + break + if N % i == 0: + ret.append(i) + if i**2 != N: + ret.append(N / i) + i += 1 + return ret + +ans = 0 +for i in enum_div(M): + if i >= N: + ans = max(ans,M / i) + +print(int(ans))" +p02712,s604706793,Wrong Answer,"n = int(input()) +sol = 0 +for x in range(1, n+1): + if x%3 != 0 and x%5 != 0: + sol += x +print(x)" +p03435,s542018764,Wrong Answer,"x = [list(map(int,input().split())) for i in range(3)] +m=0 +for i in range(3): + m+=sum(x[i]) +if m%3 == 0 and (x[0][0]+x[1][1]+x[2][2])%3==0: + print('Yes') +else: + print('No')" +p03339,s104027847,Wrong Answer,"N = int(input()) +S = input() + +ans = S[1:].count(""E"") + +for i in range(N-1): + count = ans + if S[i] == ""W"": + count += 1 + if S[i+1] == ""E"": + count -= 1 + ans = min(count,ans) +print(ans)" +p03705,s313335226,Wrong Answer,"N,A,B = map(int,input().split()) +if A>B: + print(0) +elif N == 1: + print(0) +elif A==B: + print(1) +else: + ans = 0 + C = (B-A+1) + for i in range(N-2): + ans += C + C -= 1 + print(ans)" +p03012,s742219417,Accepted,"n = int(input()) +w=list(map(int, input().split())) +ans = 10**4 +for i in range(n): + x = abs(sum(w[:i+1]) - sum(w[i+1:n])) + ans = min(ans,x) +print(ans)" +p03971,s550534678,Accepted,"N,A,B=map(int,input().split()) +S=list(input()) +a,b=0,0 +for i in S: + if i == ""a"" and a < A+B: + a += 1 + print(""Yes"") + elif i == ""b"" and a < A+B and b < B: + a += 1 + b += 1 + print(""Yes"") + else: + print(""No"")" +p02761,s313312540,Accepted,"n, m = map(int, input().split()) +ss = list() +cs = list() +for i in range(m): + s, c = map(int, input().split()) + ss.append(s) + cs.append(c) + +if n != 1: + data_range = range(10 ** (n - 1), 10 ** n) +else: + data_range = range(0, 10) + + +def is_ok(i): + for s, c in zip(ss, cs): + if int(str(i)[s - 1]) != c: + return False + return True + +for i in data_range: + if is_ok(i): + print(i) + break +else: + print('-1') +" +p02833,s163359668,Accepted,"N = int(input()) + +if N%2 == 1 : + print(0) + exit() + +ans = 0 +N //= 2 +while N : + ans += N//5 + N //= 5 + +print(ans) +" +p02629,s224341096,Accepted,"n = int(input()) +alp = ""abcdefghijklmnopqrstuvwxyz"" +def solve(n): + if n<26: + return [alp[n]] + + ans=[alp[(n%26)]] + + ans.extend(solve((n//26)-1)) + return ans + + +ans=solve(n-1) +ans.reverse() +print(*ans,sep="""")" +p03013,s586148374,Wrong Answer,"import sys + +N, M = map(int, input().split()) +A = [] + +for m in range(M): + if m == 0: + A.append(int(input())) + continue + + i = int(input()) + if A[-1] == i-1: + print(0) + sys.exit() + + A.append(i) + +li = [0] * (N+1) +li[0] = 1 + +for n in range(1, N+1): + if n in A or n == 1: + continue + + li[n] = li[n-1] + li[n-2] + +print(li[-1] % (10**9 + 7))" +p02881,s149718367,Accepted,"n = int(input()) +ans = 100000000000000 +for i in range(1, 1000001): + if n % i == 0: + a = i - 1 + b = n // i - 1 + ans = min(ans, a + b) +print(ans)" +p02912,s549128237,Wrong Answer,"import heapq +n,m = map(int,input().split()) +arr= list(map(lambda x: int(x)*(-1) ,input().split())) +heapq.heapify(arr) +for i in range(m): + d = heapq.heappop(arr) + heapq.heappush(arr,d//2) +print(sum(arr)*-1) + " +p02706,s054179233,Accepted,"N,M = map(int, input().split()) +A = list(map(int, input().split())) + +print(max(-1, N - sum(A)))" +p03076,s488430530,Accepted,"def i(): + return int(input()) +def i2(): + return map(int,input().split()) +def s(): + return str(input()) +def l(): + return list(input()) +def intl(): + return list(int(k) for k in input().split()) + +a = [str(input()) for _ in range(5)] + +n = 10 +cnt = 0 + +for i in range(len(a)): + if int(a[i][-1]) < n and int(a[i][-1]) != 0 : + n = int(a[i][-1]) + cnt = i + +for i in range(len(a)): + if i == cnt: + a[i] = int(a[i]) + elif int(a[i][-1]) == 0: + a[i] = int(a[i]) + else: + a[i] = (int(a[i])//10 + 1)*10 + +print(sum(a))" +p03637,s737752402,Accepted,"n = int(input()) +l = list(map(int,input().split())) +ans = [0,0,0] +for i in l: + if i % 4 == 0: + ans[0] += 1 + elif i % 2 == 0: + ans[1] += 1 + else: + ans[2] += 1 + +if ans[0] >= ans[2]: + print(""Yes"") +elif ans[1] == 0 and ans[0]+1 == ans[2]: + print(""Yes"") +else: + print(""No"")" +p02603,s657796469,Accepted,"n=int(input()) +ans=1000 +lst_1=list(map(int,input().split())) +# print(lst_1) +for i in range(n-1): + if (lst_1[i] i+1: + print(o[-1]) +elif len(e) > i+1: + print(e[-1]) +" +p03796,s972749604,Wrong Answer,"#整数の入力 +N = int(input()) + +ans = 1 + + +for i in range(N): + ans = ans * ((i+1)%(10**9 + 7)) + + +print(ans) +" +p02935,s424184076,Wrong Answer,"N = int(input()) +v = list(map(int,input().split())) +v.sort() + +while len(v) >= 2: + if len(v) % 2 == 0: + newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-1,2)] + v = newv + else: + f = v[len(v)-1] + newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-2,2)] + v = newv + v.append(f) + +if len(v) == 1: + print(v[0])" +p02823,s228553555,Accepted,"import sys +input = sys.stdin.readline +sys.setrecursionlimit(10 ** 7) + +n, a, b = map(int, input().split()) +if abs(a - b) % 2 == 0: + print(abs(a - b) // 2) +else: + small, big = min(a, b), max(a, b) + print(min( + (small - 1) + 1 + ((big - (small - 1) - 1 - 1) // 2), + (n - big) + 1 + ((n - (small + (n - big) + 1)) // 2) + )) +" +p02583,s014470693,Accepted,"n = int(input()) +yokolist = list(map(int, input().split())) + +count = 0 +for i in range(n-2): + for j in range(i,n-1): + for k in range(j,n): + x = yokolist[i] + y = yokolist[j] + z = yokolist[k] + if x != y and y != z and z != x: + if x < y + z and y < x + z and z < x+ y: + count += 1 + +print(count)" +p02995,s004100980,Accepted,"import math +a,b,c,d=map(int,input().split()) +lcm=(c*d)//math.gcd(c,d) +print((b-(b//c+b//d-b//lcm))-(a-1-((a-1)//d+(a-1)//c-(a-1)//lcm)))" +p02952,s529663422,Wrong Answer,"n = int(input()) +ans = 0 +for i in range(1, n+1): + if (i // 10 + 1) % 2 == 1: + ans +=1 +print(ans)" +p03745,s461899589,Wrong Answer,"n = int(input()) +A = list(map(int,input().split())) + +ans = 0 +pass_flag = False +for i in range(1,n-1): + if pass_flag: + pass_flag = False + continue + if A[i-1] < A[i] and A[i] > A[i+1]: + if not ans: + ans += 1 + ans += 1 + pass_flag = True + if A[i-1] > A[i] and A[i] < A[i+1]: + if not ans: + ans += 1 + ans += 1 + pass_flag = True + +print(ans)" +p03836,s174128746,Accepted,"from collections import deque +s, t = [0, 0], [0, 0] +s[0], s[1], t[0], t[1] = map(int, input().split()) + +dx, dy = t[0] - s[0], t[1] - s[1] +ans = deque() + +ans.append(""U"" * (dy)) +ans.append(""R"" * (dx + 1)) +ans.append(""D"" * (dy + 1)) +ans.append(""L"" * (dx + 1)) +ans.append(""U"") + +ans.append(""L"") +ans.append(""U"" * (dy + 1)) +ans.append(""R"" * (dx + 1)) +ans.append(""D"" * (dy + 1)) +ans.append(""L"" * dx) + +print("""".join(ans)) +" +p02900,s810790503,Wrong Answer,"A, B = map(int, input().split()) + +a, b = A, B +set_a = set([1]) +set_b = set([1]) + +for n in range(2, int(A ** 0.5) + 1): + if a % n == 0: + set_a.add(n) + while a % n == 0: + a //= n + print(a) + +if a != 1: + set_a.add(a) + +for n in range(2, int(B ** 0.5) + 1): + if b % n == 0: + set_b.add(n) + while b % n == 0: + b //= n + +if b != 1: + set_b.add(b) + +ans = len(set_a & set_b) +print(ans) +" +p02917,s489419300,Accepted,"N = int(input()) +B = list(map(int, input().split())) + +A = [] + +for i in range(N): + if i == 0: + A.append(B[0]) + elif i == N - 1: + A.append(B[-1]) + else: + A.append(min(B[i-1], B[i])) + +print(sum(A))" +p02608,s734140408,Accepted,"N = int(input()) + +ans = [0] * (N+1) +for a in range(1, 105): + if a*a > N : + break + for b in range(1, 105): + if a*a + b*b > N: + break + for c in range(1, 105): + if a*a + b*b + c*c + a*b + b*c + c*a > N: + break + ans[a*a + b*b + c*c + a*b + b*c + c*a] += 1 + +for i in range(1, N+1): + print(ans[i]) +" +p03127,s421683617,Accepted,"import sys +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + +def gcd(m, n): + r = m % n + return gcd(n, r) if r else n + +n, *a = map(int, read().split()) + +res = gcd(a[0],a[1]) +for i in range(2,n): + res = gcd(res, a[i]) + +print(res)"